Summary
Integrate context-mode natively into OpenHuman so that all sub-agents benefit from automatic context window protection, session continuity across compaction, and sandbox code execution - without any manual configuration by the operator. This is the same capability already built into Claude.ai and adopted across Claude Code, Gemini CLI, VS Code Copilot, Cursor, and 11 other platforms.
Background
context-mode is an open-source MCP server (mksglu/context-mode) that solves four sides of the context window problem simultaneously. It hit #1 on Hacker News with 570+ points and is in active use across teams at Microsoft, Google, Meta, Amazon, NVIDIA, Stripe, GitHub, Canva, Notion, Supabase, Cursor, and Salesforce.
The four problems it solves
| Problem |
How context-mode solves it |
Measured saving |
| Raw MCP tool dumps flood context |
Sandbox tools keep raw data out of context; only stdout enters |
315 KB → 5.4 KB (98%) |
| Session lost on compaction |
Every file edit, git op, task, error, and decision tracked in SQLite; model resumes exactly where it left off |
Full session recovery |
| LLM used as data processor |
"Think in Code" — agent writes a script, only the result enters context |
47 reads → 1 execute, 100× context saved |
| Verbose output waste |
Never enforces prose brevity — only controls where data goes, not how the model talks |
Preserves reasoning quality |
Benchmark savings
| Scenario |
Raw |
In Context |
Saved |
| Playwright snapshot |
56.2 KB |
299 B |
99% |
| GitHub Issues (20) |
58.9 KB |
1.1 KB |
98% |
| Access log (500 requests) |
45.1 KB |
155 B |
100% |
| Analytics CSV (500 rows) |
85.5 KB |
222 B |
100% |
| Repo research (subagent) |
986 KB |
62 KB |
94% |
| Full session |
315 KB |
5.4 KB |
98% |
Session time extends from ~30 minutes to ~3 hours per run.
Platform support (context-mode is already on 15 platforms - OpenHuman is not one of them)
| Platform |
Hooks |
Session continuity |
Notes |
| Claude Code |
✅ Full |
✅ Full |
Plugin marketplace, fully automatic |
| Gemini CLI |
✅ Full |
✅ High |
One config file |
| VS Code Copilot |
✅ Full |
✅ High |
SessionStart hook |
| Cursor |
✅ Partial |
⚠️ Partial |
preToolUse/postToolUse |
| OpenCode |
✅ Full |
✅ Full |
TypeScript plugin |
| Codex CLI |
✅ Full |
✅ High |
hooks.json |
| OpenHuman |
❌ None |
❌ None |
Not supported |
Problem
Every MCP tool call made by OpenHuman or a sub-agent dumps raw data into the context window. A Playwright snapshot costs 56 KB. Twenty GitHub issues cost 59 KB. After 30 minutes of a concurrent multi-agent run, 40% of the context window is gone. When the agent compacts to free space, it loses track of which files it was editing, what tasks are in progress, and what was last requested.
OpenHuman may not have sub-agent:
- Context sandboxing - no mechanism to keep raw tool output out of context
- Session continuity - no structured event tracking; compaction causes full state loss
- Sandbox code execution - no "think in code" primitive; agents process data inline, burning context from both sides
- BM25 knowledge retrieval - no indexed, searchable session knowledge base
At the scale OpenHuman operates - many concurrent agents, long-running tasks, deep tool call chains — this is a significant reliability and cost gap.
Solution
Scope: core (MCP tool registration + hook wiring) + config
Integration approach - native, not bolted-on:
Rather than asking operators to install context-mode manually as a separate MCP server, integrate it as a first-class native dependency of the OpenHuman agent runtime. When enabled, context-mode is:
- Bundled with the OpenHuman install (
npm install -g context-mode called by the installer)
- Registered automatically as an MCP server available to all agents
- Hooks wired at the agent runtime level (PreToolUse, PostToolUse, PreCompact, SessionStart) for each agent session
- Routing enforced programmatically - agents are nudged to prefer sandbox tools over raw Bash/Read/WebFetch
This mirrors how Claude Code ships context-mode as a plugin marketplace integration — one install, fully automatic, no operator configuration required.
The 11 MCP tools exposed to every agent:
| Tool |
What it does |
Context saved |
ctx_batch_execute |
Run multiple commands + search multiple queries in one call |
986 KB → 62 KB |
ctx_execute |
Run code in 12 languages; only stdout enters context |
56 KB → 299 B |
ctx_execute_file |
Process files in sandbox; raw content never enters context |
45 KB → 155 B |
ctx_index |
Chunk markdown into FTS5 with BM25 ranking |
60 KB → 40 B |
ctx_search |
Query indexed content with multiple queries in one call |
On-demand retrieval |
ctx_fetch_and_index |
Fetch URL, chunk and index; 24h TTL cache |
60 KB → 40 B |
ctx_stats |
Show context savings, call counts, session statistics |
— |
ctx_doctor |
Diagnose installation: runtimes, hooks, FTS5, versions |
— |
ctx_upgrade |
Upgrade to latest version, rebuild, reconfigure hooks |
— |
ctx_purge |
Permanently delete all indexed content |
— |
ctx_insight |
Personal analytics dashboard - 90 metrics, 37 insight patterns |
— |
Session continuity for OpenHuman and sub-agents:
Every meaningful event during an agent session is captured and persisted in SQLite:
- File reads, edits, writes
- Git operations
- Task creation, update, completion
- Errors and error resolutions
- User decisions and corrections
- QC pass/fail/retry events
When the context window compacts, the PreCompact hook builds a priority-tiered snapshot (≤2 KB). The SessionStart hook restores it. The agent continues from the last prompt with full working state - no re-prompting, no state loss.
Configuration in config.yaml:
context_mode:
enabled: true
routing: hooks # hooks (recommended) | instructions-only
max_idle_timeout_ms: 900000
per_agent: true # each agent gets its own session DB
Fallback: context_mode.enabled: false disables the integration entirely. No existing behaviour changes.
Acceptance criteria
Related
Summary
Integrate
context-modenatively into OpenHuman so that all sub-agents benefit from automatic context window protection, session continuity across compaction, and sandbox code execution - without any manual configuration by the operator. This is the same capability already built into Claude.ai and adopted across Claude Code, Gemini CLI, VS Code Copilot, Cursor, and 11 other platforms.Background
context-mode is an open-source MCP server (mksglu/context-mode) that solves four sides of the context window problem simultaneously. It hit #1 on Hacker News with 570+ points and is in active use across teams at Microsoft, Google, Meta, Amazon, NVIDIA, Stripe, GitHub, Canva, Notion, Supabase, Cursor, and Salesforce.
The four problems it solves
Benchmark savings
Session time extends from ~30 minutes to ~3 hours per run.
Platform support (context-mode is already on 15 platforms - OpenHuman is not one of them)
Problem
Every MCP tool call made by OpenHuman or a sub-agent dumps raw data into the context window. A Playwright snapshot costs 56 KB. Twenty GitHub issues cost 59 KB. After 30 minutes of a concurrent multi-agent run, 40% of the context window is gone. When the agent compacts to free space, it loses track of which files it was editing, what tasks are in progress, and what was last requested.
OpenHuman may not have sub-agent:
At the scale OpenHuman operates - many concurrent agents, long-running tasks, deep tool call chains — this is a significant reliability and cost gap.
Solution
Scope: core (MCP tool registration + hook wiring) + config
Integration approach - native, not bolted-on:
Rather than asking operators to install context-mode manually as a separate MCP server, integrate it as a first-class native dependency of the OpenHuman agent runtime. When enabled, context-mode is:
npm install -g context-modecalled by the installer)This mirrors how Claude Code ships context-mode as a plugin marketplace integration — one install, fully automatic, no operator configuration required.
The 11 MCP tools exposed to every agent:
ctx_batch_executectx_executectx_execute_filectx_indexctx_searchctx_fetch_and_indexctx_statsctx_doctorctx_upgradectx_purgectx_insightSession continuity for OpenHuman and sub-agents:
Every meaningful event during an agent session is captured and persisted in SQLite:
When the context window compacts, the PreCompact hook builds a priority-tiered snapshot (≤2 KB). The SessionStart hook restores it. The agent continues from the last prompt with full working state - no re-prompting, no state loss.
Configuration in
config.yaml:Fallback:
context_mode.enabled: falsedisables the integration entirely. No existing behaviour changes.Acceptance criteria
ctx statsin any agent session and see per-agent context savingsctx doctorreports all checks passing for the OpenHuman integrationcontext_mode.enabledandroutingmode are read fromconfig.yamlcontext_mode.enabled: falsedisables the integration with no behaviour change.github/workflows/coverage.yml)Related