Why the Engine

Context Mode Engine: keep tool output out of context

One big tool output, such as a long test log, can fill much of your agent's context window in one step. Context Mode Engine is a free plugin for coding agents. It sends large tool output, such as a test log, a web page or a git log, to a local sandbox and index. Your agent reads a short reply, and your context window keeps its room for your work.

Free · Local · Private · Forever

Context Mode Engine is source-available under the Elastic License 2.0. Free to use, for all time. It runs on your machine and keeps your data in ~/.context-mode.

Is it free, and does my data leave my machine?

Free: yes. You use the Engine at zero cost. The Elastic License 2.0 has an open end date. It ends only if you break its terms.

Your data: it stays on your machine. Your tool output, index and session log stay in ~/.context-mode. Your usage data stays on your machine, and only your agent talks to a model. It uses the network only to install or update, to check for a new version, and to fetch a URL when your agent asks to index one.

Key facts

What it is
A plugin with the package and command context-mode. It keeps large tool output in a local sandbox and a SQLite FTS5 index (FTS5 is SQLite full-text search), and gives the agent a short reply.
Who it is for
Anyone who runs a coding agent and wants more room in the context window.
Agents
Claude Code, Codex, Gemini CLI, Qwen Code, Copilot CLI, VS Code, Kiro, ZCode, OpenCode, Pi and OMP.
Measured result
A median of 98.8% of output bytes stayed out of the context, over the tool outputs of 10 KB or more in the 2026-10-31 benchmark (raw file).
Scope
Works on tool output, on your machine. Needs Node 24.15.0 or later.

The problem: big tool output fills the context

You ask your agent to run the tests, read a web page or check the git log. The tool prints hundreds of kilobytes, and all of it lands in the context window. After a few calls like this, the window is full of old output, and your agent has a smaller part of it for the task you gave it.

What the Engine does

The Engine sits inside your agent through hooks. When a tool call makes large output, the Engine sends that output to a sandbox and an index on your machine. Your agent gets a short reply with the part it needs and a hint to search for the rest.

  1. A test log, a web page or a git log comes back from a tool.
  2. The Engine keeps the full output in a local SQLite FTS5 index.
  3. Your agent reads a short reply, and finds more with ctx_search when it needs it.

Everything runs on your machine, with your own runtimes, at zero cost.

Code Mode: write code, read the answer

Code Mode is the rule: your agent writes a short script instead of reading raw output. The script runs in the sandbox, and only what it prints enters the chat. Pick a job to see both ways.

Try it

Pick a job

Fetch https://jsonplaceholder.typicode.com/photos. Which photo has the longest title (give its id and title), and how many photos have a title that contains the word "est"?

