A single browser snapshot can cost your AI coding agent 56 KB of context. Twenty GitHub issues can consume another 59 KB. The agent hasn't written a line of code, yet its working memory is already filling with raw data.
Then comes compaction: the conversation is compressed to make room, and important details about earlier decisions or unfinished work can get lost.
Context Mode tackles both problems. The source-available MCP server recently reached #1 on GitHub Trending on October 17, 2026, and its repository now shows roughly 30,900 stars. Its premise is simple: stop feeding the model everything, and give it a way to retrieve what matters. Project repository
Four ways agents waste context
Context Mode identifies four related problems:
- Raw tool output. Browser snapshots, logs, API responses, and file reads can fill the context window with data the model doesn't need to see in full.
- Lost working memory. When a conversation compacts, important details about the task and previous actions can disappear from the active context.
- Verbose responses. Models can spend output tokens on filler and repetition. Context Mode explicitly doesn't try to control this.
- The wrong kind of work. Models often read large amounts of data to perform simple calculations that a short script could handle.
The first two are the main targets. The third is an explicit non-goal, while the fourth motivates the project's most interesting technique: think in code.
Think in code, not tool calls
Suppose you want to count lines in every TypeScript file under src/. A typical agent might repeatedly read files and count their contents. The raw source consumes context even though the final answer is only a list of filenames and numbers.
Context Mode offers ctx_execute, which runs code in a separate process and returns its standard output to the model. Instead of reading every file into the conversation, the agent can calculate the answer locally:
ctx_execute("javascript", `
const files = fs.readdirSync('src').filter(f => f.endsWith('.ts'));
files.forEach(f =>
console.log(
f + ': ' +
fs.readFileSync('src/' + f, 'utf8').split('\\n').length +
' lines'
)
);
`);
The result is a compact list instead of the full contents of every file.
The project's README gives a larger example: 47 file-reading calls consuming 700 KB become one ctx_execute call returning 3.6 KB. Its benchmark table also reports reducing a 56.2 KB Playwright snapshot to 299 bytes. These are project-reported results, not guarantees for every repository or task.
Context Mode supports 12 execution runtimes, including JavaScript, TypeScript, Python, Shell, Go, Rust, and Ruby. The important idea isn't the language count; it's separating computation from the information the model needs to reason about.
Memory that survives compaction
Context Mode also maintains session information in SQLite, using FTS5 full-text search and BM25 ranking to retrieve relevant records.
Rather than stuffing an entire conversation back into the context window, it can record events from a coding session and retrieve relevant information later. Its hooks support this process around compaction and session startup: a snapshot helps preserve working state, and the next session can restore relevant context.
This isn't an unlimited memory or a guarantee that the model will never forget something. Retrieval depends on what was recorded and what can be found. But it offers an alternative to repeatedly injecting large amounts of history into every prompt.
The project supports 17 coding-agent platforms through different combinations of MCP integration, hooks, and plugins. Not every platform receives identical functionality.
Try it in about a minute
The simplest complete setup is the Claude Code plugin. Check that Claude Code is installed and that your version meets the project's stated minimum:
claude --version
Inside Claude Code, install the plugin:
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode
Restart Claude Code, or run /reload-plugins if available.
Then run the diagnostic:
/context-mode:ctx-doctor
The doctor checks the installation, execution runtimes, hooks, and SQLite/FTS5 support. Resolve any reported failures before assuming automatic routing works.
To inspect the savings during a coding session, run:
/context-mode:ctx-stats
You'll get usage and context-saving statistics for the current session.
Prefer a smaller trial? You can register the MCP server directly from your terminal:
claude mcp add context-mode -- npx -y context-mode
This provides the MCP tools without the full plugin's automatic routing hooks. The agent can use the tools, but it won't receive the same automatic guidance to route large outputs through them. See the installation instructions for the current platform-specific setup.
What it fixes—and what it doesn't
Context Mode's appeal is that it tackles a practical constraint in agentic coding: tool results can consume far more context than the useful answer they contain. Its sandboxed execution, searchable session history, and routing hooks attempt to keep that overhead under control.
There are caveats. Context savings depend on the workload and how consistently an agent uses the provided tools. A short output can still be wrong, and a small result doesn't guarantee that the model retained the right information. Review the actual output and measure your own sessions instead of assuming the README's benchmark applies to your project.
The word sandbox also deserves care: a separate process isn't automatically a hardened security boundary. Don't execute untrusted code just because the project calls its execution environment a sandbox, and don't send sensitive information into the model's context unnecessarily.
Finally, Context Mode doesn't dictate how concise or verbose the model's answers should be. It changes where data is processed and retrieved, not the writing style of the final response.
That distinction is the interesting part. Making context windows larger is one response to agent amnesia. Making agents more selective about what enters those windows is another—and Context Mode is a practical implementation worth testing.
Top comments (0)