Cost · · 4 min read
Why do agent conversations get more expensive as they get longer?
Answers to conversation-history billing, previous_response_id, prompt caching, zero cache hits, and context summarization without losing the task.
An agent that rereads a growing conversation spends more on each turn, even when the user asks a short question. Earlier messages, retrieved documents, tool definitions, and tool results all add to the input.
Developers ask whether previous_response_id history is charged, how prompt caching actually works, and how to balance long-chat quality with cost. The answer separates retaining information, supplying it to the model, and avoiding repeated computation.
Does previous_response_id make earlier conversation tokens free?#
No. OpenAI's conversation-state guide explains that earlier input tokens in the chain remain billed as input. The reference simplifies state management, and the model still processes the prior context.
To investigate cost, compare the usage returned by successive requests with the application's visible turns. Keep the response ID and logical task ID together to see whether a small follow-up pulled a much larger history along.
Do not estimate a task from its final user message. A task spans several model calls, tool calls, repairs, and review, so cost per finished task is the better comparison for judging a change.
Does prompt caching remember the answer or skip the tool call?#
Prompt caching reuses computation for eligible repeated input. It does not turn an earlier answer into a reviewed fact or stop a repeated tool call. OpenAI's prompt-caching guide describes prefix reuse and the usage fields that show cache hits.
Three separate improvements:
- Stable prompt structure reduces repeated input processing.
- Retaining a completed research result avoids another search.
- Saving a reviewed method reduces repeated instruction.
A cached call that searches the same records again still wastes work.
In an account-brief workflow, preserve the resolved account identity and source references between steps. The next step inspects the retained result and refreshes only the fact that needs freshness, without rediscovering the customer.
Why are cached tokens zero even when requests look similar?#
Similar meaning is not a matching eligible prefix. The caching guide describes prefix requirements, and the public caching question above shows how a change early in the request breaks the match.
Compare the actual serialized requests, not the prompt template in source control. Your application can inject a timestamp, reorder tool definitions, change a schema, or move retrieved material to the start. Inspect these before concluding that caching is broken.
Isolate one change at a time with a controlled pair of requests: fix the model and prefix, vary only the user content, and record the returned usage. Then repeat with your real agent path, and if only that path fails, compare what the framework adds. Do not publish a savings estimate based on an assumed cache hit.
Should I summarize conversation history to reduce cost?#
Summarization reduces what you resend and can discard the detail the next action needs, the tradeoff the long-chat question above raises. Decide what must survive the handoff. For an operational task, keep the requested outcome, unresolved questions, stable resource identifiers, source references, completed actions, and uncertain actions. Preserve exact approval-sensitive values outside a lossy prose summary: “the customer approved the update” does not identify which update.
Test with a fixture where a later correction changes an earlier fact, then ask the next step to act on the corrected value and cite its source. Also test an unresolved conflict: a summary that makes two disagreeing statements sound settled is shorter and less useful.
How do I choose between recent messages, summaries, and retrieved memory?#
Each does a different job:
- Recent messages preserve local conversational detail.
- A task summary carries progress.
- Retrieved material supplies relevant outside information.
- Reviewed memory preserves a reusable fact with scope and a way to correct it.
Assemble a small task packet:
| Material | Reason to include it |
|---|---|
| Current request | Defines the outcome to produce |
| Recent correction | Prevents repeating a known mistake |
| Task checkpoint | Avoids redoing completed steps |
| Source excerpt | Grounds the answer in current evidence |
| Exact pending action | Preserves the target and parameters awaiting a decision |
Measure on representative tasks: total usage, latency, completion quality, repeated tool calls, and user corrections. A shorter prompt that causes another failed attempt raises total cost.
The OpenAI and Anthropic guides show where to find provider usage. Deixic's memory and skills hold what the company deliberately keeps for later work, so a new task starts from the reviewed parts of earlier ones.
Find another symptom in the agent troubleshooting question index.