Context
[context] says what of the conversation each round carries.
[context]
recent_turns = 0
| Key | Meaning | Default |
|---|---|---|
recent_turns | Finished turns before the current one whose tool results are sent whole. The current turn's always are. The results of every older turn are replaced by a one-line stub at the start of each turn. | 0 |
high_water | History fraction that triggers a turn-boundary state update. | 0.8 |
low_water | See the threshold and cap rules below. | 0.5 |
summary_max_tokens | Approximate state-record cap, excluding verbatim active skills. | 4000 |
instruction_max_tokens | See the threshold and cap rules below. | 400 |
Watermarks must satisfy 0 < low_water < high_water <= 1; token caps are
positive and the instruction cap cannot exceed the summary cap. Defaults are
high_water = 0.8, low_water = 0.5, summary_max_tokens = 4000, and
instruction_max_tokens = 400.
Before a prompt turn starts, history is estimated after ordinary result elision. Its budget is half the model window after reserving output. Crossing high water folds older finished turns toward low water, leaving room for the state record and verbatim active skills. Current and configured recent turns stay whole.
The state record carries verbatim instruction excerpts (with source turn IDs),
the original goal, last write actions, original commands with observed
completion lines, exact questions/answers, and structured decisions, rejected
approaches, facts, and open items. The summarize role supplies only the
judgment sections and standing-instruction selection. Reports retry once if
malformed; every attempt is billed. Failed, oversized, canceled, or stale
updates retain raw history. A protected request that cannot fit fails before
provider dispatch; shorten the prompt or use /clear rather than expecting
silent truncation.
/summary is a separate human-readable work cache, not a context-state
inspector.
What the model sees
Until a state document covers older turns, requests carry your prompts, the model's replies, and each tool call with its parameters, from the first turn on. What changes at a turn boundary is the results of the turns before it. A file the model read last turn is sent to it this turn as
[view src/auth.rs: 412 lines, elided]
and a command it ran as
[exec cargo test: error, 96 lines, elided]
The tool is named, so is its target, whether it failed, and how much there was.
The file is still on disk, and read_turn recovers recorded earlier results.
For retained command logs, use read_output instead of re-executing a command
that might have side effects. Within a turn the recorded initial representation
stays fixed. Opt-in
successful command output can choose a
terse status before the result's first model appearance; original stdout/stderr
remain recoverable. This is source-level selection, not later pressure-driven
elision of current-turn evidence.
Some results are never stubbed: short ones, since an edit confirmation or a
todos list is about the size of its stub and says more; your answers to
ask_user, which are your words; and activated skills,
which must stay in the conversation to count as active.
Why the default is zero
A round costs what it carries, and tool results are most of what a conversation carries: across the sessions this was measured on, results from earlier turns were a quarter of everything spent. Stubbing them at every turn boundary is the largest single saving heph makes.
The window is zero rather than a few turns because of how the prompt cache
prices a change. Eliding a turn moves the point from which the cached prefix no
longer matches, and everything after that point is written to the cache again,
at about twelve times the price of reading it. Keeping the last R finished
turns whole means rewriting those R turns at the start of every turn to save
the reads of the turns before them. On the recorded sessions a window of zero
saved 22%, one saved 6%, two broke even, and four cost more than no elision at
all. Set recent_turns above zero if you would rather the model keep the last
turn's reads in view, knowing that each turn kept whole is also paid for again
at every turn start.
What was stored is not changed. The conversation on screen shows every result in
full, and so does the read_turn tool.