Skip to content

fix(agents): keep model resolution on one plugin generation - #125569

Merged
steipete merged 2 commits into
mainfrom
steipete/model-generation-owner-refactor
Aug 18, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/model-generation-owner-refactor

Conversation

@steipete

@steipete steipete commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #125090, #125182

What Problem This Solves

Fixes an issue where an in-flight agent request could combine model metadata and runtime behavior from different plugin generations when a plugin reload completed mid-request. Alias normalization, suppression, static catalog metadata, runtime hooks, provider auth, stream selection, and image compression policy could otherwise disagree about which generation owned the model route.

Why This Change Was Made

Model resolution now enters one prepared plugin-generation scope at the public resolver boundary and carries one lazy static-catalog fact through its leaf resolvers instead of rediscovering it. The same owner boundary now covers the complete /btw continuation through provider auth and stream selection; suppression caching uses scoped metadata identity; and image compression delegates static policy composition to the canonical model resolver.

This is AI-assisted work. The final diff was inspected directly, validated locally and in an isolated Testbox, and passed the repository autoreview gate.

User Impact

Requests admitted before a plugin reload remain internally consistent through completion instead of borrowing aliases, model metadata, credentials, hooks, or stream factories from the replacement generation. No configuration or public API changes are required.

Production code changes are +19 net lines. Test and test-support coverage is +474 net lines. The assertion-safety baseline shrinks by three existing assertions.

Evidence

  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/model.generation-scope.test.ts src/agents/embedded-agent-runner/model.test.ts src/agents/embedded-agent-runner/model.static-catalog.snapshot-cache.test.ts src/agents/embedded-agent-runner/model.static-catalog.prepared.test.ts src/agents/btw.test.ts src/agents/model-suppression.test.ts src/agents/tools/image-tool.test.ts
    • 8 files / 372 tests passed on the current head.
    • A/B regressions cover alias normalization, suppression, manifest-static metadata, dynamic runtime hooks, concurrent generation isolation, metadata-only generations, /btw runtime auth and stream selection, and complete image policy composition.
    • Exact-head CI also exposed an older forward-compat suite whose prepared-runtime mock omitted required generation metadata; the fixture now models the complete runtime contract and all 32 tests pass.
  • pnpm check:changed passed on the rebased head.
  • pnpm build passed.
  • Autoreview passed with no accepted/actionable P0 findings.
  • Blacksmith Testbox tbx_01m09fw1gp8mp3yf742096594t passed both real QA Lab scenarios using qa-channel with mock-openai:
    • Plugin lifecycle hot reload
    • Image generation roundtrip
  • Testbox run: https://github.com/openclaw/openclaw/actions/runs/32096928603

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 18, 2026
@steipete
steipete marked this pull request as ready for review August 18, 2026 03:53
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 12:21 AM ET / 04:21 UTC.

ClawSweeper review

What this changes

Pins model resolution, provider auth and streaming, and image-policy lookup to the plugin generation prepared for each in-flight agent request.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for protected maintainer review: static inspection found no discrete patch defect, but the branch is behind and the supplied exact-head check matrix is still incomplete.

Priority: P2
Reviewed head: c53aad8cedbddc34accdd5a491c012be2f4b99b3
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-boundary repair and supplied integration proof are strong; current-main rebase verification remains the material merge gate.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR supplies a linked after-fix Testbox QA run for plugin lifecycle hot reload and image generation; redact sensitive details if refreshed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR supplies a linked after-fix Testbox QA run for plugin lifecycle hot reload and image generation; redact sensitive details if refreshed.
Evidence reviewed 8 items Canonical generation scope: The scope binds the prepared metadata snapshot and registry through async work, using an empty registry only for metadata-only generations.
Resolver owner boundary: Both synchronous and asynchronous model resolution execute through the prepared runtime generation scope when a prepared runtime is supplied.
BTW continuation coverage: The side-question flow enters the prepared generation scope before resolving harness, model, authentication, and stream behavior.
Findings None None.
Security None None.

How this fits together

Agent requests prepare a model runtime containing plugin metadata and registry state before provider routing. That state feeds model lookup, authentication, stream selection, and image preprocessing, which must remain consistent across a plugin reload.

flowchart LR
A[Admitted agent request] --> B[Prepared model runtime]
B --> C[Scoped plugin generation]
C --> D[Model resolution]
D --> E[Provider auth]
E --> F[Streaming response]
D --> G[Image compression policy]
Loading

Decision needed

