Repository navigation
feat: use model fallbacks after context overflow recovery - #170141
Conversation
After replay-safe compaction recovery is exhausted, prefer configured fallback models with known context headroom and report the answering model. Preserve explicit fallback overrides, operator restrictions, and blocked guidance on exhaustion. Refs #9986. Reported by @amirarenco-create, with the local-model use case from @KarimVKarmali.
Use the detached runner contract and fixed model metadata for compaction/fallback integration proof. Assert the existing replay veto without coupling it to a particular terminal error kind.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR tries configured model fallbacks after replay-safe context-overflow recovery is exhausted, preferring candidates with known context headroom. Example: A 52,657-character synthetic request exceeds qwen3:4b's configured 8,192-token window.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it delivers a maintainer-approved recovery capability missing from current main, with no actionable defects found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe agent runner recovers oversized requests on the active model, then passes eligible terminal results to the shared fallback controller, which selects another configured model and records the outcome. flowchart TD
A[Agent request] --> B[Active model attempt]
B --> C[Compaction and truncation recovery]
C --> D[Replay safety classification]
D --> E[Configured fallback controller]
E --> F[Candidate context preference]
F --> G[Answer or preserved overflow guidance]
Technical reviewBest possible solution: Land recovery-first fallback through the existing controller while retaining replay vetoes, configured model restrictions, and terminal overflow guidance. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the missing routing path; the supplied native CLI comparison demonstrates the user-visible failure and recovery, without a new reproduction run during this review. Is this the best way to solve the issue? The change uses existing recovery, classification, context-budget, and fallback owners rather than introducing another routing policy or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e26de4eeae75. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +70, Tests +382, Docs +6. Total +458 across 10 files. Added test files: 2. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (6 earlier review cycles)
Reviewed October 12, 2026, 8:03 PM ET / October 13, 2026, 00:03 UTC (Revision 7). |
|
Merged via squash.
|
…70141) * feat: recover context overflow with configured model fallbacks After replay-safe compaction recovery is exhausted, prefer configured fallback models with known context headroom and report the answering model. Preserve explicit fallback overrides, operator restrictions, and blocked guidance on exhaustion. Refs openclaw#9986. Reported by @amirarenco-create, with the local-model use case from @KarimVKarmali. * test: isolate overflow recovery from durable session storage Use the detached runner contract and fixed model metadata for compaction/fallback integration proof. Assert the existing replay veto without coupling it to a particular terminal error kind. * test: retain model input literal types in overflow fixtures * test: prepare runtime config for overflow recovery
Publish the neutral suite runtime snapshot through the post-reset config owner, leaving run admission and live required-worker enforcement unchanged. Retain the intentional context-overflow failed-attempt receipt from #170141. Current-main baseline reproduces 52 failures and one passing control. The complete 17-case runner and 26-case auth files pass after preparation; the complete ten-case fault file passes with the exact one-attempt assertion. Scoped types, typed lint, formatting, and independent P0-P2 review pass. Production code is unchanged.
Publish the neutral suite runtime snapshot through the post-reset config owner, leaving run admission and live required-worker enforcement unchanged. Retain the intentional context-overflow failed-attempt receipt from openclaw#170141. Current-main baseline reproduces 52 failures and one passing control. The complete 17-case runner and 26-case auth files pass after preparation; the complete ten-case fault file passes with the exact one-attempt assertion. Scoped types, typed lint, formatting, and independent P0-P2 review pass. Production code is unchanged.
Closes #9986
What Problem This Solves
A request that still exceeds the primary model's context window after recovery fails even when a configured fallback can handle it.
User Impact
Replay-safe turns can finish on a configured fallback after compaction and oversized-tool-result recovery are exhausted, with a visible warning naming the model that answered and why it changed. Existing model locks, explicit fallback overrides (including
[]), operator restrictions, and replay guards still apply. No configuration or migration is required.Why This Change Was Made
The embedded recovery owner still tries to make the primary request fit first. Its terminal overflow result now reaches the existing fallback owner, which prefers remaining candidates whose known effective context windows fit and preserves configured order within each group. Unknown or smaller windows remain eligible; when provider token counts are absent, larger-window preference is a hint rather than a fit guarantee. Exhaustion preserves the original overflow guidance. Embedded provider request-size/TPM ceilings remain terminal.
Thanks to @amirarenco-create for the feature request and @KarimVKarmali for the local-model reproduction, and to @engagepy and @zhupeng0o0 for the additional reports.
Evidence
09754eef5fb91ef76ffed5991e0025a5dac3a347; merged main069d40e40cfdadee9c18700168883709fd58693dto take existing runtime-configuration fixture repairs. The four feature implementation files and four feature test files are byte-identical to the reviewed version. No additional production change was needed for CI repair.node scripts/run-vitest.mjs <files> --maxWorkers=1wrapper. Times include cold compilation and wrapper cleanup on the shared Mac.node scripts/worktree-setup.mjs gatewaypassed; build phases took 8m 38.4s. Core production and changed-test typechecks passed; the latter selected theagents-othergraph. Targeted lint and formatting passed. All seven required ratchets passed: max-lines, line-cap, assertion-safety, test-timeout-race, test-mock-exports, config docs, and plugin inventory.qwen3:4bat 8,192 tokens failed on base856ae491f235bd70a9ac85d1ad1384fe5acdd2b3with no fallback (37.28 s); the feature completed the same 52,657-character synthetic request through configuredqwen3:8bat 32,768 tokens, returningOVERFLOW_FALLBACK_OK,fallbackUsed: true, and reasoncontext_overflow(136.05 s). This CI repair did not rerun live inference.CI attribution and main integration
Original run
38305345929checked mergec48e94c2aea8e72201bd984f90f1580f7f31c41eagainst exact main basec5b9b254bff4d728447da563b2c29de8461a2007. Its 234 extension entries comprise 233 test failures and one suite-loading failure; it also had 22 other core failures and four cleanup failures.The strict runtime-config snapshot migration on that base exposed fixtures that previously relied on lazy config loading. Paired local runs covered every distinct extension error group, plus cleanup: direct native-policy errors, plugin-load errors, missing native requests, native timeouts, startup errors, agent-end behavior, Copilot finalization, and scheduled approvals. The native tests call their attempt/compaction owners directly, without entering the changed fallback runner. The scheduled-approval and plugin-load failures reproduce exactly on the base and pass on the original PR head; the cleanup representative reproduces the exact runtime-config rejection and 120-second timeout on the base and passes on the original head. Main already supplies the missing fixture configuration in
d8253ad5ef5df239276c29d706775b8ae39a06f6,cbc53ac75eca314efebdcc57cfcbb68ce5d4e99e, and the cleanup repair in4944a6df77080f328fed59ee22384e3ee45d522f.The warm-claim settlement representative passes on the original PR head. Running it after the same preceding explicit-target test used by CI reproduces the exact base failure:
initializeandinitializedare sent, butconfigRequirements/readis absent (210.99 s wall; preceding test passed). A cold filtered run stopped one checkpoint earlier; the ordered run resolves that attribution gap without changing either test or its timeout. The integration's complete cleanup/rooted/suspension suite is green; broad extension coverage belongs to the new exact-head CI run.Local proof entry point
The message asks for
OVERFLOW_FALLBACK_OKafter 700 synthetic padding rows. Isolated state/config and profile were used; no operator state or running Gateway was touched.OPENCLAW_STATE_DIR=/private/tmp/oc-lm-feat-overflow-fallback/candidate-state-v2 \ OPENCLAW_CONFIG_PATH=/private/tmp/oc-lm-feat-overflow-fallback/state/openclaw.json \ TMPDIR=/private/tmp/oc-lm-feat-overflow-fallback/tmp \ pnpm openclaw --profile feat-overflow-fallback agent --local \ --agent main --session-id overflow-candidate \ --message "$(cat /private/tmp/oc-lm-feat-overflow-fallback/message.txt)" \ --json --timeout 180This exercises the CLI, embedded context recovery, fallback selection, native Ollama generation, and visible terminal result. The primary's oversized-message rejection is OpenClaw's precheck; the separate composition test covers a provider still rejecting after bounded compaction.
Exact-head validation complete for
09754eef5fb91ef76ffed5991e0025a5dac3a347: CI run 38323581294 passed, including all three extension bundles andopenclaw/ci-gate(44 successful jobs, 26 intentionally skipped, no failures). ClawSweeper reviewed this exact head with no findings and no Before merge items. Its proof-only note is that a base-failing run of the added regression tests is not recorded; the supplied native CLI comparison provides before-and-after user-flow evidence. No additional proof cycle was pursued for that note. CI wall times: extension bundles 1/2/3 took 352/646/366 seconds; compact-large-13 took 253 seconds. The PR remains open and is not being merged by this repair lane.