Skip to content

fix: prevent stale fallback models after plugin reloads - #133633

Merged
steipete merged 1 commit into
mainfrom
codex/130706-provider-normalization
Sep 8, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/130706-provider-normalization

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130706, #130324. CPU/stall recovery for #130324 remains unproven by this repair.

What Problem This Solves

Resolves a problem where model fallback could select a model normalized by another provider generation after a plugin reload. A narrowed metadata view could also keep applying model aliases from a broader view.

Why This Change Was Made

Fallback candidate reuse now distinguishes both the selected runtime registry and the exact metadata view. Weak identity tokens keep the existing global 256-entry bound without retaining retired contexts, and callers receive independent copies of cached candidates.

This narrows the former umbrella change to the remaining two-file cache repair. Provider hook and alias ownership landed separately in #141679, and admitted compaction generation selection landed in #139429. Related SDK and model-selection fixture cleanup landed in #139829, #139900, and #140069; the wider extraction remains tracked in #130706.

User Impact

Fallback uses the provider implementation and manifest rules selected for that run, even when multiple generations coexist. Empty registries and narrowed metadata views remain authoritative, and one caller cannot change another caller's cached model or route provenance.

The production change is +5 lines after removing redundant collector typing and copy-helper plumbing. The regression file adds 107 lines covering three cases. This remains an in-memory cache repair with no configuration, persistent-store, or protocol change.

Evidence

  • Before the fix, warming generation A made both retained-generation and request-scoped B return model-a instead of model-b. A shared empty registry with full→narrow metadata returned model-full instead of latest. The unfixed source is identical on the current main base.

  • On main 665d4fadbd475a4117dc90696ae2da1037afdb3c, the cache regression and two normalization sibling files passed 28 tests. They cover A→B→empty→A→A, active-scope restoration, full→narrow→full metadata, and mutation isolation for model and route fields.

  • An isolated synthetic source run through runWithModelFallback attempted the expected A/B/empty/A fallback models after each primary failure. This is source-boundary proof, not a package, Gateway, or authenticated-provider result.

  • The prior full changed gate and managed P2 scoped-clean review carry forward by exact equivalence: both file operations and postimages, all 33 reviewed context files, and 21 additional dependency/tooling/owner files are byte-identical. Current-main targeted lint, formatting, and diff checks passed. Required CI must be assessed on the rewritten PR head.

  • Blacksmith Testbox runtime proof built exact published head 63be3978bdaf3941ddf3b367c4624ed4e21da739. Both compiled cache scenarios passed: retained registries A→B→empty→A and metadata full→narrow→full. Across seven contexts, the real fallback runner made all 14 expected primary/fallback attempts; caller-copy isolation and route provenance remained intact. All six production functions came from that natural build. Both process groups settled without escalation, fixtures were removed, source/runtime manifests stayed unchanged, and all 81 exported files were hash-verified.

This is compiled production-boundary proof with synthetic provider callbacks. It does not establish Gateway, external-provider, or CPU/stall recovery. Exact-head CI and native landing remain pending.

Contributor credit remains Peter Steinberger (@steipete).

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 31, 2026 00:00
@steipete
steipete requested a review from a team as a code owner August 31, 2026 00:00
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 11:43 PM ET / September 8, 2026, 03:43 UTC.

ClawSweeper review

What this changes

The PR separates cached fallback model lists by plugin registry and metadata view, preserves caller-owned copies, and adds reload regression coverage.

Merge readiness

✅ Ready for maintainer review

The narrowed repair remains necessary on current main. No actionable defect was found, and the previous draft-status blocker is resolved.

