Putting a budget on AI coding agents
Ask a team what an AI coding agent costs and you'll often hear a monthly total. Ask what one task costs and the answer is usually "it depends." That gap is where surprise bills come from. Agent costs are hard to predict because of how agents work. Fixing it means putting limits on each run, not jus

Ask a team what an AI coding agent costs and you'll often hear a monthly total. Ask what one task costs and the answer is usually "it depends." That gap is where surprise bills come from.
Agent costs are hard to predict because of how agents work. Fixing it means putting limits on each run, not just on the account.
An agent works in a loop: read context, decide, call a tool, read the result, decide again. Each step is a model call, and each call sends the context the model needs: the task, instructions, relevant files, and the history of the run so far.
1. Scope the task before the run. A plan with a clear goal, the files likely involved and a definition of done keeps the run short. "Fix the date parsing bug in invoice/parse.py, add a test" is a cheaper run than "fix the invoice bugs."
2. Cap steps and time per run. Pick a step limit and a wall-clock limit that fit the task size. When a run hits a cap, it should stop and report what it has done and where it's stuck. A partial result with a clear note is useful; a run that silently keeps trying isn't.
3. Limit retries on the same failure. If the same test fails the same way after a couple of attempts, the agent probably needs information it doesn't have. Stop and ask.
4. Keep context narrow. Give the agent the files that matter and let it request more. Summarize long tool output (logs, test results) instead of passing it whole.
5. Match the model to the step. Planning and tricky debugging may need a stronger model. Mechanical edits, formatting and simple checks usually don't.
6. Use prompt caching where it applies. Model providers offer caching for repeated prompt prefixes such as system instructions and stable context. On Anthropic's API, for example, reading from the cache is billed at a small fraction of the normal input price (10% for most models), while writing to the default five-minute cache costs a little more than normal input. Agents that resend the same instructions and files on every step are a good fit. Check your provider's current pricing, since multipliers and cache lifetimes differ by provider and model.
7. Measure per task, not per month. Track tokens and cost per run, alongside the outcome: did it produce a change that passed? The useful number is cost per accepted change, not total spend.
There's a second cost that doesn't show on the model bill: human time spent on changes that were never going to merge. A pull request that fails tests or has an obvious security issue still takes someone's time to open, read and reject.
Catching those before a person sees them saves more than tuning prompts. Run the tests on the exact commit, run an independent review of the diff, and only ask for human attention when both pass.
AI CodeOps splits work into plan, build, review and test, done by AI agents on your repository. A pull request only opens when your tests pass on that exact commit, the AI review of the real diff has no open high or critical findings, and a person approves. Changes that fail earlier stop there, without reaching a reviewer's queue. If anything errors, the gate fails closed.
A budget won't make agent costs fixed, but it makes them bounded, and it makes it obvious which tasks are worth handing to an agent at all.
Free during the open beta: https://aicodeops.dev