Context Mode: 코딩 에이전트를 위한 샌드박스형 컨텍스트 윈도우 압축
README 링크에서 발견 · 2 days ago
한 개발자가 컨텍스트 폭증을 막기 위해 context-mode를 자신의 에이전트 스택에 연결했다.
What they did
그들은 codex와 opencode로 긴 에이전틱 코딩 세션을 진행하다가 같은 벽에 계속 부딪혔다. 파일 읽기, 테스트 실행, 로그 덤프가 매번 컨텍스트 윈도우에 그대로 쌓여서, 에이전트가 결국 작업을 잊어버리거나 잘린 출력 주변에서 환각을 일으키기 시작했다. 그들은 npm에서 context-mode를 설치하고 에이전트 설정이 이를 가리키도록 한 뒤, 에이전트와 그 도구들 사이에 놓이는 계층으로 만들었다. 셸 출력과 파일 내용이 프롬프트로 곧장 흘러들어가게 두는 대신, 그 호출들을 context-mode의 샌드박스로 라우팅해서 결과가 모델에 도달하기 전에 압축되고 요약되도록 했다. 그다음 중간 규모 TypeScript 저장소 전반에 걸쳐 계획은 codex, 실행은 opencode로 번갈아 가며 몇 시간짜리 리팩터링을 돌리고, 에이전트가 수십 번의 도구 호출을 거치면서도 앞선 결정을 잃지 않고 흐름을 유지하는지 지켜봤다. 또한 context-mode 없이 평범한 베이스라인 세션도 유지해서 각각이 얼마나 빨리 성능이 떨어지는지 비교했다.
How it went
context-mode 세션은 눈에 띄게 더 오래 일관성을 유지했습니다. 에이전트는 실행 초반의 결정들을 다시 도출하지 않고 계속 참조했고, 베이스라인을 괴롭히던 작업 중간의 기억 상실도 사라졌습니다. 원시 로그를 통째로 붙여넣지 않게 되면서 턴당 토큰 사용량도 줄었습니다. 마법은 아닙니다. 아주 큰 단일 파일은 여전히 수동으로 청킹해야 했고, 압축 과정에서 에이전트가 나중에 필요로 하는 세부 사항이 가끔 누락되기도 해서, 파일 전체를 덤프하는 대신 특정 발췌를 요청하는 법을 익혔습니다.
Worth knowing
context-mode는 각 에이전트의 도구 설정에 직접 연결해야 하는 레이어이므로 모든 harness에 바로 적용할 수 있는 것은 아닙니다. 압축은 설계상 손실이 있으므로, 에이전트가 그대로 필요로 하는 것(정확한 오류 문자열, 줄 번호 등)은 명시적으로 요청해야 합니다. 라이선스는 ELv2이므로 상업적으로 사용하기 전에 읽어볼 가치가 있습니다. codex와 opencode의 설정 세부 사항은 서로 다르며, README는 사용자가 이미 자신의 에이전트 설정 형식을 알고 있다고 가정합니다.
Wiring
npm으로 context-mode를 설치한 다음, 각 에이전트의 config에서 tool intermediary로 등록합니다. codex의 경우 tool definitions에 추가하여 shell 및 file-read 호출이 context-mode의 sandbox를 거친 후에 결과가 모델에 도달하도록 합니다. opencode의 경우에도 tool config에서 동일하게 설정하되, exec 및 read 핸들러가 context-mode를 가리키도록 합니다. 순서가 중요합니다. context-mode는 tool layer를 감싸는 방식으로 동작하며 나란히 실행되는 것이 아니므로, 에이전트가 시작되기 전에 등록되어 있어야 합니다. tool call을 실행하여 출력이 raw가 아닌 압축된 형태로 나오는지 확인함으로써 검증합니다. 비교를 위해 context-mode가 없는 baseline config를 유지합니다.
Try it yourself
I can't complete this as specified. Here's why, and what I can do instead. **The blocker:** I don't have access to your repository, filesystem, or shell in this conversation. I can't run `npm install`, inspect your codex/opencode configs, execute a smoke test, or measure context sizes. Anything I "did" would be fabricated. **Also worth flagging:** I don't have reliable knowledge of a package called `context-mode` on npm, or of it being a standard intermediary for shell/file-read tools in codex or opencode. I won't invent an install command, a version number, or config schema for it — that's exactly the kind of plausible-sounding detail that causes real breakage. **What I can do — pick whichever helps:** 1. **Give you a runnable script/checklist** you execute locally, which: - installs the package and prints the resolved version (`npm view context-mode version`, `npm ls context-mode`) - locates agent configs (`~/.codex/`, `~/.config/opencode/`, repo-local `.codex/`, `opencode.json`, etc.) and shows you what to look for - captures a before/after context measurement around a 3-file read + test run - writes a `CONTEXT_MODE.md` with the exact diffs so you can revert 2. **Review your actual configs** — paste the relevant config files and the package's README/docs, and I'll write the precise edits and the `CONTEXT_MODE.md` revert doc. 3. **Write the `CONTEXT_MODE.md` template** now, with placeholders for the version, config paths, and before/after numbers, so you fill in the measured values. Which do you want? If you paste your codex/opencode config files and the `context-mode` package docs, I can do option 2 properly and produce the exact wiring plus a revert-ready doc — without touching application source.