Back to blog

Cost optimizationGuide

Multi-agent handoff cost: what a 3-agent chain uses in tokens

See why every agent in a chain re-reads all earlier handoffs, what that costs in tokens, and three changes that shrink the input.

By CheapTokens TeamPublished Updated 6 min read

Cover: three agents in a chain passing a growing handoff note
On this page
  1. Where the tokens pile up
  2. What 100 tasks a day cost
  3. Three ways to shrink the bill
  4. 1. Make the handoff a short structured note
  5. 2. Pass each agent only what it needs
  6. 3. Give short roles a cheap model
  7. Why not just pass the KV cache?
  8. Before you scale to hundreds of runs

Your three agents finished the job, and the bill is bigger than the job looks. The reason is simple: with text handoffs, every agent pays to read everything the agents before it wrote. A 1,500-token plan is paid for once when the planner writes it, then again by the coder, then again by the reviewer. Trim the handoff, hand each agent only what it needs, and the input of every later agent gets smaller.

Below: a worked 3-agent example with its token math, a cost estimate for 100 tasks a day on live prices, and three changes you can make today. Chat-completions APIs are stateless, so every request carries its full context again (why a long chat costs more and how the messages array works cover the basics).

Where the tokens pile up#

Say you run a planner, a coder and a reviewer. The task plus instructions is 1,000 tokens. The planner writes a 1,500-token plan, the coder writes 3,000 tokens of code and notes, the reviewer writes an 800-token verdict. These are round numbers for the example, not a measurement; swap in your own from the usage field (how to read it).

Guess the number

How many tokens does the reviewer read as input?

Show answer

Answer: 5,500

5,500: the task (1,000), the plan (1,500) and the code (3,000) all arrive in its request.

Each agent's input is the task plus every handoff it receives:

Agent Reads (input) Writes (output)
Planner 1,000 (task) 1,500
Coder 1,000 + 1,500 = 2,500 3,000
Reviewer 1,000 + 1,500 + 3,000 = 5,500 800
Whole chain 1,000 + 2,500 + 5,500 = 9,000 1,500 + 3,000 + 800 = 5,300

The chain reads 9,000 tokens to produce 5,300. Add a fourth agent and it would read the task plus all three handoffs, so input grows with every hop, not just by one handoff.

What 100 tasks a day cost#

A handoff token is billed once as output, when the agent writes it, and then as input for each later agent that reads it. Output tokens are priced higher than input tokens, so in this example the answers are the larger share of the bill even though the chain reads more than it writes (input vs output tokens).

One task is 9,000 tokens in and 5,300 out. On MiniMax-M2.7 that is $0.0012 per task. For 100 tasks a day, these are the live prices across our models, next to OpenRouter:

Model Per request 100 requests OpenRouter, 100 requests
GLM-5.3-Flash $0.00039 $0.0392 $0.0773
DeepSeek-V4-Flash $0.00067 $0.0665 $0.126
MiniMax-M2.7 $0.0012 $0.125 $0.906

9,000 input and 5,300 output tokens per request. Prices per 1M tokens are current and change together with our tariffs; the OpenRouter column shows reference prices for the same workload.

In total, with input and output counted together, the CheapTokens models above come out cheaper than OpenRouter for this chain.

Want the calculation for your own chain? Put the average request of one agent into the calculator: about 3,000 tokens in and 1,800 out, repeated 300 times, is 100 tasks of three agents.

Cost calculator

100 tasks a day, three agents each

Input tokens per request: 3,000 · Output tokens per request: 1,800 · Requests per day: 300

ModelPer dayPer month
GLM-5.3-Flash$0.0396$1.19
DeepSeek-V4-Flash$0.0675$2.03
MiniMax-M2.7$0.126$3.78

Three ways to shrink the bill#

1. Make the handoff a short structured note#

