Cost and budget control for AI coding agents
Cost estimation
Estimating token and API costs before tasks
- A Preflight Registry for File Hashes and Token Counts
- Budgeting a Full Mutation Run
- Costing a Caller Inventory Pass Across a Monorepo
- Costing a Retrieval Eval: Golden Queries and Judge Calls
- Costing a Self-Review Gate: Tokens, Minutes and Review Time
- Costing a Wrong Tool Pick in Tokens and Retries
- Estimating a Dependency Change Before an Agent Installs
- Estimating Token Cost Before You Send an Agent a Task
- All of Cost estimation
Agent budgeting
Budgeting agent runs and workflows
- Blocking a Run When the Budget Check Fails: Exit Codes and Logs
- Enforcing Budgets Across Child Agents and Sub-Tasks
- Reserving Rate-Limit Capacity Alongside Token Spend
- Setting a Maximum Review Cost per Agent Branch: A Policy Guide
- Setting a Per-Task Budget an Agent Cannot Exceed
- A Budget Ledger Schema: Reservations, Refunds, Charges
- A Fallback Path When the Reservation Broker Is Down
- Budgeting a Shadow Copy of Production Traffic
- All of Agent budgeting
Spend tracking
Tracking and reconciling AI model spend
- Measuring Token Spend from Context Files and Skills
- Proxying Reservations for Sub-Agents on an Agent Platform
- A Broker Log Schema That Joins Reservations to Spend
- A Budget Dashboard: Traces, Spend and Stop Reasons Joined
- A Check Cost Ledger: Tokens, Time and Spend in One Table
- A Rejected Count: Logging the Preflight to Provider Gap
- A Shadow-Run Log Schema: Fields for Comparing Model Outputs
- How to Log an Agent Run So You Can Tell Where It Went Over
- All of Spend tracking
Cost optimization
Caching and routing to reduce agent costs
- Choosing a Model Per Task from Pass Rates and Token Counts
- Routing Only the Hard Cases to the Expensive Model
- Testing Output Against a New Model Without Burning the Budget
- Caching and Routing: When a Cache Hit Should Still Escalate
- Hashing a Prompt Template into the Same Key
- Pricing a Cache Hit and a Cache Miss in Dollars
- Prompt Caching for Agents: What to Cache and Skip
- Routing Agent Requests to the Cheapest Model That Passes Evals
- All of Cost optimization
Budget overruns
Handling budget overruns and orphaned agents
- A Grace Allowance When the Quota Service Is Down
- Fan-Out Without Fan-In: Handling Orphaned Sub-Agents
- Killing a Run Mid-Stream Without Corrupting State
- Postmortems for Budget Overruns: Writing the Run Record
- Reading the Override Log for Patterns: Queries and Thresholds
- Refunding Reserved Capacity When an Agent Task Fails
- Reporting Agent Overages Up: Metrics a Manager Can Act On
- Reserving Budget for Orphaned Sub-Agents
- All of Budget overruns