Skip to content

fix: New Session adopts discovered models - #129307

Merged
steipete merged 6 commits into
mainfrom
oc-92a.8/dynamic-catalog-convergence
Aug 25, 2026
Merged

steipete merged 6 commits into
mainfrom
oc-92a.8/dynamic-catalog-convergence

Conversation

@jalehman

@jalehman jalehman commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #124008

Related: #126013

Thanks @catsonkeyboard for the packaged-runtime report and @ekinnee for investigating the broader catalog convergence problem.

Root cause

Dynamic provider discovery completed in the prepared model-catalog owner, but the Gateway's cached chat-metadata projection and the browser's independent shared metadata cache both retained their original static snapshots. The original patch also conveyed full-catalog provenance through a manual boolean, imported authentication ownership from the catalog worker, and could misclassify a subordinate catalog publication as a top-level owner transition.

Architectural repair

  • Publish successful full-catalog completion as its own subordinate lifecycle event without claiming that every agent owner is ready.
  • Identify completed full catalogs through the existing producer-owned provenance marker, preserve their exact paired authentication generation in the existing auth owner, and fail closed if that pair is missing.
  • Rebuild configured wildcard projections from the completed catalog without initiating provider discovery in chat startup or ordinary metadata reads.
  • After an operator explicitly requests models.list, revalidate the existing per-agent browser metadata owner so Chat and New Session converge without copying rows, adding protocol fields, or introducing a parallel store.
  • Opening the New Session model picker now performs the same explicit, cooldown-bounded discovery as the existing Chat picker; background startup remains prepared-only.
  • Preserve availability/error behavior, stale-generation rejection, multiple-agent publication ownership, CLI-agent retries, and contributor credit.

The latest ClawSweeper wildcard finding is fixed at the canonical full-catalog provenance boundary and covered with real configured wildcard/auth facts. The old manual discovery flag and worker-owned auth coupling were removed.

Proof

  • Failing-before/passing-after Gateway regression: a configured OAuth-backed wildcard now exposes the newly discovered model rather than returning only its statically prepared sibling.
  • Failing-before/passing-after lifecycle regression: catalog publication during owner attachment no longer suppresses later owner refresh.
  • Failing-before/passing-after real Chromium flow: Chat discovers a model and its 262k context window, then New Session visibly renders the same discovered option.
  • Focused browser regression: both dynamic catalog and New Session CLI-agent recovery scenarios pass.
  • Independent structured review of both the maintainer delta and complete contributor branch found no actionable findings.
  • Personally inspected upstream Codex contract: codex-rs/app-server/src/request_processors/catalog_processor.rs:242, codex-rs/app-server/src/models.rs:34, codex-rs/core/src/thread_manager.rs:782, and codex-rs/app-server-protocol/src/protocol/v2/model.rs:89.

The browser proof uses a real Chromium browser with a mocked Gateway. A combined providers-on, non-minimal real Gateway/browser attempt was also tried twice, including an isolated single-provider bundled root, but Gateway startup exceeded this repository's 120-second test budget before browser navigation (146 seconds/2.44 GiB and 126 seconds/2.49 GiB). That attempt is not represented as live-provider proof.

@clawsweeper

clawsweeper Bot commented Aug 25, 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 gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 25, 2026, 5:58 PM ET / 21:58 UTC.

ClawSweeper review

What this changes

This PR propagates dynamically discovered provider models from the prepared catalog through Gateway metadata and the Control UI so New Session can display them after explicit picker discovery.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open. The branch remains a relevant candidate fix for the New Session discovery gap, but its new picker refresh can turn an already usable static catalog into “Models unavailable” when models.list fails; fix that regression before merge.

Priority: P1
Reviewed head: 9987b93afa905ceb9723eb33750a31549a4d7dc8

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The branch has focused lifecycle and browser coverage, but a concrete ready-state regression blocks merge.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its attached Chromium evidence uses a mocked Gateway and does not replace the required direct Codex contract review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its attached Chromium evidence uses a mocked Gateway and does not replace the required direct Codex contract review.
Evidence reviewed 7 items New picker failure path: The changed ready-state branch requests a refresh with rejection enabled, then changes the existing metadata snapshot to an error state if the request fails.
Existing ready-snapshot contract: The established New Session regression keeps two existing options selectable after a metadata refresh fails, demonstrating that a transport failure must not erase a ready catalog.
Current-main comparison: Current main only retries picker catalogs after an error; it does not run a full discovery from the ready metadata state, so the error-state transition is introduced by this branch.
Findings 1 actionable finding [P1] Keep the ready catalog when discovery fails
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

