mksglu/context-mode · 17 Oct 2026 · Feature

The Context Problem Has an Output Side, and Someone Finally Built for It

Camille Laurent
Camille Laurent
Contributing Editor

Context Mode routes an agent's raw tool output through sandboxes and a SQLite search index instead of the model's context window — and in doing so exposes how uneven the hook landscape across coding agents really is.

mksglu/context-mode
★30.2k stars Velocity · 7d +611 ★/day ↗accelerating
star history

Every few months, the coding-agent world rediscovers that context windows are finite. Anthropic wrote the canonical framing in late 2025: context is a resource with an attention budget, models degrade as the window fills — the phenomenon the industry calls context rot — and good engineering means finding “the smallest possible set of high-signal tokens.” Everyone nods. Then a Playwright snapshot dumps 56 KB of accessibility tree into the conversation and the budget is gone by lunch.

mksglu/context-mode

The tooling response to this has been strangely lopsided. Cloudflare’s Code Mode compressed tool definitions — the schemas and descriptions that eat the window before you’ve typed a word. The project’s own origin story is blunt about the gap: with 81+ tools active, 143K tokens are consumed before your first message, and “nobody was solving the output side.” Context Mode, an MCP server by Mert Köseoğlu, is an attempt to be the other half: it intercepts what tools return and keeps most of it out of the model’s face.

The idea, stripped down

The core move is almost embarrassingly simple, which is usually a sign it’s the right one. When an agent needs to process something large — a log file, an API response, a scraped page, twenty GitHub issues — Context Mode runs that work in an isolated subprocess and lets only the script’s stdout enter the conversation. The raw data never crosses the boundary. A 56 KB Playwright snapshot becomes 299 bytes of whatever the script chose to print. Over a full session, the project claims 315 KB of raw output compresses to 5.4 KB.

The philosophical framing is more interesting than the mechanism. Context Mode’s pitch is that the LLM should program the analysis, not compute it. Instead of reading fifty files into context to count functions, the agent writes a script that does the counting and logs the result. One script replaces ten tool calls. This inverts the usual relationship: the model stops being a data processor and becomes a code generator whose output happens to be the answer. It’s the same insight that made notebooks beat manual calculation, applied to agents.

The second half of the architecture is where the boring, load-bearing work lives: a SQLite knowledge base. Content that the agent will need to consult repeatedly — fetched documentation, indexed files, session history — gets chunked by headings, stored in an FTS5 virtual table, and retrieved on demand via BM25 search with Porter stemming. Search runs two strategies in parallel (stemmed matching and trigram substring matching) and merges them with Reciprocal Rank Fusion, then reranks multi-term queries by term proximity and corrects typos via Levenshtein distance before re-searching. None of this involves a model call — the author confirmed on Hacker News that it’s “purely deterministic text processing.” That matters both for cost and for trust: the compression is auditable in a way an LLM summarizer’s isn’t.

Session continuity, or: what compaction destroys

The more ambitious feature is session continuity, and it addresses a real wound. When a context window fills, agents compact — dropping older messages to make room — and in doing so routinely forget which files were being edited, what was in progress, and what the user last asked. Context Mode hooks every tool call, user prompt, git operation, and error into a per-project SQLite database, then when compaction fires, builds a priority-tiered snapshot (capped around 2 KB) that gets re-injected at session start. Critical state — active files, tasks, user decisions — survives; low-priority telemetry gets dropped first. Detailed event history goes into FTS5 so the model can search its own past rather than having it dumped back into context.

It’s a genuinely clever design: instead of fighting compaction, it treats the context window as a cache with a database behind it. Whether the 2 KB snapshot budget is enough for genuinely tangled sessions is an open question the sources don’t answer.

Sixteen platforms, one glue layer

Here’s the part that will either impress or exhaust you, depending on your temperament. Context Mode supports sixteen agent platforms — Claude Code, Codex CLI, Gemini CLI, Cursor, VS Code and JetBrains Copilot, OpenCode, KiloCode, Qwen, Kimi, Zed, Kiro, Antigravity, Pi, OMP, OpenClaw — and the README is essentially a field guide to how incoherent the hook landscape is. Claude Code has a full five-hook lifecycle. Codex gates hooks behind feature flags and can’t rewrite tool input yet. Cursor documents a sessionStart hook but its validator rejects it. OpenCode lacks SessionStart entirely, so Context Mode abuses an experimental.chat.system.transform hook as a surrogate. Zed and Antigravity have no hooks at all and fall back to instruction files with roughly 60 percent routing compliance versus ~98 percent with hooks.

