Repository navigation
fix(tui): gate auto-compact on the capped history the request sends - #2066
Merged
Merged
Conversation
Contributor
|
nc-review could not produce a verdict this run (agent exit |
will-lamerton
force-pushed
the
fix/tui-auto-compact-capped-gate
branch
from
November 11, 2026 15:04
2054db1 to
adec59b
Compare
The TUI loop measured the full history against the auto-compact threshold while the request only sent capMessagesForModel(messages, maxMessages), so rows the cap already drops could trigger compaction. Gate on the capped view and adopt the result only when compaction ran, matching run/--plain and the subagent executor. Also drop the modeOverrides ternary whose branches built the same object, and the try/catch around maybeAutoCompact, which never throws. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
will-lamerton
force-pushed
the
fix/tui-auto-compact-capped-gate
branch
from
November 11, 2026 15:08
adec59b to
eeeb9d0
Compare
This was referenced Nov 11, 2026
jay23606
added a commit
to jay23606/nanocoder
that referenced
this pull request
Nov 12, 2026
…ano-Collective#2066) The TUI loop measured the full history against the auto-compact threshold while the request only sent capMessagesForModel(messages, maxMessages), so rows the cap already drops could trigger compaction. Gate on the capped view and adopt the result only when compaction ran, matching run/--plain and the subagent executor. Also drop the modeOverrides ternary whose branches built the same object, and the try/catch around maybeAutoCompact, which never throws. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
The TUI conversation loop sends
capMessagesForModel(messages, maxMessages)to the model, but its auto-compact gate measured the fullupdatedMessages. In a long session withsessions.maxMessagesset, old rows that the cap already drops from every request still counted toward the threshold. Compaction could fire, and spend an LLM summary call, while the request was well under the limit.run/--plain(plain/conversation.ts) and the subagent executor already gate on the capped view, so the TUI was the odd one out.Fix
Gate on
capMessagesForModel(updatedMessages, maxMessages). The result is adopted only when compaction actually ran (compacted !== compactGateInput), the same as the other two loops. OtherwisemaybeAutoCompacthands back the capped view, and taking it would discard history.There is one behaviour difference, and it matches
plainand subagents. When compaction does run, the compacted capped view replaces the history, so rows beyond the cap are no longer kept in memory. Previously the whole history was compressed and kept. Those rows were never sent to the model, but they did end up in the autosaved session. Flagging it in case a maintainer prefers to keep the dropped prefix. I didn't do that here: with the LLM summary strategy, the shorter compacted tail would pull the old, uncompacted prefix back into the next request's window.Dead code removed alongside (item 9 of the review), both trivially safe:
modeOverridesternary. Both branches built the same object; whennonInteractiveModeis false,nonInteractiveAlwaysAllowis already[].try/catcharoundmaybeAutoCompact. That function catches everything fromperformAutoCompactitself, and the only other call in it,getAppConfig(), has already run at the top of the loop.Testing
New
conversation-loop.spec.tscase:maxMessages: 2, a context limit the capped view fits under, and two large old rows that only the full history counts. It asserts that no compaction notice is queued and that the full history plus the reply is kept. It fails onmainand passes with the fix. The existing auto-compaction specs, which use the default cap, still pass.Passing locally:
tsc --noEmit,biome checkandconversation-loop.spec.ts.🤖 Generated with Claude Code