The agent tax is the extra token cost an AI agent pays because it resends its whole, growing context on every step it takes to finish one job. A single chat turn pays for the context once; a 20-step agent pays for it 20 times, each time a little larger. Below, one agent task is priced line by line at list rates, followed by the five levers that change the result most.
How AI agent cost adds up: a 20-step example
Assume an agent that starts each task with an 8,000-token base (system prompt, tool definitions, task). Every step appends about 2,000 tokens of tool results and model output, and every step writes 500 output tokens. Step i therefore reads 8,000 + 2,000 × (i − 1) input tokens.
Input tokens over 20 steps:
Σ = 20 × 8,000 + 2,000 × (0 + 1 + … + 19) = 160,000 + 2,000 × 190 = 540,000 tokens
Output tokens: 20 × 500 = 10,000.
The base is only 30% of that input (160,000 of 540,000). The other 70% is the same tool results being read again on later steps. The last 8 steps alone read 312,000 tokens, more than the first 12 combined (228,000).
Priced at ATP list rates per million tokens, as of October 2026:
The same base context answered in one turn costs 8,000 × $3/M + 500 × $15/M = $0.024 + $0.0075 = $0.0315 on claude-sonnet-4-6. The agent task costs about 56 times as much. That multiple is the agent tax: the rate card did not change, the number of tokens did.
Anthropic publishes one real-world data point: in Claude Code, agent teams use "approximately 7x more tokens than standard sessions" when teammates run in plan mode, because each teammate keeps its own context window (Claude Code costs).
Five levers that cut the agent tax
1. Cap steps
Input grows roughly with the square of the step count, so the late steps are the expensive ones. Set a hard maximum and return a clear failure when it is reached. If the same task fits in 12 steps, input drops to 12 × 8,000 + 2,000 × 66 = 228,000 tokens and the task costs $0.77 instead of $1.77.
2. Summarise tool output before it enters the context
Replace raw file contents and full API responses with a short summary or the lines that matter. If growth per step falls from 2,000 to 500 tokens, input becomes 160,000 + 500 × 190 = 255,000 tokens: $0.765 + $0.15 = $0.92 per task, 48% less.
3. Run sub-steps on a cheaper model
Many steps only read a tool result and decide what to call next. Keep the decisions on claude-sonnet-4-6 and route the rest to deepseek-v4-flash. With 6 decision steps and 14 sub-steps, each averaging 27,000 input tokens:
- Sonnet: 162,000 × $3/M + 3,000 × $15/M = $0.486 + $0.045 = $0.531
- Flash: 378,000 × $0.2/M + 7,000 × $0.4/M = $0.0756 + $0.0028 = $0.078
- Total: about $0.61 per task, 66% less than all-Sonnet
Test quality on your own tasks before switching; the DeepSeek vs Claude comparison is a starting point.
4. Use prompt caching where your provider supports it
Most of an agent's input is a prefix it already sent one step earlier. On Anthropic's own API, a cache read costs 0.1× the base input rate and a 5-minute cache write costs 1.25× (Anthropic pricing). In the 20-step example, 494,000 of the 540,000 input tokens are repeats. At Anthropic's Sonnet 4.6 rates that is 494,000 × $0.30/M + 46,000 × $3.75/M + $0.15 output = $0.148 + $0.173 + $0.15, about $0.47 per task. The cache expires after its lifetime, so a step that waits on a slow tool can miss it. Check how your provider meters cached tokens before counting on this lever.
5. Give each agent its own budget
Put each agent in its own project and allocate credits to it. A project can only spend what it was allocated, and requests return 402 once the balance is used up, so a stuck loop stops at the ceiling instead of at month-end. At 10,000 Sonnet tasks a month, the allocation is 1,770,000 credits (1 credit = USD 0.01). Setup: team with budget caps.
How to measure cost per completed task
The gateway sees requests; only your application knows which requests belong to one task. Every ATP response carries an x-request-id header. Log it next to your own task or session ID, the step number, and whether the task ultimately succeeded.
Then:
- Pull the rows for those request IDs from Request logs, which show model, status, and input/output tokens per request (usage and logs). Retention is 7 days, so export weekly with the request logs endpoint.
- Multiply tokens by the model's list rate and sum per task.
- Divide total cost, including failed and abandoned tasks, by the number of completed tasks.
Failed tasks belong in the numerator. An agent that succeeds 80% of the time at $1.77 per attempt costs $1.77 / 0.8 = $2.21 per completed task.
Watch for one pattern in the logs: a 200 with empty content. On reasoning models this usually means max_tokens was too low for the thinking budget. ATP typically reports zero usage and deducts no credits for it, but an agent that retries without raising max_tokens will repeat the empty call (errors).