Read it1,039,898 B, about 259,975 tokens
Write code393 B, about 98 tokens
⏺ context-mode - ctx_execute (MCP)(language: "javascript",
code: "const res = await fetch("https://jsonplaceholder.typicode.com/photos");
if (!res.ok) throw new Error("HTTP " + res.status);
const photos = await res.json();
let longest = null;
for (const p of photos) {
  if (!longest || p.title.length > longest.title.length) longest = p;
}
const withEst = photos.filter(p => p.title.includes("est")).length;
const ties = photos.filter(p => p.title.length === longest.title.length).map(p => p.id);
console.log(JSON.stringify({ total: photos.length, longest: { id: longest.id, title: longest.title,…
intent: "longest photo title and count of titles containing \"est\"")
  ⎿  exit 0 · 239 B
     {
       "total": 5000,
       "longest": {
         "id": 653,
         "title": "temporibus commodi et fugit doloremque reprehenderit exercitationem necessitatibus au…
         "length": 86
       },
       "longestTieIds": [
         653
       ],
       "titlesContainingEst": 892
     … +1 lines
     239 B produced, 254 B returned

⏺ context-mode - ctx_execute (MCP)(language: "javascript",
code: "const photos = await (await fetch("https://jsonplaceholder.typicode.com/photos")).json();
const wholeWord = photos.filter(p => /\best\b/.test(p.title)).length;
console.log(JSON.stringify({ wholeWordEst: wholeWord, substringEst: photos.filter(p => p.title.incl…
intent: "count titles with \"est\" as a whole word vs substring")
  ⎿  exit 0 · 40 B
     {"wholeWordEst":597,"substringEst":892}
     40 B produced, 54 B returned

99.96% of the bytes stay out of the chat. One live run on 2026-11-02: Claude Code 2.1.312, claude-haiku-5-5, Context Mode 2.0.0-next.26. Produced: what the code printed in the sandbox. Returned: what the agent read. Data and the stream it copies

Here is a Linux syslog sample: https://raw.githubusercontent.com/logpai/loghub/master/Linux/Linux_2k.log. How many authentication failures does it contain, and which 3 remote hosts caused the most?

Read it216,485 B, about 54,121 tokens
Write code566 B, about 142 tokens
⏺ context-mode - ctx_execute (MCP)(language: "shell",
code: "d=$(mktemp -d) && cd \"$d\" && curl -sSfL -o Linux_2k.log https://raw.githubusercontent.com/…
intent: "authentication failure counts and top rhost values")
  ⎿  exit 0 · 273 B
     lines:     1999
     auth failure lines: 490
     --- failure lines with non-empty rhost, top 3 ---
       80 rhost=150.183.249.110
       23 rhost=n219076184117.netvigator.com
       23 rhost=207.243.167.114
     --- distinct rhosts among failures ---
           48
     --- failure lines with empty rhost ---
     1
     273 B produced, 288 B returned

⏺ context-mode - ctx_execute (MCP)(language: "shell",
code: "cd \"$(ls -td /tmp/tmp.* 2>/dev/null | head -1)\" 2>/dev/null || cd \"$TMPDIR\"; f=$(ls -t *…
  ⎿  exit 0 · 0 B
     0 B produced, 14 B returned

⏺ context-mode - ctx_execute (MCP)(language: "shell",
code: "d=$(mktemp -d) && cd \"$d\" && curl -sSfL -o Linux_2k.log https://raw.githubusercontent.com/…
  ⎿    80 rhost=150.183.249.110
       23 rhost=n219076184117.netvigator.com
       23 rhost=207.243.167.114
       20 rhost=60.30.224.116
       15 rhost=195.129.24.210
       14 rhost=218.188.2.4
     168 B produced, 168 B returned

99.7% of the bytes stay out of the chat. One live run on 2026-11-02: Claude Code 2.1.312, claude-haiku-5-5, Context Mode 2.0.0-next.26. Produced: what the code printed in the sandbox. Returned: what the agent read. Data and the stream it copies

What are the top 10 stories on the Hacker News front page right now? Give title, points and domain for each.

Read it35,087 B, about 8,772 tokens
Write code1,501 B, about 375 tokens
⏺ context-mode - ctx_execute (MCP)(language: "python",
code: "import subprocess, re, html
out = subprocess.run(["curl","-sL","--max-time","30","https://news.ycombinator.com/"],capture_outpu…
rows = re.findall(r'<tr class="athing[^"]*" id="(\d+)">.*?<span class="titleline"><a href="([^"]+)"…
scores = dict(re.findall(r'<span class="score" id="score_(\d+)"[^>]*>(\d+) points?</span>', out))
for i,(id_,href,title,dom) in enumerate(rows[:10],1):
    print(f"{i}. {html.unescape(re.sub('<[^>]+>','',title))} | points: {scores.get(id_,'?')} | doma…
print("rows found:", len(rows))")
  ⎿  1. Show HN: Wikihack – HackerTube, but for Wikipedia articles mentioned on HN | points: 93 | domain…
     2. Show HN: HackerBooks – HackerTube, but for books mentioned on HN | points: 1305 | domain: hacker…
     3. Postgres 19 is late because so many more bugs are being found now | points: 348 | domain: rhaas.…
     4. F/OSS Comics #13: BSD Unix, Part 3 – The Beginning of BSD Unix | points: 100 | domain: fosscomic…
     5. HackerTube: YouTube built from videos recommended by HN | points: 2512 | domain: karpathy.bearbl…
     6. Ask HN: Which TV do you recommend for privacy? | points: 329 | domain: none (HN internal)
     7. Mystery of 60-Second Fluctuations in Power Grids Solved | points: 103 | domain: fz-juelich.de
     8. Bones may release proteins that slow aging and extend life span | points: 51 | domain: science.o…
     9. Trigger.dev customer environment variables exposed | points: 73 | domain: trigger.dev
     10. Nibnib: Image compression with extreme decompression speed | points: 135 | domain: github.com/r…
     rows found: 28
     1,064 B produced, 1,064 B returned

95.7% of the bytes stay out of the chat. One live run on 2026-11-02: Claude Code 2.1.312, claude-haiku-5-5, Context Mode 2.0.0-next.26. Produced: what the code printed in the sandbox. Returned: what the agent read. Data and the stream it copies

Which of the last 300 vitejs/vite commits fix the server, and which are v8.3 releases?

Read it318,426 B, about 79,607 tokens
Write code11,688 B, about 2,922 tokens
⏺ context-mode - ctx_batch (MCP)(commands: ["git shortlog -sn -300 HEAD","git log --stat --format='commit %h %an: %s' -300"],
queries: ["fix(server)","release: v8.3"])
  ⎿  ## fix(server)
      docs/guide/troubleshooting.md | 14 ++++++++++++++
      1 file changed, 14 insertions(+)
     commit 6894f5c kingmaker: fix(server): handle file watcher errors without crashing (#23503)
      packages/vite/CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++
      packages/vite/package.json |  2 +-
      2 files changed, 33 insertions(+), 1 deletion(-)
     commit b28db28 owenn: fix(server): match static aliases on path boundaries (#23643)
      packages/vite/CHANGELOG.md | 8 ++++++++
      packages/vite/package.json | 2 +-
      2 files changed, 9 insertions(+), 1 deletion(-)
     commit c3e06f9 翠: fix(server): store ids to `safeModulePaths` rather than URLs (#23656)
     … +174 lines
     318,426 B produced, 11,688 B returned

96.3% of the bytes stay out of the chat. One live run on 2026-11-03: Node MCP client (batch-call.mjs) v26.8.1 over MCP, drawn as Claude Code prints an MCP call, Context Mode 2.0.0-next.34. Produced: what the code printed in the sandbox. Returned: what the agent read. Data and the stream it copies

Read it: the whole output goes into the chat. Write code: the output stays in the sandbox, and the chat gets the answer.

What you get

Your context window keeps its room for your work. Across the tool outputs of 10 KB or more, the Engine kept a median of 98.8% of the bytes out of the context. We measured bytes per tool output, median of 5 runs, on an M1 Pro with Node 26.8.1 (raw file, source on GitHub).

One example: a browser snapshot of 133.3 KB became a 0.5 KB reply. Same method, median of 5 runs (raw file, source on GitHub). Move the slider to see more tool outputs.

Tool outputRaw outputEntered the contextSaved
Commit history, 300 commits160.5 KB0.3 KB99.8%
Browser snapshot133.3 KB0.5 KB99.6%
Test run, 1106 tests61.4 KB0.4 KB99.3%
Library docs6.8 KB0.5 KB92.6%
Bytes per tool output, median of 5 runs, Apple M1 Pro, Node 26.8.1, 2026-11-01. Saved = 1 - entered / raw. Raw file.

Your path through these docs

Each page takes one step. Start with the install, then follow the story.

  1. Install: run your agent's own install command, then check with context-mode doctor.
  2. First session: see the bytes kept out of context with ctx_stats.
  3. How it works: hooks, sandbox and index, step by step.
  4. Sandbox: run code, and only what it prints reaches the model.
  5. Search: find any output again with ctx_search.
  6. Long sessions: keep your place after compaction.
  7. Security: your agent permissions stay in charge.
  8. Privacy: your data stays on your machine.
  9. Agents: how each of the eleven agents connects.
  10. Tools: a reference for the nine ctx tools.
  11. Doctor: check and repair your setup.
  12. Benchmarks: rerun the numbers on your machine.
  13. Engine and Gateway: how the two fit together.
  14. For AI agents: a short brief, plus prompts.

Prompts to give your agent

Paste one into your agent. Each prompt shows in full.

Prompt
Install Context Mode Engine for this agent. Use the agent's own install command from https://github.com/mksglu/context-mode/blob/main/docs/install/README.md, then run `context-mode doctor` and show me the result.

Get started free

Context Mode Gateway: your coding agent costs less and remembers your project. Context Mode Engine installs from your terminal.

After you sign in, the console gives you one command to connect your coding agent.

Read the docs