Repository navigation
fix(compaction): emit a failure event and back off after a failed summary - #1584
Merged
Merged
Conversation
…a failed summary The trigger estimate counted every assistant message's reasoning, which is never resent to the provider, so a reasoning model ran the estimate to 2.4x the gateway-reported prompt_tokens and tripped auto-compaction at a fraction of the window. A compaction whose summary request failed emitted nothing and was retried on the next turn. It now emits compaction_failed with the error and skips the next bufferSize auto checks. A forced compaction still runs.
This was referenced Oct 20, 2026
Closed
Contributor
|
🎉 This PR is included in version 0.233.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This was referenced Oct 20, 2026
edenreich
added a commit
that referenced
this pull request
Oct 20, 2026
…zer (#1595) Resolves #1592 ## Summary `maybeRolloverSession` runs at the top of every headless turn and `PerformRollover` compacted with `force=true`. That is the `force: true` on 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 (five `compaction_started` in 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 how `current_tokens: 497420` was logged under a 500k threshold. ## Changes - `MaybeRollover` calls the new `performRollover` with `force=false` for the token trigger, so the optimizer applies its own threshold and failure backoff. The idle trigger and the manual `PerformRollover` (`/compact` outside the TUI) keep forcing. - A gated rollover whose optimizer produced no checkpoint message returns `errNoCheckpoint` and leaves the session and the group index untouched. Message count cannot tell, since the skill restorer re-emits loaded skills after the checkpoint. `MaybeRollover` logs it at debug. - `visibleMessages` is shared by the gate and the compaction, so both estimate the same message set. - Tests: the fired case asserts `force=false`, `TestMaybeRollover_NoCheckpointKeepsSession` pins the failed-summary path over three turns, `TestMaybeRollover_IdleTriggerForces` pins the idle path, and `TestShouldRollover` gains a hidden-entries case. In headless both the rollover and `optimizeConversation` in the agent loop consult the optimizer once per turn, so a backoff of `buffer_size` now counts two checks per turn. Unifying the two gates is a separate change. no docs ticket: internal bug fix. --------- Co-authored-by: inference-gateway-maintainer[bot] <246577062+inference-gateway-maintainer[bot]@users.noreply.github.com>
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.
Summary
Closes #1581. The estimate gap and the
force: truequestion continue in #1586.A compaction whose summary request fails logs the error, returns the messages unchanged and emits nothing, so the stream shows
compaction_startedwith no end and the next turn crosses the same threshold and tries again. Each attempt is a full summarisation request. On the run in the issue sixcompaction_startedfired in six minutes before onecompaction_completed.It now emits
compaction_failedwith the error and skips the nextbufferSizeauto checks. A forced compaction (/compact, session rollover) still runs.Changes
internal/conversation/conversation_optimizer.go:compaction_failedevent,skipAutoCheckscounter,inBackoff.bufferSizeturns, a retry after, and force bypasses the backoff.Not in this PR
The issue also reports the trigger estimate running far above the provider's
prompt_tokens. The cause is not established, so the estimate is unchanged here.no docs ticket: internal-only fix
Verification
task precommit:runclean,go test ./...green.