The planner does not need to write an essay for the coder. Ask for fields: goal, files, steps, constraints. Say a short note of eight one-line steps takes about 400 tokens instead of 1,500 (an assumption: put your own number from usage), and every later agent reads that smaller note. Cap the answer with max_tokens, set a bit above the expected note, so a chatty model cannot sneak the essay back in.

python
import os
from openai import OpenAI

client = OpenAI(
    base_url='https://api.cheaptokens.dev/v1',
    api_key=os.environ['CHEAPTOKENS_API_KEY'],
)
task = 'Add a --dry-run flag to the export command'

plan = client.chat.completions.create(
    model='deepseek-ai/DeepSeek-V4-Flash-0731',
    max_tokens=500,
    messages=[
        {'role': 'system', 'content': 'Reply with JSON only: {goal, files, steps, constraints}. At most 8 steps, one line each.'},
        {'role': 'user', 'content': task},
    ],
)
note = plan.choices[0].message.content
print(plan.choices[0].finish_reason, plan.usage.completion_tokens)

If finish_reason is length, the note was cut off by the cap: raise max_tokens a little or shorten the schema (what that error looks like). Model id and base URL are in the CheapTokens docs.

A handoff note as JSON, and the finish_reason that shows it was cut off
The structured handoff note and the finish_reason value that signals a cut-off note.

2. Pass each agent only what it needs#

If the reviewer checks the code against the task, it does not need the plan: the task and the code are enough. If it also checks the code against the plan, keep the plan. Cutting the plan out of its context is a one-line change in your orchestrator:

Compare

What the reviewer reads

Before: everything

Task 1,000 + plan 1,500 + code 3,000 = 5,500 tokens in.

After: task and code

Task 1,000 + code 3,000 = 4,000 tokens in.

With both changes (and the 400-token note, which is our assumption), the example chain becomes planner 1,000 in and 400 out, coder 1,000 + 400 = 1,400 in and 3,000 out, reviewer 1,000 + 3,000 = 4,000 in and 800 out. That is 1,000 + 1,400 + 4,000 = 6,400 tokens in and 400 + 3,000 + 800 = 4,200 out, against 9,000 and 5,300 before. Same 100 tasks a day:

Model Per request 100 requests OpenRouter, 100 requests
GLM-5.3-Flash $0.0003 $0.0296 $0.0583
DeepSeek-V4-Flash $0.00052 $0.0516 $0.0963
MiniMax-M2.7 $0.00095 $0.095 $0.696

6,400 input and 4,200 output tokens per request. Prices per 1M tokens are current and change together with our tariffs; the OpenRouter column shows reference prices for the same workload.

For one task on MiniMax-M2.7 the trimmed chain is $0.00095, down from $0.0012.

3. Give short roles a cheap model#

The planner writes short answers, so start there: try GLM-5.3-Flash (390K context, up to 8,192 output tokens per answer) and compare the result on 10–20 of your own tasks. The coder writes the longest answers: DeepSeek-V4-Flash allows up to 32,768 output tokens per answer. Since every model sits on one balance with one price at any hour, mixing them in one chain needs only a different model string per agent. Current prices for both are in the pricing table and on the DeepSeek page.

Why not just pass the KV cache?#

The paper SwaT (arXiv:2610.15095), submitted on 10 October 2026 by Alabdulkareem, Tenison, Zhang, Zhu, Katz and Gutfreund, proposes exactly that: agents hand each other KV-cache state instead of text, so the receiver skips reading the text again. According to the abstract page (read on 31 October 2026), the authors report 40% higher mean accuracy (with KV-cache compaction) than text-to-text communication and 4x faster mean wall-clock time across 17 benchmarks, 12 LLMs and 6 model families. The 40% is accuracy, not a saving on tokens or price.

A research method like this needs access to the model's internal cache. A chat-completions request takes text in and gives text out, so with an API your lever is the text: the three changes above.

Before you scale to hundreds of runs#

Checklist

Handoff checklist

For the bigger picture of agent budgets, see how to estimate the cost of an AI agent and why agents use so many tokens.