To be clear about what this is: a large fraction of the codebase is adapter glue, and the project doesn’t pretend otherwise. But the glue is the product here. The interesting artifact Context Mode has produced isn’t the sandbox — it’s the compatibility matrix, which reads like a bug report against the entire agent ecosystem. When one project has to write a different integration path for sixteen runtimes to do the same four things, the problem isn’t the project.

The hype, and the parts that deserve squinting at

The project has had its moment: the README wears a Hacker News #1 badge claiming 570+ points, and the visible Show HN thread — a separate, earlier submission — drew 84 points and a substantive discussion. The trajectory is real; the exact arithmetic between the two submissions is unclear from the sources.

Some skepticism is warranted, and the HN thread supplies it honestly. One user reported that the routing hooks didn’t trigger reliably — the agent kept reaching for plain WebFetch instead of the sandboxed path, which is precisely the anti-pattern the tool exists to prevent. The author traced it to a known bug fixed in v0.7.1. That’s a fixed bug, but it points at the structural fragility of the whole approach: a system whose value depends on the model choosing the right tool, or on hooks intercepting it, will occasionally fail at both, and one unrouted 56 KB fetch can wipe out a session’s savings.

The benchmarks, meanwhile, are self-reported and suspiciously tidy — every scenario lands between 94 and 100 percent saved. The methodology isn’t published in the sources, and the numbers deserve independent replication before anyone budgets around them.

Two more things worth flagging. The README’s “used across teams at” logo wall — Microsoft, Google, Meta, Amazon, and thirteen others — links to nothing (every badge href is a bare anchor). There’s no verification anywhere in the sources that any team at these companies uses it. And the license has moved: the launch blog post from February 2026 says MIT; the current README says Elastic License 2.0, chosen explicitly to prevent repackaging as a competing closed-source SaaS. A license change mid-flight is a project’s prerogative, but it’s also the kind of thing early adopters notice.

There’s also a commercial sibling. context-mode.com markets a hosted-flavored product — “1,000 requests free,” a control plane with memory, skills, and a command-blocking “Cage” — that goes well beyond the open-source repo. The site’s own benchmarks claim 65.5 percent lower cost on a long Opus session. The relationship between the repo and the company isn’t spelled out in the sources, and the tension between “nothing leaves your machine” in the README and a metered cloud offering is unresolved.

Where this sits in the field

The broader context-optimization literature — DataHub’s survey is a fair representative — catalogs chunking, RAG, ranking, and compaction as the standard playbook. Context Mode is essentially that playbook, relocated from the application layer to the agent-runtime layer, and enforced with hooks rather than prompt suggestions. Its refusal to dictate prose style is a notably restrained design choice: the README cites evidence that aggressive brevity prompts degrade reasoning benchmarks, so the routing block governs where data goes, not how the model talks. That discipline is rarer than it should be in this genre.

The open questions are the ones that always follow this pattern. Does deterministic BM25 retrieval actually surface what the model needs, or does it occasionally return the legally-relevant-but-wrong snippet? Can hook-based routing stay reliable as platforms churn their hook APIs — the README already documents breakage on Cursor, Codex, and OpenCode? And will the platforms themselves absorb this? Claude Code, Codex, and friends are all racing to add native context management; a first-party compaction-and-retrieval feature would flatten a lot of Context Mode’s value proposition overnight.

Until then, it’s the most complete answer anyone has shipped to the output side of the context problem — deterministic, local, and honest about the fact that most of its code is glue because the ecosystem forced it to be.

Sources

  1. I built a context window optimization framework for coding ...
  2. Must-Have MCP Servers for Coding and Beyond : r/ClaudeAI
  3. Context Mode: The Control Plane for Coding Agents
  4. Effective context engineering for AI agents
  5. 5 Essential MCP Servers Every Developer Should Know
  6. Show HN: Context Mode – 315 KB of MCP output becomes ...
  7. Context Window Optimization Strategies | DataHub
  8. MCP vs Skills: Understanding AI Coding Assistant Integrations ...
  9. Anyone using the Context-mode extension? Any thoughts ...
  10. How we solved Context Management in Agents
  11. What MCPs are you using with your AI coding agents right now?
  12. Stop Burning Your Context Window — We Built Context Mode

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.