Priority: P2
Reviewed head: 63be3978bdaf3941ddf3b367c4624ed4e21da739

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful ordered regression coverage and no supported correctness blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured body reports compiled fallback-runner recovery across registry and metadata transitions using synthetic callbacks; the linked artifact could not be independently retrieved, and no external-provider or CPU-recovery claim is accepted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured body reports compiled fallback-runner recovery across registry and metadata transitions using synthetic callbacks; the linked artifact could not be independently retrieved, and no external-provider or CPU-recovery claim is accepted.
Evidence reviewed 8 items Current main still needs the repair: The fetched main implementation keys candidates by configuration fingerprints and global registry state, without the selected registry or metadata-view identities added by this PR.
Cache identity matches normalization ownership: Runtime normalization uses the same retained-generation-first registry selection as the new cache key. Empty registries remain authoritative. This is OpenClaw-owned normalization; the narrowed patch does not depend on the Codex runtime or protocol.
Existing metadata contract: The documentation explicitly requires narrowed normalization views to remain authoritative, including empty views that must not inherit broader snapshot policies.
Findings None None.
Security None None.

How this fits together

OpenClaw builds an ordered model list from the requested model and configured fallbacks. Plugin metadata and provider hooks normalize those choices before the fallback runner attempts them.

flowchart TD
  A[Requested model and configured fallbacks] --> D[Fallback candidate cache]
  B[Selected plugin registry] --> D
  C[Selected metadata view] --> D
  D --> E[Ordered independent candidate list]
  E --> F[Model fallback runner]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests +107. Total +112 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 29 24 +5
Tests 1 107 0 +107
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 136 24 +112

Review metrics

None.

Technical review

Best possible solution:

Keep fallback caching bounded and tied to the exact registry and metadata view already selected for the operation.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: identical configuration and metadata fingerprints can reuse generation A's cached models under generation B or a narrowed view. The added regression captures that sequence; this review did not execute it.

Is this the best way to solve the issue?

Yes. Adding the missing context identities at the cache owner preserves existing normalization precedence, candidate ordering, copy isolation, and the 256-entry bound without adding a competing selection path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2da0ae724dae.

Labels

Label justifications:

  • P2: This repairs a bounded wrong-model selection defect when plugin generations or metadata views coexist.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured body reports compiled fallback-runner recovery across registry and metadata transitions using synthetic callbacks; the linked artifact could not be independently retrieved, and no external-provider or CPU-recovery claim is accepted.

Evidence

What I checked:

  • Current main still needs the repair: The fetched main implementation keys candidates by configuration fingerprints and global registry state, without the selected registry or metadata-view identities added by this PR. (src/agents/model-fallback-candidates.ts:193, 2da0ae724dae)
  • Cache identity matches normalization ownership: Runtime normalization uses the same retained-generation-first registry selection as the new cache key. Empty registries remain authoritative. This is OpenClaw-owned normalization; the narrowed patch does not depend on the Codex runtime or protocol. (src/agents/provider-model-normalization.runtime.ts:16, 63be3978bdaf)
  • Existing metadata contract: The documentation explicitly requires narrowed normalization views to remain authoritative, including empty views that must not inherit broader snapshot policies. Public docs: docs/plugins/architecture.md. (docs/plugins/architecture.md:149, 63be3978bdaf)
  • Focused regression coverage: The complete added test exercises retained-generation and request-scoped A→B→empty→A→A transitions, active-scope restoration, mutation isolation, and full→narrow→full metadata with a shared registry. Assertions inspect candidate values and provenance rather than cache internals. Tests were inspected, not executed during this read-only review. (src/agents/model-fallback-candidates.generation.test.ts:15, 63be3978bdaf)
  • Pinned scope and review continuity: The verified introduction contains only the candidate-cache implementation and its regression file. Earlier packaged-path, changelog, and compaction concerns do not remain in this patch. The latest completed review had no findings; supplied GitHub state records ready-for-review at 2026-09-08T03:38:58Z. (63be3978bdaf)
  • Captured compiled-boundary evidence: The supplied PR body at source revision 2f2d7594eecc32a3f15f595e7efaa4224f2fa1d92187e85596647322ed38129d links https://github.com/openclaw/openclaw/actions/runs/34181669478 and reports seven contexts with 14 expected primary/fallback attempts through the compiled production runner, using synthetic provider callbacks. Direct GitHub and browser retrieval failed, so the artifact was not independently inspected. The claim does not extend to authenticated providers, Gateway behavior, or CPU recovery. (63be3978bdaf)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-31T00:06:46.517Z sha a27f0eb :: needs changes before merge. :: [P1] Resolve the built facade from the parent directory
  • reviewed 2026-08-31T00:17:09.727Z sha a27f0eb :: found issues before merge. :: [P1] Resolve the built facade from the parent directory | [P3] Remove the release-owned changelog entry
  • reviewed 2026-08-31T22:57:56.357Z sha e7cabfd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T23:08:52.243Z sha e7cabfd :: found issues before merge. :: [P1] Apply static normalization to queued compaction
  • reviewed 2026-08-31T23:23:54.105Z sha e7cabfd :: found issues before merge. :: [P1] Pass static normalization into queued compaction
  • reviewed 2026-09-01T15:27:57.900Z sha d847db0 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-08T01:53:05.649Z sha 63be397 :: needs changes before merge. :: none
  • reviewed 2026-09-08T03:36:07.079Z sha 63be397 :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 31, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer review of the packaged-path finding on a27f0eb7189bd12cec13f7c7c365daa89409cb32:

