Agent runtime

Tool Result Clearing

Dropping a tool's response from the agent's context window after the agent has used it — to keep the context lean across long multi-tool workflows.

Operating principle

Production AI is not a prompt. It is a system of context, tools, permissions, traces, evals, and feedback loops.

What it is

Tool result clearing is a compaction strategy specific to tool-heavy agent workflows. After the agent has read a tool's response and acted on it, the raw response is removed from the conversation history and replaced with a short note ('called tool X, used the result to do Y'). The context stays lean even after dozens of tool calls.

Why it matters

Tool results — search results, file contents, API responses — are the largest single contributor to context-window bloat in agent workflows. A workflow that calls 20 tools and keeps all their raw responses in context will exceed any reasonable budget. Clearing the results after use is the cheapest way to keep long workflows feasible.

How it works

After a tool call completes and the agent has incorporated the result, the runtime rewrites the message history to summarize the call. The summary preserves the fact that the tool was called and what the agent concluded; it drops the verbose payload. Done correctly, the agent doesn't notice; done poorly, the agent loses critical context and asks for the same thing again.

Related resources