Question Recommendation
Should the prepared-generation scope land after a rebase and green exact-head checks, or should maintainers request a narrower ownership boundary? Rebase and land after exact-head validation: Preserve the single scoped boundary and merge after a rebase produces green exact-head checks.

Why: The maintainer label requires explicit handling, and local current-main merge inspection was unavailable in this partial checkout.

Before merge

  • Resolve merge risk (P1) - The branch is behind current main, and this partial checkout could not inspect the resulting three-way merge; rebase and exact-head validation are needed before landing.
  • Resolve merge risk (P1) - The reported production delta is +19 net lines for a bug fix; the central scope is coherent, but maintainers should confirm it remains the smallest owner-boundary implementation after rebase.
  • Complete next step (P2) - Protected maintainer handling plus unavailable local current-main merge inspection require explicit maintainer sign-off, not an automated repair.
Agent review details

Security

None.

PR surface

Source +172, Tests +321, Other 0. Total +493 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 9 1096 924 +172
Tests 6 441 120 +321
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 3 0
Total 16 1540 1047 +493

Review metrics

Metric Value Why it matters
Production versus test delta production +19 net; tests/test support +474 net The added generation-scope ownership is small relative to its regression coverage, but positive bug-fix production growth still merits owner review.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/agents/btw.test.ts, vector/embedding metadata: src/agents/embedded-agent-runner/model.generation-scope.test-support.ts, vector/embedding metadata: src/agents/embedded-agent-runner/model.generation-scope.test.ts, vector/embedding metadata: src/agents/model-suppression.test.ts, vector/embedding metadata: src/agents/model-suppression.ts, vector/embedding metadata: src/agents/tools/image-tool.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Rebase and validate the exact head (recommended)
    Rebase onto current main and merge only when the post-rebase head completes its provider-routing checks successfully.
  2. Accept the scoped routing change
    A maintainer may accept the remaining provider-routing compatibility risk after reviewing the rebased model/auth/stream path.

Technical review

Best possible solution:

Keep one prepared-generation scope as the canonical model-routing boundary, then rebase it onto current main and land only after the resulting exact head is green.

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

No high-confidence current-main reproduction was run. The A/B generation fixtures clearly model the reload overlap, but this read-only partial checkout could not execute tests or resolve current main.

Is this the best way to solve the issue?

Yes, subject to rebase validation: carrying the prepared metadata and registry through the canonical resolver, BTW continuation, and image lookup removes the mixed-generation reads without adding configuration surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7e7b860bca54.

Labels

Label justifications:

  • P2: This is a bounded agent/provider consistency repair during plugin reloads, without evidence of an active emergency.
  • merge-risk: 🚨 auth-provider: The scoped path governs model routing and provider authentication across an in-flight request.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR supplies a linked after-fix Testbox QA run for plugin lifecycle hot reload and image generation; redact sensitive details if refreshed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies a linked after-fix Testbox QA run for plugin lifecycle hot reload and image generation; redact sensitive details if refreshed.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the current head and the related merged model-generation repairs cited by the PR; local history also shows sustained work on prepared model runtime and BTW paths. (role: recent generation-runtime contributor; confidence: high; commits: c53aad8cedbd, bb95d106d813, f77d2ec3a80b; files: src/agents/embedded-agent-runner/model.ts, src/agents/btw.ts, src/plugins/runtime/generation-scope.ts)
  • Vito Cappello: Recent history on the affected agent model and authentication neighborhood includes model/session routing fixes. (role: recent model/auth runtime contributor; confidence: medium; commits: 77d89b2fa843, 5621979a469a; files: src/agents/embedded-agent-runner/model.ts, src/agents/btw.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and let the resulting exact head finish green before merge.

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 (1 earlier review cycle)
  • reviewed 2026-08-18T04:02:13.450Z sha 662205f :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for current head c53aad8cedbddc34accdd5a491c012be2f4b99b3:

The +19 production-line delta is the shared generation-owner boundary: public resolver scoping, one lazy static-catalog fact, and complete /btw continuation scoping. The same change removes duplicate per-leaf catalog and image-policy lookup paths; further reduction would move or hide the ownership boundary rather than simplify it. No public config, protocol, persisted-state, or migration surface changes.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 18, 2026
@steipete
steipete merged commit d9b69c5 into main Aug 18, 2026
219 of 220 checks passed
@steipete
steipete deleted the steipete/model-generation-owner-refactor branch August 18, 2026 04:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
…#125569)

* fix(agents): pin model resolution to prepared generation

* test(agents): complete prepared runtime fixture
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 merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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