Context budgets for coding agents in real repositories

Coding agents have changed how many developers work, and they have also changed how fast quotas and bills grow. A single instruction can make an agent list directories, open files, run tests and reread its own notes, each a model call carrying a large context. Developers often notice that a few agent sessions consume more than a week of chatting, and some go as far as considering removing all documentation from a repository so the agent has less to read.
That instinct is understandable but usually backwards. This article explains where an agent's tokens actually go, why the right documentation saves more than it costs, and which habits reduce waste without making the agent dumber. It also looks at the wider question many people raise: whether agents have plateaued, and what that means for how much you should trust and pay for them. The site is independent and not affiliated with Anthropic or any agent vendor.
Frequently asked questions
What is a context window?
The total amount of text a model can consider in one request, measured in tokens. It includes the system prompt, the conversation, any files loaded and the tool outputs. Everything inside it is processed on each call.
Why does an agent use more tokens than chat?
An agent works in many hidden steps. Each step sends the growing context back to the model, so costs accumulate with every file read and command run, not just with each message you type.
Does removing documentation from a repo save tokens?
It can reduce what the agent reads in some cases, but it usually makes it explore more blindly, opening many files to rediscover what a short guide would have told it. Concise, targeted docs tend to save tokens.
What is the difference between a project guide and a skill file?
A project guide gives the agent a stable overview of the repository. A skill file describes how to perform one specific task and is loaded only when needed. Both reduce exploration if kept short.
Have coding agents plateaued?
Opinions differ. They still make mistakes and need a human in the loop, and improvements feel incremental after earlier leaps. But tooling, context handling and workflows continue to improve how useful they are in practice.
Which is better for cheap agent steps, a small or a large model?
Small models are fine for narrow steps like summarising a file or writing a commit message. Planning and multi-file changes benefit from a stronger model. Mixing them is often the most economical choice.
Can I point an agent at the free endpoint here?
Tools that accept a custom OpenAI-compatible base URL can use it with model free-ai. It is a 35B open model, so expect it to be weaker than frontier models on large refactors.
Anatomy of an agent session
Picture a simple request: fix a failing test. The agent reads the instruction, then lists the repository, opens the test file, opens the module under test, runs the test suite, reads the output, edits a file, runs the tests again and reports. That may be ten or more model calls, and each one carries the system prompt, the conversation so far and every file and output collected along the way.
The result is that cost grows faster than the number of steps. The tenth call is far larger than the first because it includes everything the first nine produced. Long sessions on big repositories can reach the edge of the context window, at which point the agent summarises or drops information and may repeat work.
Understanding this shape is the first step to controlling it. Once you see that cost is driven by what accumulates in context rather than by the number of instructions you type, the remedies become obvious: give the agent less to read, make what it reads more useful and end sessions before they grow bloated.
System prompts and tool definitions
Agents ship with long instructions describing tools, safety rules and style. These are sent on every call. They are rarely the largest item, but they are a constant overhead.
Tool output is the heavyweight
Test logs, directory listings and file contents dominate. A verbose test runner that prints thousands of lines can cost more than the whole conversation.
The case against deleting your docs
When an agent seems to waste tokens reading Markdown, deleting the Markdown feels like a fix. In practice, agents without guidance explore more. They open files to learn the architecture, grep for conventions and try commands to find out how tests run. All of that costs tokens, and it also introduces mistakes when the agent guesses wrong.
The real problem is usually that the docs are long, stale or not aimed at the agent. A two-page architecture overview written for new human hires, last updated two years ago, is both expensive and misleading. A short, current file that says where things live and how to run the checks is cheap and saves many exploratory calls.
Write for the agent, briefly
A compact project guide with the directory map, the build and test commands, key conventions and known traps is worth far more than a long narrative. Keep it to what changes the agent's decisions.
Move task recipes into skills
Instructions for occasional tasks, such as adding a migration or cutting a release, belong in separate files loaded on demand. See portable skills and tool loops for the general pattern.

