Return by Reference: Bounding Tool-Output Context Cost in LLM Agents with Capability URLs
LLM agents increasingly invoke tools that produce large or binary outputs — figures, PDFs,data files. Tool results commonly return these inline as base64 — the default afforded by thecontent model of protocols like the Model Context Protocol (MCP) — which permanently inflatesthe agent’s context. We measure this cost: base64-encoded binary consumes ∼920 tokens perKB under a representative BPE tokenizer, so a single 30 KB figure costs ∼27,000 tokens, and atwelve-figure session costs ∼332,000 tokens — enough to overflow a 200K context window onits own. We describe a preventive alternative: return the output by reference — a URI plusfixed-size metadata (size, MIME type, integrity hash) — and fetch the bytes on demand onlywhen needed. The URI’s scheme selects the delivery mechanism; our measured instantiationis a short-lived HTTPS capability URL. This realizes the decades-old Claim Check integrationpattern — the claim check is a URI — and yields Bounded Output Context Cost: thecontext cost of a tool output is O(1) in its payload size (∼90–100 tokens, measured, independentof file size), a 301× reduction for a typical figure. We give a hardened reference implementationwith an MCP-specific security analysis, extend the pattern to tool arguments — where inlinefiles are worse still, because the model must generate the bytes — and position the approach ascomplementary to observation masking and summarization, which act reactively and lossily afteroutputs enter context, and to the MCP File Uploads Working Group’s concurrent draft extension,which adopts the same out-of-band design. Reference implementation and measurement harnessare open source.
Authors
- Peter Lemenkov (ORCID: https://orcid.org/0009-0008-2573-4971)
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-11-23
- DOI
- https://doi.org/10.5281/zenodo.24477584
- Primary Topic
- Topic Modeling
- Type
- preprint