Cost control: tier, cache, and cap fan-out
Most agent spend is avoidable. Route easy work to cheap models, cache repeated calls, set token budgets, and cap fan-out concurrency.
Model tiering
Not every step needs your most expensive model.
- Route classification, routing, and extraction to a small/cheap (or local) model; reserve the frontier model for hard reasoning. See show local agent stack.
- A tiered fallback (local → cheap API → frontier) keeps both cost and the zero-key floor in check.
Caching and token budgets
Stop paying twice for the same answer.
- Cache deterministic or repeated calls (identical prompt → cached result).
- Set a token budget per run and truncate or summarize context that exceeds it — runaway context is the silent cost driver.
Cap fan-out concurrency
Unbounded fan-out spends money *and* triggers rate limits.
- The same concurrency limiter that fixes reliability (reliability) is also a cost cap — bounded parallelism bounds spend.
Related patterns
Parallelization: fan out independent work
Parallelization runs independent sub-tasks concurrently — split-and-merge for speed, or same-task-N-ways for accuracy — but only when no step depends on another's output.
Prioritization: decide what to do next
When an agent faces a pile of possible actions, score and order them by urgency, value, dependencies, and cost instead of just grabbing whatever came in first.
Routing: send each input to the right handler
Routing puts a thin classifier in front of your specialists — it inspects each input, picks the handler best suited to it, and dispatches without doing the work itself.