Plan cheaply, execute precisely
One habit consistently reduces agent spend: think in an ordinary chat first. Discuss the approach, the files involved and the risks in a regular conversation, which is a single call per message, then give the agent a precise task with the plan attached. The agent spends its budget executing rather than exploring.
This also improves results. An agent told exactly which files to change and what the tests should show makes fewer wrong turns than one asked to figure it all out. Some developers write the plan in a scratch Markdown file the agent can read, which doubles as a record of the change.
- Describe the goal and constraints in chat before starting the agent
- Name the files or modules that should change
- State how to verify success, such as a specific test command
- Ask the agent to stop and ask if the plan turns out wrong
Taming tool output
Because tool output is the largest consumer, the biggest savings come from controlling it. Configure test runners to print only failures. Pipe long commands through filters before the agent sees them. Prefer targeted searches over full directory listings.
Many agents let you define custom commands or scripts. A small script that runs the relevant tests and prints only the first failure with its stack trace can replace a command that dumps pages of output.
Quiet test runners
Most test frameworks have flags for minimal output or for stopping at the first failure. Make those the defaults the agent uses.
Targeted search beats listing
Encourage the agent to search for a symbol or filename instead of listing whole trees. A search result is a few lines; a recursive listing of a large repository is thousands.

Keeping sessions short
Long sessions accumulate context the agent no longer needs: files read for a sub-task that is finished, output from tests that now pass, a discussion that went nowhere. Starting a fresh session for each logical task, with a short summary of what came before, keeps every call smaller.
Commit early and often. A clean commit is a natural checkpoint, and a new session can start from it with a brief note instead of carrying the whole history forward.
Summaries as hand-offs
Ask the agent to write a few lines describing what it did and what remains before you end a session. Paste that into the next one. It is cheap context with high value.
Using a cheap model for side tasks
Not every step needs the strongest model. Generating a commit message, summarising a diff, writing a changelog entry or drafting docstrings are well within reach of a mid-sized open model. Moving these off the premium model reduces cost without touching the hard parts.
The snippet below summarises a git diff with the free endpoint on this site. It reads the staged changes and asks for a concise commit message, which you can review before committing.
Know where it falls short
A 35B model can misread a subtle change or miss the intent behind a refactor. For routine diffs it is usually fine; for anything important, read the message before you accept it.
import subprocess
from openai import OpenAI
client = OpenAI(base_url="https://api.anthropickeyfreeapi.com/v1", api_key="none")
diff = subprocess.run(["git", "diff", "--cached"], capture_output=True, text=True).stdout
if not diff.strip():
raise SystemExit("nothing staged")
r = client.chat.completions.create(
model="free-ai",
messages=[
{"role": "system", "content": "Write a git commit message: one summary line under 72 chars, a blank line, then up to 4 bullet points."},
{"role": "user", "content": diff[:50000]},
],
temperature=0.2,
)
print(r.choices[0].message.content)
Have agents plateaued?
A recurring discussion asks whether coding agents stopped improving after the big leaps of recent years. Agents still make mistakes, cannot be fully trusted and need a human to review their work. Features arrive steadily, but each new model feels less like a revolution than the last.
There is truth in that, and it argues for a practical stance. Treat agents as fast, capable assistants that need supervision, not as replacements. Spend premium capacity where it clearly helps, keep reviews in place, and do not pay for hours of unsupervised exploration that a short plan would have avoided.
Basic mistakes still happen
Even strong models sometimes give wrong answers to simple coding questions with full confidence. Tests and review remain the safety net, whichever model you use.
Cheatsheets and conventions that help
Shared cheatsheets of agent commands and shortcuts circulate widely because small habits compound. Knowing how to clear context, resume a session, switch models or run a custom command saves time and tokens every day. Spend twenty minutes learning your agent's commands; it pays back quickly.
At the team level, agree on conventions: where the project guide lives, how skill files are named, which tests are the quick ones. Consistency means every developer's agent sessions start from the same efficient baseline.
Make shortcuts a team habit
When one person discovers a command that clears stale context or runs only the affected tests, share it. A short team cheatsheet kept in the repository spreads good habits faster than any training session.

Measuring what changed
Before and after any change to your repository or habits, measure. Note tokens per task from your provider's usage page or your own logs, along with whether the task succeeded on the first try. After a week, you will see which habits actually reduced spend and which only felt productive.
If you route side tasks to the free endpoint, log those calls too; the guide on tracking API spend shows a simple ledger. Keep in mind its per-IP limits of one request per second with bursts of three and 10,000 requests per day, and that it is stateless, so each call carries its own context. For background on plan quotas, see why Claude limits run out.
Compare like with like
Measure the same kind of task before and after a change. A week of bug fixes and a week of new features consume very different amounts, so mixing them hides the effect you are trying to see.
Send a prompt to the keyless free-ai endpoint from the home page and see how it handles your own task, no signup needed.
Read also
- What does an overloaded error from an AI API mean, and what helps?
- How to build an n8n pipeline that refreshes old blog posts with AI
- Why do Claude usage limits run out after just a few messages?
- Claude Pro vs ChatGPT Plus: which is better for learning to code?
- Are free Claude credits, gift trials and shared accounts safe?