Guide · 2026-04-29 · 9 min read
Cost-Efficient AI Agents: Tuning Settings and Orchestrating Tasks Without Burning Your Budget
Agent loops are where AI bills explode. A practical playbook for the per-call settings and the orchestration patterns that keep multi-agent systems fast, accurate, and an order of magnitude cheaper.
Agent Loops Are Where Bills Explode
A single GPT-5.5 call costs cents. A 12-step ReAct loop with tool calls, retries, and a critic pass on top can cost dollars per task — and most teams discover this the same way: a six-figure invoice at the end of the month.
The good news is that agent costs are unusually compressible. Two levers move the needle: the per-call settings every step uses, and the orchestration shape of how steps fit together. Get both right and the same workflow runs at 5–15% of its original spend with equal or better quality. Here's the playbook.
Part 1: The Per-Call Settings That Define Agent Cost
In a one-shot completion the model talks once. In an agent, it talks 5–50 times per task. Every leaky setting compounds.
1. `max_tokens` — Per Role, Not Per System
The single highest-leverage setting in any agent stack. Output tokens cost 5–10× more than input tokens, and agents generate output on every step. Set `max_tokens` *per role*:
- Planner / router: 256–512 tokens. It writes a plan, not an essay.
- Tool-calling step: 128–256 tokens. JSON arguments only.
- Worker / synthesizer: 1024–2048 tokens. Sized to the actual deliverable.
- Critic / verifier: 128–256 tokens. "Pass / fail + reason."
Leaving everything at 4096 is the most common — and most expensive — default. Tightening these alone routinely cuts agent bills 30–50%.
2. Reasoning Mode: Off by Default, On by Step
GPT-5.5, Claude Opus 4.7, and DeepSeek V4 Pro all support extended reasoning. It is brilliant for hard planning and catastrophically expensive for simple tool calls — reasoning tokens are billed at output rates and can be 10–50× the visible answer length.
The right pattern is not "always on" or "always off" but per-role:
- Reasoning on for the planner once at the top of a task.
- Reasoning off for every tool-call step and worker call in the middle.
- Reasoning on for the final critic only if the task is high-stakes.
3. `temperature` — Deterministic Where You Can
For tool calls, routing decisions, and structured extraction set `temperature: 0`. You get shorter, more consistent answers — which means fewer retries, smaller outputs, and prompt caching actually works because identical inputs produce identical outputs. Save higher temperatures for the one or two creative steps that genuinely need variance.
4. Native Tool Calling, Never Stringly-Typed JSON
Asking the model to "return JSON like this..." wastes tokens on schema reminders, validation retries, and apologetic preambles. Native tool calling / structured output modes (OpenAI, Anthropic, Google, DeepSeek all support them) emit shorter, schema-validated payloads with far fewer retries. On a 10-step agent that's typically 15–25% off the bill.
5. Cache the Long Static Prefix
Every major provider now offers cached input pricing at 5–10× lower than uncached. In an agent the system prompt + tool definitions + few-shot examples are re-sent on every step. If you put them at the *front* of the prompt and the changing scratchpad at the *back*, the entire static prefix caches.
For an agent that runs 20 steps with a 4K-token static prefix, this is the difference between paying for 80K cached input tokens (cheap) and 80K uncached tokens (expensive). Read Prompt Caching Explained for per-provider details.
6. Trim the Scratchpad — Aggressively
The scratchpad (prior thoughts + observations) grows on every step. By step 12, you might be sending 20K tokens of history per call. Two cheap fixes:
- Summarize after every N steps. A small model (Tier 4) compresses prior steps into 200 tokens of "what we learned so far."
- Drop tool outputs you no longer need. A 5KB API response from step 3 is rarely useful at step 9.
7. Hard Step Limits and Cost Budgets
Every agent run should have a hard `max_steps` cap and a per-task dollar budget that aborts the loop. Without it, a single hallucinated retry cycle can rack up $50 before anyone notices. Log per-step token usage and alert on outliers.
Part 2: Orchestration Patterns That Save Money
Settings are the floor. Orchestration is the ceiling. The biggest savings come from changing the *shape* of how agents collaborate.
Pattern A — Cascade (the default you should already be running)
Classify the task on the cheapest model first; escalate only if needed.
In production this pattern reliably keeps 60–80% of traffic on Tier 3 or below while quality on a blind eval is indistinguishable from "always Tier 1." It is the single highest-ROI change for any team currently routing every request to a flagship.
Pattern B — Planner / Worker / Critic Split
One frontier-model planner decomposes the task once. Cheap workers execute each step. A small critic checks the final output. Asymmetric models per role:
- Planner: Tier 1 (Claude Opus 4.7 or GPT-5.5 Pro), reasoning on, runs once.
- Workers: Tier 2 or Tier 3 (Sonnet, Gemini 3 Flash, DeepSeek V4 Flash), reasoning off, run N times.
- Critic: Tier 3 with a tight prompt and `max_tokens: 256`.
You pay frontier prices once, not N times. For most multi-step tasks this is 3–8× cheaper than running the planner model on every step.
Pattern C — Parallel Fan-Out, Sequential Synthesis
Steps that don't depend on each other should run in parallel, not in series. Three independent tool calls take one step instead of three — and each one can use a smaller model since it has narrower scope. Sequential dependencies are real, but in most agents the LLM defaults to serializing things that could parallelize. Audit your traces and look for calls that have no causal link.
Pattern D — Tool-First, LLM-Last
Many "agent" tasks don't need an LLM in the middle of the loop at all. Call your search API, your database, your validator directly — and only ask the model to *interpret* the structured results at the end. A Tier 3 model summarizing 5 deterministic tool outputs costs cents. A Tier 1 agent that "decided" to call the same tools costs dollars.
Pattern E — Memoize Tool Calls
Identical tool calls in the same task (or across nearby tasks) should hit a cache. Web searches, database reads, and currency conversions are all idempotent within short windows. A simple in-memory LRU keyed on `(tool_name, args)` typically eliminates 20–40% of redundant calls.
Pattern F — Batch the Background Work
If the agent doesn't have to answer in real time — overnight reports, eval grading, document processing — push every step through the Batch API. It is ~50% off on every major provider and stacks cleanly with prompt caching.
Part 3: A Real-World Cost Comparison
Same task: process a customer support ticket, classify it, retrieve relevant docs, draft a reply, verify it.
Naive baseline — every step on GPT-5.5, 12 average steps, no caching:
- ~$0.42 per ticket → $42,000/month at 100K tickets.
Same task, settings-only fixes (per-role `max_tokens`, reasoning off mid-loop, native tool calls, prefix caching, scratchpad summarization):
- ~$0.14 per ticket → $14,000/month. Same models, same flow.
Same task, settings + orchestration (cascade + planner-worker-critic, DeepSeek V4 Flash for workers, GPT-5.5 only for the planner and on the 5% of tickets the critic flags):
- ~$0.028 per ticket → $2,800/month. Same blind-eval quality.
That's a 15× reduction without changing what the agent *does* — only how it's wired.
Part 4: A 30-Minute Audit You Can Run Today
Pull the last 100 traces from your top agent and check, in order:
1. What's `max_tokens` on every step? Set per role to the smallest value that fits real outputs.
2. Is reasoning mode on for steps that don't need it? Turn it off everywhere except the planner.
3. Is your prompt structured as static-prefix-first / dynamic-suffix-last? If not, fix it for caching.
4. Are tool calls using native tool calling, or stringly-typed JSON?
5. How long is the scratchpad on the last step? If it's >8K tokens, add a summarization step.
6. What's the median model used? If it's a Tier 1 flagship on every step, you can split into a planner-worker pattern this afternoon.
7. Is there a hard `max_steps` cap and a per-task budget? Add both before they're needed.
Most teams find 4 of 7 are wrong, and fixing them collapses agent spend by 5–10× in a single week.
Run Your Numbers Before You Migrate
Don't take any of these multipliers on faith. Plug your real per-step token volumes and the model mix you're considering into the AI Agent Loop Cost Estimator and compare side-by-side. The right answer is almost always a mix — frontier model for the planner, mid-tier for the workhorse steps, cheap-and-fast for everything trivial, and batch for everything the user doesn't see in real time.
Tighten the settings first, restructure the orchestration second. By the end of the week, your agent does the same job for a fraction of the bill.