Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Capping tool output at the wrapper keeps a single tool call from torching the context budget and triggering lost-in-the-middle, and the wrapper has structured-format knowledge the model lacks.
Picture a research assistant who can fetch books from a library for you, and your desk only fits five books at a time. If the assistant dumps every book they can find onto the desk, half of them slide off and the ones underneath are buried. A good assistant skims each book first, hands you the relevant chapter, and writes the rest of the title on a sticky note so you can ask for more if you need it. The tool wrapper is that assistant. The model is you at the desk. Without a cap at the wrapper, one tool call can bury everything else on the desk, including the question you were trying to answer. With a cap, the desk stays usable and the agent can ask for more on demand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
State the problem: tool outputs can be huge and the model cannot skim. Connect to lost-in-the-middle and context-budget consumption. Name three capping strategies (hard truncate, top-N relevance extraction, summarize then return) and when each is appropriate. Explain why the wrapper has better information than the model for choosing what to cut: it knows the source format. Close with how capping composes with lazy retrieval and pagination tools, plus the rule that the wrapper must always tell the model when it cut.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating tool outputs as raw passthroughs and assuming the model will handle truncation on its own, when in fact the model sees the entire blob and burns budget over it.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.