Skip to content
Hands-on5 min readPublished 2026-11-30Reviewed 2027-11-30

Handing off 12 times made the last call 992× larger: the Agents SDK forwards the whole history by default ​

A triage agent passes work to a research agent, which passes it to a writer, six or seven rounds back and forth. The bill grows by tens of times, and eventually the run hits a context limit. The usual diagnosis — "the model is expensive" or "the context window is too small" — is wrong. What you hand to the next agent is what costs money.

Every number below comes from openai-agents 0.26.0, Python 3.12.11 and tiktoken 0.14.0 (o200k_base), measured on 2026-11-30. The model is a scripted custom Model, so no real API call is made: there is no network jitter and no billing noise, only the question of how many tokens the next agent actually received.

The default: the new agent takes over the whole conversation ​

The handoff documentation says it plainly: "When a handoff occurs, it's as though the new agent takes over the conversation, and gets to see the entire previous conversation history." The only way to change that is an input_filter (or RunConfig.handoff_input_filter).

So a handoff does not mean "pass the conclusion". It means "pass everything". Each hop resends the history, which makes cost grow quadratically: call number k pays for all k−1 previous inputs.

Setup: 13 calls, 6 handoffs, one 5,606-token tool result ​

Three agents hand off in a cycle (triage → researcher → writer → triage). Each hop contains one function call and one handoff: the function returns a 60-row order dump as JSON, 5,606 tokens / 14,043 characters, and each agent also emits a 40–60 token note. That is 13 model calls in total — 6 handoffs plus one closing call.

Accounting: tokens of system_instructions plus tokens of the JSON-serialized input items, identical across all four groups. Tool schemas are excluded (identical in three groups; the comparison is unaffected). Serialization runs slightly larger than the real wire format, but the same way for every group.

Four policies ​

PolicyCumulative input tokensLast callLast vs. first hopVerifiable fields retained
Default (full history)256,35336,725992.6×3/3
remove_all_tools42,557 (−83.4%)1,093 (−97.0%)29.5×0/3
Hand-written note (input_items)37,438 (−85.4%)148 (−99.6%)4.0×3/3
nest_handoff_history (opt-in)341,396 (+33.2%)50,838 (+38.4%)1,374×3/3

"Verifiable fields" means whether the last input still contains the three concrete values gateway_txn, refund_no and order_id — the only basis on which a downstream agent can cite the original record.

Why it is quadratic, not linear ​

Consecutive calls differ by a stable 6,116 / 5,956 / 6,114 tokens: one tool result plus a couple of sentences per hop. So call k is roughly k × 6,100; 13 calls accumulate 256,353 and the last one costs 36,725.

Extrapolating on the same increment, call 24 would carry about 140,705 input tokens. That is no longer a cost question: a 128k-class window cannot hold it, and the chain fails at some hop — which hop depends on how large one intermediate tool result happens to be, and is hard to predict.

Three traps, all reproduced ​

One: remove_all_tools saves money and deletes the evidence. The total drops to 42,557 (−83.4%) and the last call to 1,093 (−97.0%). But it strips structured tool items and keeps only messages, so "I found two duplicate charges" survives while gateway_txn and refund_no do not: 0/3 in the last input. The downstream agent can restate the finding but cannot substantiate it. The docs also warn that it does not touch tool content already copied into ordinary messages or nested summaries.

Two: nest_handoff_history is more expensive by default. This is the counterintuitive one: 341,396 (+33.2%), last call 50,838 (+38.4%) — costlier than doing nothing. The reason is in the source: default_handoff_history_mapper does not call a model to summarize. It renders every transcript item as index. JSON inside one <CONVERSATION HISTORY> message (agents/handoffs/history.py). JSON escaping adds characters, the numbering and wrapper text are pure overhead, and lossless message items stay in place. It changes the representation; it does not shorten it. The documentation says the same thing from another angle: it "does not redact sensitive data", and tool arguments and outputs remain in the generated summary.

Three: server-managed conversations cannot use filters. With conversation_id, previous_response_id or auto_previous_response_id, handoff input filters are not supported. To keep the next agent from inheriting that history you need a separate run, and you must not reuse the original id. Also note that a per-handoff input_filter takes precedence over RunConfig.handoff_input_filter when both are set.

What belongs on the handoff note ​

Only the third policy is both cheap and evidenced: drop the raw history, forward one structured note. Total 37,438 (−85.4%), last call 148 (−99.6%), just 4.0× the first hop — it stops growing with hop count.

But the 3/3 retention is not something a flag gives you; I wrote txn_550007, R-88007 and A1234008 into the note by hand. Replace them with "research done, please continue" and retention is 0/3 immediately. A workable note has three lines: one-sentence conclusion, the verifiable IDs (transaction number, ticket number, version), and the unfinished action plus its idempotency key. The raw tool output does not belong there — keep it in your own store and pass an index instead.

Closing ​

The default handoff does not lose information; it just bills the same information once per hop. remove_all_tools and the default nest_handoff_history fail in opposite directions — one deletes the evidence, the other merely reformats it. What actually sets the cost is which fields you write down at the moment of handoff.

Your situationWhat to use
One or two handoffs, short historyShip the default; do not over-engineer
Many handoffs, downstream needs only conclusionsHand-write input_items, keep the note under three lines
Downstream must cite raw recordsKeep tool items, but forward only the matching rows
Server-managed conversationFilters unavailable; start a separate run with explicit input

OpenAIChat · Full-stack engineering for LLM-powered conversations and apps