feat(compaction): adaptive failure backoff and actionable context budget errors - #1122
Open
ChrAlpha wants to merge 2 commits into
Open
feat(compaction): adaptive failure backoff and actionable context budget errors#1122ChrAlpha wants to merge 2 commits into
ChrAlpha wants to merge 2 commits into
Conversation
…ssure The failure cooldown was a flat five minutes regardless of pressure, so one transient summarizer failure at the blocking threshold left every turn degraded or failing for the full window. Failures now track consecutive attempts; triggers fired at or above the hard threshold pass HardPressure and re-attempt on an exponential schedule (30s, 1m, 2m, 4m) capped strictly below the flat cooldown, so a capped retry still finds the failure entry alive and attempts accumulate instead of resetting through entry expiry. Soft-pressure triggers keep the flat cooldown, success clears the state, and manual runs still bypass.
A turn rejected for context budget surfaced only "Required context exceeds the model context budget." — accurate, but with nothing the user can do about it. Both context budget details now name the recovery paths: run /compact to summarize older history, shorten the request (window-too-small only), or switch to a model with a larger context window. Localized copies updated in all three web locales per the error-catalog codesync.
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 this is
Two halves of the same failure experience, landed as two commits: when compaction fails under pressure the retry cadence now adapts (commit 1), and when a turn is ultimately rejected for context budget the error tells the user what to do about it (commit 2). The second half was originally #1123, folded in here since both exist to make the context-budget failure path recoverable and legible.
How it works
Cooldown backoff (
feat(compaction): retry on exponential backoff under hard context pressure)The compaction failure cooldown was a flat five minutes regardless of pressure, so one transient summarizer failure at the blocking threshold left every turn degraded or failing for the full window.
HardPressure— both the async trigger and the sync backstop compute it from the same pressure/budget pair — and re-attempt on an exponential schedule: 30s, 1m, 2m, 4m, capped at 4m30s.Actionable budget errors (
feat(apperror): make context budget errors actionable)A turn rejected for context budget surfaced only "Required context exceeds the model context budget." — accurate, but with nothing the user can do about it, in English, on every surface.
context.protected_overflowandcontext.budget_unsatisfiednow name the recovery paths: run/compactto summarize older history, shorten the request (window-too-small only), or switch to a model with a larger context window. Channel replies use the Detail directly; the web UI localizes by code.codesync(error-catalog)contract; pinned expectations updated in Go tests and the web vitest suite./compactis registered on the shared channel command group and shipped as a web chat quick action; channel error rendering applies secret redaction only, no length caps. For a reserve-drivenbudget_unsatisfied(window smaller than the output reserve) only the model switch helps — the wording hedges all three remedies.Verification
RunCompactionSyncgate test (normal pressure skips inside the cooldown, hard pressure past the backoff reaches the model)go test -race ./internal/agent/context/compaction/;go test ./internal/apperror/ ./internal/agent/runtime/native/ ./internal/handlers/ -count=1;pnpm --filter @memohai/web exec vitest run src/utils/api-error.test.ts(51/51) — all re-run on the combined headgo test ./...+ lint via pre-commit on each commit; two adversarial review rounds on the backoff (the original cap-equals-expiry sawtooth was found in review and is pinned by the rewritten cap test) and one on the error copy