You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
agent: mid-turn compaction (a single turn that grows past the budget) #7
Follow-up to issue 939. The SummarizingCompactor fires once, at the top of a turn, on the incoming history (via RunnerConfig.Compactor). That covers the common case (a long conversation), but not a single turn that itself balloons past the context budget mid-loop — e.g. many parallel tool calls returning large results within one turn.
Scope
Re-check the estimate inside the Runner loop (between steps) and re-run the Compactor on the working msgs when it crosses the budget, emitting another EventCompaction.
Decide the interaction with tool-result offloading (966): offloading already shrinks large tool outputs to stubs, so mid-turn compaction is the fallback for when even the stubs + assistant text exceed budget.
Guard against a compaction/So-still-too-big loop (a hard floor; abort the turn with a clear error if a single step can't fit).
Roadmap notes this as the "L for mid-turn" effort. The pre-loop hook shipped in 939 is the "M" version.
Data point from dogfood run 1 (#57): DeepSeek used 155k input tokens over 8 steps answering a single 'where is X built' question, mostly from read_file returning whole files (main.go, config.go, app.go, connections.go) that then rode along in every later step. Mid-turn compaction would bound that; so would read_file defaulting to a window.
Folding #109's last item in here, as agreed: make the step budget visible to the model ("step 31 of 40"). It needs the before-each-model-call point, so it'll be one of the first stages on the step chain this PR adds. See docs/HOOKS.md (#125).
Activity
panyam commentedon Oct 15, 2026
Data point from dogfood run 1 (#57): DeepSeek used 155k input tokens over 8 steps answering a single 'where is X built' question, mostly from read_file returning whole files (main.go, config.go, app.go, connections.go) that then rode along in every later step. Mid-turn compaction would bound that; so would read_file defaulting to a window.
panyam commentedon Oct 26, 2026
Folding #109's last item in here, as agreed: make the step budget visible to the model ("step 31 of 40"). It needs the before-each-model-call point, so it'll be one of the first stages on the step chain this PR adds. See
docs/HOOKS.md(#125).