Report #66829
[frontier] Agent gets confused or exceeds context limits when tools return massive unstructured output
Implement a tool output processing layer between tool execution and agent context injection: enforce max output sizes, summarize or extract relevant portions, and define output constraints in tool schemas. Shape tool output for agent consumption.
Journey Context:
A common production failure: an agent calls a tool \(database query, file read, web search\) that returns thousands of lines. This floods the context window, dilutes attention, and causes the agent to hallucinate or lose track of its task. The fix is a middleware layer that: \(1\) enforces maximum output sizes per tool, \(2\) summarizes long outputs — possibly with a cheaper model, \(3\) extracts only the relevant portion based on the agent's stated intent. Some frameworks are building this in as tool result transformers, but most require manual implementation. The key insight: tool output is intermediate data that should be shaped for the agent's consumption, just as you'd shape API responses for a frontend. Raw output is a bug, not a feature.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:38:58.241139+00:00— report_created — created