Repository navigation
fix(conversation): gate a token-triggered rollover through the optimizer - #1595
Conversation
Session rollover compacted with force=true on every headless turn, so a failed summary skipped the backoff from #1584 and was retried each turn, and the rollover still started a new session copying the full history when nothing was summarised. Its gate also estimated over hidden entries the compaction then dropped. A token-triggered rollover now compacts with force=false, so the optimizer applies its own threshold and failure backoff, and it keeps the current session when the optimizer returned no reduction. The idle trigger and the manual PerformRollover keep forcing. The gate estimates the same visible messages the rollover compacts.
|
@infer please use counterfeiter for fakes or mocks, add this also to your AGENTS.md so this is not repeating, fix this. |
|
Model: Todos
Pull Request✅ Infer Result: SuccessDone. The PR now uses counterfeiter-generated fakes everywhere it touches, and AGENTS.md states the rule explicitly so the feedback does not repeat. What changed
Verification
no docs ticket: internal-only refactor. Skipped: I did not sweep the rest of the repo for other hand-written doubles - a grep for the optimizer interface found only these two fakes, and other test doubles I saw in passing are already counterfeiter output. Risk: none known, the stubs behave exactly like the old fakes and the same assertions pass. Model: Tokens: 2,749,148 in · 26,227 out · 2,775,375 total (38 requests) Tool calls: 57 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
…feiter output FakeConversationOptimizer is now generated by mocks:generate and both the session rollover tests and the chat rollover fixture configure it through its Stub field and generated accessors instead of hand-writing optimizer stand-ins in tests. no docs ticket: internal-only refactor.
Makes the existing counterfeiter convention explicit so review feedback like this does not repeat: no hand-written fake or mock structs in tests, every test double is generated by mocks:generate and configured through its Stub or Returns fields.
…age count The skill restorer re-emits loaded skills after the checkpoint, so a compacted conversation can hold more messages than before. A gated rollover now looks for the checkpoint message instead.
|
🎉 This PR is included in version 0.234.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolves #1592
Summary
maybeRolloverSessionruns at the top of every headless turn andPerformRollovercompacted withforce=true. That is theforce: trueon every auto compaction in #1586, and it had three effects on the run there: the backoff from #1584 only guards!force, so a failed summary was retried every turn (fivecompaction_startedin six minutes), each failed attempt still started a new session and copied the full history into it, and the gate estimated over hidden system reminders the compaction then dropped, which is howcurrent_tokens: 497420was logged under a 500k threshold.Changes
MaybeRollovercalls the newperformRolloverwithforce=falsefor the token trigger, so the optimizer applies its own threshold and failure backoff. The idle trigger and the manualPerformRollover(/compactoutside the TUI) keep forcing.errNoCheckpointand leaves the session and the group index untouched. Message count cannot tell, since the skill restorer re-emits loaded skills after the checkpoint.MaybeRolloverlogs it at debug.visibleMessagesis shared by the gate and the compaction, so both estimate the same message set.force=false,TestMaybeRollover_NoCheckpointKeepsSessionpins the failed-summary path over three turns,TestMaybeRollover_IdleTriggerForcespins the idle path, andTestShouldRollovergains a hidden-entries case.In headless both the rollover and
optimizeConversationin the agent loop consult the optimizer once per turn, so a backoff ofbuffer_sizenow counts two checks per turn. Unifying the two gates is a separate change.no docs ticket: internal bug fix.