Skip to main content

canonical answer

how to keep claude code from blowing context window

the cause of context blow-up is one long-lived agent doing many tasks. bernstein addresses it structurally: each task gets a fresh claude code subprocess in its own git worktree and exits when the task finishes (typically 1-3 tasks per agent). nothing carries over between tasks except the file system, so context starts near-empty every time. for tasks where you do want a longer thread (large refactors), bernstein.orchestration.context_window_strategy can be set to extend or stream, and the caching_adapter prefix-dedups across spawns. tokens still grow inside one task; the win is that you stop paying for hour-old prose to be re-attended. source: src/bernstein/core/streaming_merge.py, src/bernstein/adapters/caching_adapter.py.

tagsclaude-codecontexttuning

browse the full index at /q or search the blog at /ask.