Mahal Systems

Overview › 2Tools › c.Trimming results › i.

Bound tool output: cap it, or write it to a file the agent can read

Tool surfaceContext General

Also fits: 5Context › b.Filtering input

Cap the characters of tool output kept per call (VeRO settled near 15-20 KB on TerminalBench), or, better, write long output to a file and return its path with a short head, so the agent can read more if it needs to. When the agent runs code, filter and aggregate results inside the execution environment and return only the slice it needs.

Tier 3 because it changes what the model sees.

When it applies

  • In the code: tool results passed to the model whole, with no cap or file offload
  • In traces: a single tool result over about 10% of the context window; context-overflow outcomes; a truncated result followed by re-running the same command
  • In eval results: context-overflow outcomes as a share of failures

How

  1. From traces, find the largest tool results and the share of context they take.
  2. Set a cap from the distribution of results on successful cases; or switch to file offload for that tool.
  3. Re-run cases that previously overflowed or truncated.

How to measure it

  • experiment (tier 3): paired eval at the old and new cap, or cap against file offload; count overflow failures

To compare the change against your agent's current version, with the same cases and enough repeats to see past run-to-run noise, use aot-evals.

Expected impact

  • Quality: mixed, small: a cap can drop what the agent needed; file offload avoids that (Cursor, unmeasured)
  • Cost: improves, medium: VeRO: overflow errors 13 to 1 with a lower cap
  • Performance: improves, small

Caveats

Samples 16, 17 and 47 regressed under every run; output-length changes are the usual suspect.

Evidence

Evidence comes from: Code generation, Tool use.

  1. TerminalBench-2

    30KB to 15KB (Tools-B=89), 20KB (Filesystem-B=178), 17KB (Tools-B=178, after probing 15KB on 16 samples and seeing some tasks needed more). Filesystem run cut ContextLengthExceeded from 13 to 1.

    Scale AI, "VeRO: A Harness for Agents to Optimize Agents" (ICML 2026) · Feb 2026 · paper §A.4

  2. mixed

    MAX_TOOL_OUTPUT_CHARS lowered 16 times, raised 13. The only frequently-touched constant lowered more often than raised.

    Scale AI, VeRO code release · figure_04 (100 runs, five benchmarks)

  3. Write long tool outputs to files, don't truncateNot measured

    Truncation "can lead to data loss"; the file approach "has resulted in fewer unnecessary summarizations when reaching context limits." No number.

    Jediah Katz (Cursor), "Dynamic context discovery" · Jan 2026 · 1. Turning long tool responses into files

  4. Filter and aggregate tool results in codeNot measured

    Illustrative: a 10,000-row sheet filtered to pending orders; "The agent sees five rows instead of 10,000." Not measured.

    Adam Jones, Conor Kelly (Anthropic), "Code execution with MCP: Building more efficient agents" · Nov 2025 · Benefits: Context efficient tool results

  5. Pass data between tools in code, not contextNot measured

    With direct calls "the full call transcript flows through twice. For a 2-hour sales meeting, that could mean processing an additional 50,000 tokens" (estimate). Also: "models may be more likely to make mistakes when copying data between tool calls."

    Adam Jones, Conor Kelly (Anthropic), "Code execution with MCP: Building more efficient agents" · Nov 2025 · Intermediate tool results consume additional tokens; Privacy-preserving operations

  6. Express loops, polling and conditionals in codeNot measured

    "more efficient than alternating between MCP tool calls and sleep commands through the agent loop" and "saves on 'time to first token' latency: rather than having to wait for a model to evaluate an if-statement".

    Adam Jones, Conor Kelly (Anthropic), "Code execution with MCP: Building more efficient agents" · Nov 2025 · Benefits: More powerful and context-efficient control flow

  7. Chain actions by writing and executing codeNot measured

    Cites CodeAct and Anthropic, "highlighting the token savings benefit because the agent does not process the intermediate tool results."

    Lance Martin, "Agent Design Patterns" · Jan 2026 · Multi-Layer Action Space

Also known as

  • Token-efficient tool responses

Related

In Claude Code

This optimization is a skill in aot-kit, our open-source Claude Code plugin: /aot-kit:bound-tool-output. Its library entry holds every source. Have new evidence, or a correction? Suggest a change.

Before you go...

Build better agents, weekly

Our latest research, performance benchmarks, optimization strategies, and updates around AOT development.

One email a week, nothing else. Unsubscribe anytime.