Context Mode

What It Is (confidence: medium)

Context Mode (mksglu/context-mode, Elastic License 2.0) is a cross-platform context-window optimizer for AI coding agents — “the other half of the context problem.” Sandboxes tool output (claimed ~98% reduction: “315 KB becomes 5.4 KB”), persists session memory across compaction, and enforces routing across 18 platforms via MCP + hooks. Self-reported at capture: 19.5k stars, context-mode.com.

Key Points (confidence: medium)

  • Sandboxed tool output keeps raw data out of context: ctx_execute 56 KB→299 B, ctx_execute_file 45 KB→155 B, ctx_batch_execute 986 KB→62 KB, ctx_index 60 KB→40 B; benchmarks — Playwright snapshot 56.2 KB→299 B (99%), 20 GitHub issues 58.9 KB→1.1 KB (98%), 500-row CSV 85.5 KB→222 B. Claimed session extension ~30 min → ~3 hours.
  • Session continuity survives compaction: SQLite + FTS5/BM25 + priority-tiered snapshots; 5 hooks (PreToolUse, PostToolUse, UserPromptSubmit, PreCompact, SessionStart); PreCompact builds a ≤2 KB priority-tiered XML snapshot into session_resume; SessionStart injects <session_knowledge> directive + 18-category Session Guide. Full continuity only on ~7 of 18 platforms.
  • “Think in Code”: “The LLM should program the analysis, not compute it” — ctx_execute runs 12 languages; “Before: 47 × Read() = 700 KB. After: 1 × ctx_execute() = 3.6 KB.” Credential passthrough for gh/aws/gcloud/kubectl/docker without exposing secrets.
  • Routing enforced by hooks (~98% compliance), not instructions (~60%): “Hooks intercept tool calls programmatically… Instruction files guide the model via prompt instructions but cannot block anything.” Auto-writing routing files to projects was disabled to prevent git-tree pollution; a single unrouted curl can dump 56 KB into context.
  • Deliberately declines output-prose shaping: “Aggressive brevity prompts have been shown to degrade coding/reasoning benchmarks” — the routing block focuses on where data goes, not how the model talks.

Implications (confidence: medium)

Context Mode is the strongest “select, don’t destroy” counterexample to the paper’s warning: evidence is deferred to FTS5 (index full output, return matching sections), not destroyed — same design family as contextsniper’s intention-aware gate. Its refusal of output shaping is the explicit inverse of headroom’s approach. Caveat: all figures are self-reported README context-savings with no billed-cost control arm — exactly the class of input-side metric the paper shows doesn’t predict cost.

Open Questions

  • No billed-cost measurement or control arm — the ~98%/~3-hour claims are unverified against the paper’s success-adjusted-billed-cost lens.
  • “17 platforms” vs 18 in tables — internal inconsistency; heavily version-gated (Claude Code v1.0.33+, Node ≥22.5, Codex PreCompact in CLI 0.130.0+); Cursor marketplace plugin awaiting review.

token-usage-reduction — structural lever in this contested concept’s space token-reduction-is-not-cost-reduction — the decisive evaluation lens rtk-rust-token-killer — contrast: sandboxing/deferring vs rewriting/compressing token-optimizer-mcp — sibling with pre-execution veto hooks contextsniper — mechanism parallel: select-don’t-destroy intent filtering

Sources

  • raw/external/github-com-context-mode-052ecc22.md