How do I cut the token costs of AI coding agents?
Coding agents resend large amounts of code and history on every step, so input tokens dominate the bill. Use prompt caching, keep context lean, reserve frontier models for hard tasks, and run routine agent work on an open coding model hosted on your own hardware, where tokens have no per-unit price.
Check caching first. Agents that reuse the same files and instructions should hit the cache on most input tokens. A low cache hit rate is often the single biggest waste.
Split the work. Planning and tricky debugging can go to a frontier model; tests, refactors, documentation and bulk edits can go to a strong open model.
Run long jobs locally. Background agents that run for hours are where per-token billing hurts most and where owned hardware pays back fastest.
Watch speed. Agents read long prompts, so prompt processing speed matters as much as generation speed. Test with real repositories.
Sources
Updated