$ node scripts/run-node.mjs --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 99.90 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 13.3s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4129ms (slowest: built plugin control-plane loads 3376ms)

OpenClaw 2026.8.1 (9987b93) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|warn|info|debug|trace)
  --no-color           Disable ANSI colors
  --profile ‹name›     Use a named profile (isol
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

Prepared model catalogs supply Gateway chat metadata and configured model listings. The Control UI keeps a shared metadata cache for each agent, which New Session uses to render its model picker.

flowchart LR
  A[Provider discovery] --> B[Prepared model catalog]
  B --> C[Gateway metadata lifecycle]
  B --> D[Configured model listing]
  C --> E[Browser metadata cache]
  D --> E
  E --> F[New Session picker]
Loading

Before merge

  • Keep the ready catalog when discovery fails (P1) - loadModels rejects on a models.list failure and this catch changes already-ready metadata to error. The error renderer hides every existing option, so a transient provider-discovery failure after opening the picker prevents selecting the static models that were usable immediately before. Preserve the ready snapshot/fallback and cover that sequence.
  • Resolve merge risk (P1) - The bug-fix diff adds production +77/-34 (net +43); first remove the new error-state regression rather than retaining a second failure path for ready metadata.
  • Resolve merge risk (P1) - The changed auth-generation path is compatibility-sensitive, and the asserted Codex catalog contract still needs direct source inspection before a merge recommendation.
  • Complete next step (P2) - The UI failure path has a narrow mechanical repair and a focused existing test boundary; the maintainer label keeps its application human-supervised.

Findings

  • [P1] Keep the ready catalog when discovery fails — ui/src/pages/new-session/model-control.ts:342-348
Agent review details

Security

None.

PR surface

Source +43, Tests +246. Total +289 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 10 77 34 +43
Tests 12 281 35 +246
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 358 69 +289

Review metrics

Metric Value Why it matters
Production versus regression coverage production +77/-34 (net +43); tests +281/-32 (net +249) This bug-fix adds lifecycle, auth-pairing, and UI refresh behavior, so preserving the existing ready-state failure invariant is essential before accepting the production growth.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/gateway/server-chat-metadata-lifecycle.test.ts, unknown-data-model-change: src/gateway/server-methods/chat-metadata-runtime.test.ts, unknown-data-model-change: src/gateway/server-methods/chat-metadata-runtime.ts, vector/embedding metadata: src/agents/embedded-agent-runner/model-resolution-consistency.test.ts, vector/embedding metadata: src/gateway/server-chat-metadata-lifecycle.test.ts, vector/embedding metadata: src/gateway/server-methods/chat-metadata-runtime.test.ts, and 6 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #124008
Summary: This PR is a candidate fix for the canonical New Session dynamic-model discovery issue; its remaining defect is within that same consumer path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Preserve the ready catalog on discovery failure (recommended)
    Keep the existing metadata snapshot and its model choices usable when the picker-triggered models.list refresh rejects, and add focused regression coverage.
  2. Pause for contract verification
    Do not merge until the direct Codex catalog contract cited by the PR can be independently inspected.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve the ready New Session catalog when picker discovery fails; add a regression that confirms static choices remain selectable after a rejected models.list refresh.

Technical review

Best possible solution:

Keep the ready New Session metadata selectable when explicit discovery fails, add that regression coverage, then complete the direct Codex contract check before merging.

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

Yes—source-reproducible: start with ready chat metadata, open the picker, and make models.list reject; the changed catch moves the control to the error renderer, which hides the existing options.

Is this the best way to solve the issue?

No. The safest repair is to retain the ready metadata snapshot on discovery failure, matching the existing stale-metadata refresh contract rather than treating an optional discovery error as catalog loss.

Full review comments:

  • [P1] Keep the ready catalog when discovery fails — ui/src/pages/new-session/model-control.ts:342-348
    loadModels rejects on a models.list failure and this catch changes already-ready metadata to error. The error renderer hides every existing option, so a transient provider-discovery failure after opening the picker prevents selecting the static models that were usable immediately before. Preserve the ready snapshot/fallback and cover that sequence.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: Opening New Session’s picker can make an already usable model catalog unavailable after a transient discovery failure.
  • add merge-risk: 🚨 compatibility: The new default picker action can replace existing static model choices with an error state.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • remove P2: Current review triage priority is P1, so this older priority label is no longer current.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: Opening New Session’s picker can make an already usable model catalog unavailable after a transient discovery failure.
  • merge-risk: 🚨 compatibility: The new default picker action can replace existing static model choices with an error state.
  • merge-risk: 🚨 auth-provider: Gateway projection now consumes the full catalog’s paired authentication generation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its attached Chromium evidence uses a mocked Gateway and does not replace the required direct Codex contract review.

Evidence

Acceptance criteria:

  • [P1] pnpm test ui/src/pages/new-session/model-control.metadata-lifecycle.test.ts.
  • [P1] pnpm test ui/src/lib/model-catalog-store.test.ts.
  • [P1] pnpm test ui/src/e2e/new-session-page.model-catalog.e2e.test.ts.

What I checked:

Likely related people:

  • steipete: Current blame assigns the changed picker path to this revision, and feature history shows repeated New Session and chat-metadata repairs. (role: recent feature owner and current revision author; confidence: high; commits: 9987b93afa90, 475d20a03473, 872230be91cc; files: ui/src/pages/new-session/model-control.ts, src/gateway/server-methods/chat-metadata-runtime.ts)
  • hixvac: Recent history includes the New Session missing-catalog-owner recovery in the same metadata lifecycle area. (role: adjacent owner; confidence: medium; commits: 33744584f38f; files: src/gateway/server-methods/chat-metadata-runtime.ts)

Rank-up moves

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

  • Preserve ready static models when explicit discovery rejects and add the focused UI regression.
  • Independently inspect the Codex catalog contract cited by the PR before a merge recommendation.

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-08-25T12:23:06.187Z sha 7e0eaa2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T13:05:41.620Z sha 7e0eaa2 :: needs changes before merge. :: [P2] Mark the completed preload as fully discovered

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 25, 2026
@steipete
steipete force-pushed the oc-92a.8/dynamic-catalog-convergence branch from 7e0eaa2 to 8add163 Compare August 25, 2026 20:29
@steipete
steipete requested a review from a team as a code owner August 25, 2026 20:29
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M and removed size: S labels Aug 25, 2026
@steipete

Copy link
Copy Markdown
Contributor

Maintainer follow-up: the PR now repairs both independent cache owners instead of stopping at the Gateway projection.

The prepared-catalog producer publishes completed discovery with its exact paired auth generation; configured wildcard views consume that producer-owned provenance; and explicit Chat/New Session picker discovery refreshes the existing shared browser metadata store. Startup remains prepared-only, subordinate publication cannot pretend every agent owner is ready, stale auth fails closed, and the previous worker-owned auth coupling/manual full-catalog flag are gone.

The first image shows the initial prepared-only Chat state. The second shows the same account-discovered model visibly available in New Session with its discovered 262k context window. The attached recording covers Chat discovery, updated reasoning controls, navigation into New Session, and the visible discovered model. These are real Chromium captures with a deterministic mocked Gateway.

The originally failing Chromium assertion is now green, both relevant browser suites pass (5 scenarios), and the real non-minimal Gateway RPC/owner-boundary shard passes (7 files, 52 tests). Independent review of the complete rewritten branch reported no actionable findings.

Prepared-only Chat before discovery

Discovered model visible in New Session

[email protected]

@steipete
steipete force-pushed the oc-92a.8/dynamic-catalog-convergence branch from 370a28e to 9987b93 Compare August 25, 2026 21:52
@clawsweeper clawsweeper Bot added 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. and removed P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 25, 2026
@steipete
steipete merged commit 3f6f679 into main Aug 25, 2026
345 of 357 checks passed
@steipete
steipete deleted the oc-92a.8/dynamic-catalog-convergence branch August 25, 2026 22:33
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
* oc-92a.8: converge dynamic chat metadata catalog

* fix(gateway): converge discovered model catalogs across sessions

Co-authored-by: Josh Lehman <[email protected]>

* test(gateway): satisfy deferred helper lint

* test(ui): bind model discovery proof to the active route

* chore: keep release notes in pull request metadata

* test(agents): preserve plugin metadata scope in model fixtures

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. 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. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: New Session model picker omits dynamically discovered providers from chat.metadata

2 participants