The proposed ../plugins/ change is not applicable to the emitted artifact. dist/plugin-sdk/model-ref-parse.js:2 imports the parser from a root dist chunk. The flagged import.meta.url expression is physically emitted in dist/model-ref-shared-Ce0-Yp5A.js:64, where ./plugins/provider-model-normalization.runtime.js resolves to the existing stable facade. Its URL is relative to the defining module, not the SDK caller. Changing it to ../plugins/ would point outside dist.

The full declaration-enabled build and built SDK cold/warm normalization assertions passed at this head. The cold assertion requires normalized-first before any retained-generation scope is entered; nested empty generations and scope restoration were tested separately. The URL-owning chunk hash is e9d123f3ee0bbcc88fcb0f7c3343ff1e4ac28bec056345cae985a9f007ecb892 and the stable facade hash is b38b6266ee830b19968c3a4ba75a3b98308546112278eaa433482c755d249331. This conclusion is specific to that inspected build.

The one-line changelog entry is retained by explicit maintainer direction. The +38 production lines separate retained lookup from cold loading and share matching/evaluation; duplicate probes, matching logic, and cached hook misses were removed.

Hosted CI run 33343257890 is still failing. Its source-loader/test failures are being investigated independently; this comment is not a merge-ready claim or a waiver of CI.

@steipete
steipete force-pushed the codex/130706-provider-normalization branch from a27f0eb to e7cabfd Compare August 31, 2026 22:49
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
Bind the bounded fallback candidate cache to both the selected provider registry and exact metadata view. Preserve caller-owned copies and remove redundant collector typing and clone plumbing.

Related: #130706, #133633. No claim of CPU workload recovery for #130324.
@steipete
steipete force-pushed the codex/130706-provider-normalization branch from d847db0 to 63be397 Compare September 8, 2026 01:45
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed channel: telegram Channel integration: telegram gateway Gateway runtime scripts Repository scripts commands Command implementations extensions: codex size: XL labels Sep 8, 2026
@steipete steipete changed the title fix: preserve selected models across reloads and compaction fix: prevent stale fallback models after plugin reloads Sep 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. labels Sep 8, 2026
steipete added a commit that referenced this pull request Sep 8, 2026
Read the replacement runtime configuration, authored activation source and metadata together when deferred startup logging begins. Remove redundant one-shot plugin-load memoization while retaining load, claim, retirement and attachment ordering.

Related: #130706, #133633.
@steipete
steipete marked this pull request as ready for review September 8, 2026 03:38
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
Read the replacement runtime configuration, authored activation source and metadata together when deferred startup logging begins. Remove redundant one-shot plugin-load memoization while retaining load, claim, retirement and attachment ordering.

Related: openclaw#130706, openclaw#133633.
@steipete
steipete merged commit 0e1f60e into main Sep 8, 2026
271 checks passed
@steipete
steipete deleted the codex/130706-provider-normalization branch September 8, 2026 05:08
@steipete

steipete commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 9, 2026
)

Bind the bounded fallback candidate cache to both the selected provider registry and exact metadata view. Preserve caller-owned copies and remove redundant collector typing and clone plumbing.

Related: openclaw#130706, openclaw#133633. No claim of CPU workload recovery for openclaw#130324.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant