Why
- An MCP server tool call may return a large amount of data, which can quickly fill the available context window.
- The agent may not be able to control how much data an MCP server returns in a tool response by modifying the tool arguments alone. For example, fetching a single pull request can still return a very large
descriptionfield.
How it works
Configuration
TrueFoundry Agent Harness applies offloading automatically — no setup required. Two complementary thresholds govern when tool responses are written to the sandbox instead of staying in context. Single tool response that’s too large If an individual tool response exceeds the per-call threshold, the full result is written to a file in the sandbox and replaced in context with a short preview plus the file path:
Subagents have a higher threshold because they run in isolated context, so a single larger payload is less likely to crowd out their working memory.
Parallel tool calls returning together
When the agent fires several tool calls in parallel and their responses come back together, no single response may be over the per-call threshold but their combined size can still flood the context window. In this case the harness offloads responses one at a time — starting with the largest — until the combined tool-call content drops below 6,000 tokens. The smallest responses stay inline and the largest end up on disk.
In every case the offloaded content remains accessible — the agent can read or
grep the saved file from the sandbox whenever it needs the original data.
Large tool response handling is off by default and must be enabled per agent via
config.context_management.large_tool_response.enabled: true. Once enabled, the thresholds above (individual_tool_response_token_threshold, total_tool_response_token_threshold, and preview_number_of_characters) are configurable. See config.context_management.large_tool_response for the full field reference.Example
User
Can you please list the mcp servers I have access to
Assistant
Let me get more information about the user.
get_me
get_me
Tool CallTool Response
Assistant
Let me list the MCP servers you have access to.
list_mcp_servers
list_mcp_servers
Tool CallTool Response (blocked) — Full result saved to
/tmp/tool-id-xyz-outputAssistant
Let me get a preview of the data and print the schema.
sandbox
sandbox
Tool CallTool Response
Assistant
Now I understand the schema of the MCP servers output file. Let me write code to parse the MCP server names.
sandbox
sandbox
Tool CallTool Response
Assistant
Hey John, here are the MCP servers you have access to:
- test-realtime-global
- slack-mcp
- google-calendar-mcp
- …