Skip to content

fix: keep plugin catalogs intact after discovery timeouts - #140441

Merged
shakkernerd merged 2 commits into
mainfrom
fix/catalog-late-result
Sep 6, 2026
Merged

shakkernerd merged 2 commits into
mainfrom
fix/catalog-late-result

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139951

What Problem This Solves

Fixes an issue where a later model discovery could lose catalog data when a plugin returned a stateful result after an earlier discovery deadline. After failed OAuth preparation, host finalization could still consume an abandoned provider result; outcome getters were also read after the hook returned late.

Why This Change Was Made

Carry the catalog owner's existing activity check to the first reader after the awaited hook, and recheck it before finalization. This covers provider, providers, and outcomes without changing plugin-facing callbacks or cancelling an admitted hook or credential refresh.

User Impact

Timed-out discovery no longer drains plugin-owned results before a later accepted discovery. Timely results, multi-provider outcomes, and credential rotation completion keep their existing behavior. The regression is reproduced with a supported synthetic plugin; no affected bundled plugin has been identified.

Evidence

  • Real resolveImplicitProviders composition: the unfixed path consumed a stateful getter after timeout and left the next discovery empty. The fixed path leaves all three result shapes unread after timeout and consumes them once on the next accepted call.
  • On deae51804cfe4a1a57fb87af08ac02be4897d0b9, 94 affected tests passed remotely in 72.07 seconds, including the six lifecycle cases, multiple-provider outcomes, failure retention, successful-empty recovery, and admitted credential refresh persistence. Both CI planner regressions also passed, with the existing 80-job limit unchanged.
  • Final root types and targeted lint passed remotely. The complete changed-path gate passed on the byte-identical production and documentation revision. Independent P2 review of the production change and test relocation found no actionable issues.
  • A built Gateway comparison used three real gateway call models.list requests per arm: refresh through the deadline, a prepared read after releasing the held hook, and a second refresh. Both revisions used isolated synthetic state, the same plugin, and the same request sequence.
Gateway observation Base e1c1bc37c77 Fixed deae51804cf
Late provider getter reads 1 0
Late outcomes getter reads 1 0
Account-only model rows on next refresh 0 1
Stored credential records Unchanged Unchanged

The fixture deliberately fails OAuth preparation, so inventory recovery does not imply executable credentials. Both Gateway processes, temporary state, and local fixture servers were cleaned up. The final remote test/type/build/command sequence exited successfully in 4 minutes 38 seconds.

Exact-head CI passed. ClawSweeper reviewed the same head at Platinum with no findings.

The reproduced contract is inside a custom plugin hook; there is no identified bundled-plugin UI reproduction. Browser fixtures containing already-serialized catalog rows cannot exercise its getters. The real Gateway/CLI comparison is the primary runtime evidence for this lifecycle boundary.

@clawsweeper

clawsweeper Bot commented Sep 6, 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 docs Improvements or additions to documentation agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 6, 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 5:42 PM ET / 21:42 UTC.

ClawSweeper review

What this changes

Prevent expired model-discovery runs from consuming plugin-owned catalog results, with regression coverage and documentation of late-result handling.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded fix: current main still consumes late plugin results at both identified boundaries. No actionable correctness or security findings remain, and the supplied Gateway comparison supports the repair.

Priority: P2
Reviewed head: deae51804cfe4a1a57fb87af08ac02be4897d0b9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with relevant Gateway evidence, meaningful regression coverage, and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied built-Gateway comparison exercises the changed discovery owner through real models.list requests: an expired hook leaves getters unread, and the next refresh recovers the model with unchanged credentials. The six source-level cases supplement this runtime evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied built-Gateway comparison exercises the changed discovery owner through real models.list requests: an expired hook leaves getters unread, and the next refresh recovers the model with unchanged credentials. The six source-level cases supplement this runtime evidence.
Evidence reviewed 7 items Current main still has the finalization gap: At the fetched main revision, the timeout owner checks activity before invoking the catalog, but calls finalization after the awaited catalog without another check. Finalization reads provider getters when OAuth preparation failed.
Current main also reads late outcomes: The catalog runner reads outcomes immediately after the plugin hook resolves, before the existing report callback can reject expired publication. Suppressing the callback alone cannot prevent a stateful getter from being consumed.
Introduced repair preserves the existing boundary: The verified merge-base-to-head diff carries the existing owner activity predicate to outcome extraction and rechecks activity before finalization. The predicate is not added to the plugin hook context; credential selection, refresh persistence, settings, schemas, and dependencies are unchanged.
Findings None None.
Security None None.

How this fits together

Model discovery combines plugin catalogs with configured providers to build OpenClaw’s model inventory. Its timeout owner must discard expired results without consuming data that a later discovery can use.

flowchart TD
  A[Model refresh request] --> B[Prepare provider credentials]
  B --> C[Run plugin catalog hook]
  C --> D{Discovery still active?}
  D -->|Yes| E[Read outcomes and finalize catalog]
  E --> F[Publish model inventory]
  D -->|No| G[Discard result without reading getters]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +7, Tests +162, Docs +4. Total +173 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 8 1 +7
Tests 1 162 0 +162
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 174 1 +173

Review metrics

None.

Technical review

Best possible solution:

Keep result consumption within the existing discovery lifetime while allowing already-admitted credential refreshes to complete safely.

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

Yes: current-main source exposes both late getter reads, and the supplied baseline Gateway comparison reproduces the subsequent empty catalog. This read-only review did not execute the scenario.

