Worked Example: Autonomous PR & Bug-Fix Engineering Agent
Autonomous software engineering agents consume far more tokens per task than customer-facing chatbots. Before writing a single patch, a coding agent ingests repository guidelines, bash/filesystem tool schemas, stack traces, test logs, and multi-file diffs—then iterates through build-test-fix loops until CI passes.
The pre-loaded Coding Agent preset models 80 engineering tasks per day using Claude Sonnet 5.5 ($2.00/1M input, $0.10/1M cached input, $10.00/1M output) with 35% of steps routed to Claude Haiku 5.5 ($0.10/1M input, $0.01/1M cached input, $0.50/1M output) for file discovery and log compression.
Base context starts at 7,500 tokens (3,500 coding instructions, 2,200 filesystem/shell tool schemas, 1,800 issue description and error trace). Across 12 steps, each file read or test log appends 2,800 tokens and each turn generates 900 output tokens of diffs and tool calls. By Step 12, peak context reaches 39,200 tokens, totaling 274,800 input tokens and 10,800 output tokens before retries. With 75% prompt caching, 15% retry overhead, 4 sandbox test runs at $0.001, an 85% autonomous pass rate, and P90 budgeting, the exact per-PR and monthly run rates update live above.
Why Coding Agents Hit Context Ceilings Quickly
- Unfiltered Test & Build Output: A single verbose compiler trace or
npm testdump can inject 15,000 tokens in one step. Truncating stdout to the failing assertions keeps step growth predictable. - Model Routing Gains: Offloading read-only repo search and lint log summarization to economy models cuts blended input and output rates without degrading the primary model's patch quality.
- Framework Alignment: If you are building directly on Claude's filesystem and shell loop, check the Agent Framework Picker to compare the Claude Agent SDK against LangGraph and custom loops.
Next Steps for Engineering Teams
Compare coding economics against shorter operational workflows using the Customer Support Agent Cost Calculator or the Research Agent Cost Calculator. For concrete techniques to compact diffs and raise cache-hit ratios above 80%, read How to Reduce AI Agent Costs and Tokens and Context Windows Explained.