feat(compaction): add fallbackModel to retry compaction on quota/rate-limit errors#34569
Closed
iamcobolt wants to merge 1 commit intoopenclaw:mainfrom
Closed
feat(compaction): add fallbackModel to retry compaction on quota/rate-limit errors#34569iamcobolt wants to merge 1 commit intoopenclaw:mainfrom
iamcobolt wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…-limit errors
Adds agents.defaults.compaction.fallbackModel — an opt-in key that retries
compaction with a different model when the primary fails due to quota or
rate-limit errors (HTTP 429 / 402 billing). Auth errors and timeouts use
their own retry mechanisms and are unaffected.
"off" (default): no change in behaviour
"fallback": tries each model in agents.defaults.model.fallbacks in order,
skipping the current model; re-throws after exhausting candidates
Also ships the companion thinking-override change (compaction-overrides.ts)
needed for compact.ts's inner thinking-retry loop. See companion PR openclaw#33296.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16 tasks
5 tasks
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
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
agents.defaults.compaction.fallbackModelkey. Set to"fallback"to retry compaction using theagents.defaults.model.fallbackschain in order, skipping the current model. Defaults to"off".Schema
agents.defaults.compaction.fallbackModel:"off"(default) |"fallback""off": quota/rate-limit errors surface as-is."fallback": retries each model inagents.defaults.model.fallbacksin order, skipping the current model. Re-throws after exhausting all candidates.Renders as a two-button segmented control in the config UI, with a help tooltip.
UI — Before / After
Before (upstream
main— no Compaction Fallback Model field):After — new
Compaction Fallback Modelfield withoff / fallbacksegmented control:Change Type
Scope
Linked Issue/PR
compaction.thinking)Key Changes
compaction-fallback.ts(new) —resolveCompactionFallbackCandidates()resolves the ordered candidate list from config; filters out the current modelcompaction-fallback.test.ts(new) — 6 unit tests covering all statescompact.ts— outer model-fallback loop wrapping the thinking-retry inner loop;transcriptPolicyandsanitizeSessionHistoryre-resolved per candidate;before_compactionhook guarded byhookFired(fires exactly once per compaction event)compaction-overrides.ts— also shipsresolveCompactionThinkLevel(companion to feat(compaction): disable thinking by default; add compaction.thinking override #34554); both features share this helpertypes.agent-defaults.ts/zod-schema.agent-defaults.ts— bothfallbackModelandthinkingfields narrowed to their 2-option unionsNotes for Reviewers
rate_limit/billingerrors with remaining candidates; after exhausting all candidates the last quota error is re-thrown.before_compactionhook: guarded byhookFiredso it fires exactly once regardless of model or thinking retry depth.transcriptPolicyandsanitizeSessionHistoryre-resolved per candidate — provider-specific flags correct for cross-provider fallbacks.compaction-overrides.tshelper from companion feat(compaction): disable thinking by default; add compaction.thinking override #34554. If feat(compaction): disable thinking by default; add compaction.thinking override #34554 merges first, this diff will shrink accordingly.User-visible / Behavior Changes
agents.defaults.compaction.fallbackModel(opt-in; defaults to"off", no change in behaviour)."fallback"and compaction hits a quota error, it retries silently with the next model in the fallbacks chain.Security Impact
Repro + Verification
agents.defaults.compaction.fallbackModel: "fallback"with amodel.fallbackschainEvidence
resolveCompactionFallbackCandidatescasesHuman Verification
pnpm tsgoclean,pnpm checkpasses"off","fallback"with empty fallbacks,"fallback"filtering current model,hookFiredguard across model and thinking retry loopsCompatibility / Migration
fallbackModelis optional; default is"off"(no behaviour change)agents.defaults.compaction.fallbackModel: "fallback"withagents.defaults.model.fallbackspopulatedFailure Recovery
agents.defaults.compaction.fallbackModel: "off"fallbackModelconfig valueRisks and Mitigations
"fallback"is opt-in; users configure their own fallbacks chain.transcriptPolicyandsanitizeSessionHistoryare re-resolved per candidate.