Is this the best way to solve the issue?

Yes: checking the existing lifetime before each post-await consumer fixes the cause without changing plugin callbacks, timeout policy, or credential persistence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7921ec48f82d.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied built-Gateway comparison exercises the changed discovery owner through real models.list requests: an expired hook leaves getters unread, and the next refresh recovers the model with unchanged credentials. The six source-level cases supplement this runtime evidence.

Label justifications:

  • P2: This repairs a source-proven catalog lifecycle defect reproduced with a supported synthetic plugin, without evidence of an urgent bundled-provider outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied built-Gateway comparison exercises the changed discovery owner through real models.list requests: an expired hook leaves getters unread, and the next refresh recovers the model with unchanged credentials. The six source-level cases supplement this runtime evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied built-Gateway comparison exercises the changed discovery owner through real models.list requests: an expired hook leaves getters unread, and the next refresh recovers the model with unchanged credentials. The six source-level cases supplement this runtime evidence.

Evidence

What I checked:

  • Current main still has the finalization gap: At the fetched main revision, the timeout owner checks activity before invoking the catalog, but calls finalization after the awaited catalog without another check. Finalization reads provider getters when OAuth preparation failed. (src/agents/models-config.providers.implicit.ts:384, 7921ec48f82d)
  • Current main also reads late outcomes: The catalog runner reads outcomes immediately after the plugin hook resolves, before the existing report callback can reject expired publication. Suppressing the callback alone cannot prevent a stateful getter from being consumed. (src/plugins/provider-discovery.ts:182, 7921ec48f82d)
  • Introduced repair preserves the existing boundary: The verified merge-base-to-head diff carries the existing owner activity predicate to outcome extraction and rechecks activity before finalization. The predicate is not added to the plugin hook context; credential selection, refresh persistence, settings, schemas, and dependencies are unchanged. (src/plugins/provider-discovery.ts:183, deae51804cfe)
  • Regression coverage exercises consecutive discoveries: Six cases cover timely and expired provider, providers, and outcomes results through resolveImplicitProviders. The expired cases release the held hook, assert zero getter reads, then verify a subsequent discovery consumes the preserved result once. Existing cases also cover admitted credential rotation and fallback behavior. Tests were inspected, not executed during this review. (test/openai-model-discovery-auth-order.test.ts:713, deae51804cfe)
  • Real Gateway comparison: The supplied complete PR body, captured under sourceRevision fade102ea56e0bcc90978c8c93f071fd1e8baed2ffb8f9e91c3523b000e8f734, records three real gateway call models.list requests per arm using isolated synthetic state and a held plugin hook. Compared with the pinned baseline, the reviewed head reduced late provider/outcome getter reads from one to zero and restored one account-only model on the next refresh, with unchanged credential records. This is runtime evidence for the changed catalog boundary, not a bundled-plugin UI claim. (deae51804cfe)
  • Related merged work is complementary: The supplied GitHub context verifies fix: preserve models when OAuth preparation fails #139951 merged as 33da4e2. It preserves inventory after OAuth preparation failure; this PR addresses late result consumption that remains in current main. Current-main history also identifies Shakker’s related timeout work and Peter Steinberger’s catalog maintenance. (src/agents/models-config.providers.implicit.ts, 33da4e237c16)

Likely related people:

  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: 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 (2 earlier review cycles)
  • reviewed 2026-09-06T20:54:17.646Z sha 9d1acbd :: needs maintainer review before merge. :: none
  • reviewed 2026-09-06T21:23:28.514Z sha deae518 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 6, 2026
@shakkernerd shakkernerd self-assigned this Sep 6, 2026
@shakkernerd
shakkernerd merged commit 8aad170 into main Sep 6, 2026
181 checks passed
@shakkernerd
shakkernerd deleted the fix/catalog-late-result branch September 6, 2026 21:56
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: timed-out catalog runs no longer consume provider results needed by subsequent discovery.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* commit '294df333c58f2da104eccffc623ccb3c4d43d4d8': (1802 commits)
  fix: clear stale diagnostics after Gateway changes (#140426)
  fix: keep plugin catalogs intact after discovery timeouts (#140441)
  perf(tui): prepare session picker rows once per overlay (#140462)
  refactor(config): reuse environment substitution for write-back (#140460)
  refactor(discord): remove retired auto-presence templates (#140463)
  fix(ui): finish roster refreshes during session activity (#140459)
  fix(setup): match prepared credentials to the model provider (#140461)
  fix: keep MiniMax discovery on the selected credential (#140438)
  refactor(tests): remove unused parent context cache reset (#140456)
  fix: avoid repeated xAI OAuth refresh during discovery (#140434)
  perf(routing): reuse prepared event session targets (#140454)
  fix(media): keep deferred audio and extraction providers discoverable (#139231)
  refactor(codex): remove redundant app-server forwarding (#140451)
  fix(test): avoid false native polling timeouts (#140119)
  test(gateway): retain saved source in reload fixtures (#140453)
  fix(gateway): reduce repeated model work when listing sessions (#140414)
  fix(feishu): fall back to post mode over table limit (#136382)
  fix: use the bundle-compatible Proxyline runtime under Bun (#140411)
  refactor(trace): reuse the canonical usage counter type (#140444)
  refactor(node-host): share execution policy result fields (#140446)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…40441)

Discard provider catalog results after their discovery run expires, preserving subsequent refreshes and existing credential-refresh persistence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR 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: 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