Agent context stops drowning in raw tool output: a sandbox turns 315 KB into 5.4 KB, and sessions resume after compaction
Synopsis
Every MCP tool call dumps raw data into an AI agent's context window, and a single Playwright snapshot costs 56 KB; when the conversation compacts, the agent forgets which files it was editing and what tasks are in progress. context-mode, an MCP server, keeps that raw data in a sandbox and returns only results, while recording file edits, git operations, tasks and errors in SQLite for retrieval after compaction. Its stated comparison is 315 KB reduced to 5.4 KB, about a 98% cut.
Interpretation
An AI agent's context window is no longer filled directly by raw tool output; raw data is processed inside a sandbox and only results enter the conversation. Previously each MCP tool call wrote raw data into context wholesale: a Playwright snapshot 56 KB, twenty GitHub issues 59 KB, one access log 45 KB, leaving 40% of context gone after 30 minutes. The stated comparison is 315 KB of raw data becoming 5.4 KB after sandbox processing, about a 98% reduction.
After the conversation compacts, the agent can still recover which files it edited, which tasks are in progress, and what the user last asked for. Compaction previously only freed space and lost this state; context-mode does not dump the record back into context but indexes events into FTS5 and retrieves only relevant parts via BM25 search. File edits, git operations, tasks, errors and user decisions are tracked in SQLite; without --continue, previous session data is deleted immediately, so a fresh session starts clean.
The agent is directed to write scripts that perform the analysis rather than reading data into context and computing it there. Counting functions across 50 files previously meant reading each file into context; now the agent writes a script, runs it, and prints only the result. The stated comparison is 47 Read() calls at about 700 KB versus one ctx_execute() at 3.6 KB; the approach is a mandatory paradigm across 17 supported clients, plus OpenClaw gateway integration.
Perspective
Intended for developers and operators of AI agents that use MCP tools, covering 17 supported clients such as Claude Code plus OpenClaw gateway integration. Hook-capable platforms enforce routing automatically; non-hook platforms need a one-time routing file copy. The material proposes no follow-up validation step.
The material explicitly does not dictate how the model writes its final answer; brevity is left to the model or the user's own configuration files, on the stated grounds that aggressive brevity prompts have been reported to degrade coding and reasoning benchmarks. Session data persists only with --continue and is otherwise deleted immediately. The figures are the project's own comparisons, with measurement conditions not described.
