Context Mode:让编程代理在沙箱里算,只把结果塞进上下文
开源接口项目 Context Mode 改变编程代理吃日志的方式:原始快照留在沙箱,由代理写脚本处理,只把精简结果返回上下文;基准里页面快照可从约数十 KB 降到约三百字节。
编程代理打开页面自动化工具、拉代码托管上的议题或跑测试时,大段原始输出常直接灌进上下文。一帧浏览器快照就能到约几十 KB,真正有用的往往只是一行报错,其余标签、样式与无关节点全在白白占额度。
开源项目 Context Mode 换了做法:原始数据留在沙箱,让模型写脚本处理,只把有用结果返回。公开基准示例包括完整调试会话从约四万五千 Token 降到约两千六百,页面快照从约五十六 KB 到约两百九十九字节,整体上下文约降九成四。作者提醒这些是基准估计,不保证人人省下同等额度,也不能把它理解成「多出九成四配额」的绝对承诺。
示意对比图无个人水印,说明「原始数据留沙箱,只有结果进上下文」,并提到大体量内容可进全文检索索引再查询。对经常让代理扫页面、啃构建日志的团队,这类接口把「读一切」改成「算完再读」,更符合「先缩小证据再推理」的工程习惯。
边界同样清楚:节省幅度取决于任务与脚本质量;沙箱执行本身也有权限与供应链风险,引入前应审仓库默认网络策略,并限制可执行范围。若脚本写错,压缩后的摘要可能丢掉关键报错,仍需保留按需取回原文的路径。
Context Mode MCP for Codex and Claude Code
Stop letting Codex waste its context window on massive logs and browser snapshots. This MCP is a game changer.
I recently came across an interesting open-source project called Context Mode, and I think anyone using Codex or Claude Code should check it out.
Here's the problem.
Every time Codex opens a page with Playwright, checks GitHub issues, or runs tests, tons of raw output gets dumped into the context window.
A single browser snapshot can take up 56KB. Most of that information is completely irrelevant. Sometimes all you actually need is one error message.
Context Mode takes a different approach: instead of feeding everything to the AI, it lets the AI write scripts to process the data and only returns the useful results.
For example, instead of reading hundreds of files into context, Codex can run a script in a sandbox, analyze everything there, and return a tiny summary.
The project's benchmarks are pretty impressive:
·Full debugging session: 45,300 → 2,600 tokens ·Playwright snapshot: 56KB → 299 bytes ·Overall context reduction: ~94%
Of course, these are benchmark estimates, not a guarantee that you'll get 94% more Codex usage.