Skip to content

fix(models): wait for standalone catalog refresh before listing - #149752

Merged
obviyus merged 4 commits into
mainfrom
fix/models-list-discovery-projection
Sep 16, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/models-list-discovery-projection

Conversation

@obviyus

@obviyus obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Related: #149472

What Problem This Solves

Without a Gateway, models list --refresh could exit with no discovered rows after a successful proxy response.

Why This Change Was Made

The decision whether refresh can outlive its caller is made by exactly one mechanism at src/agents/prepared-model-runtime.catalog-access.ts:658; this state has one writer. Gateway refresh keeps its bounded wait. catalog-access.ts +5 lines; build.ts -1.

Growth accepted under the owner's standing acceptance (2026-09-15).

User Impact

The command prints completed discovery instead of silently returning an earlier catalog.

Evidence

openclaw models list --provider litellm --refresh --json: before, one GET /v1/models returned 200 but JSON had zero rows; after, one GET returned 200 and JSON listed the returned row. Twenty CLI tests and the Gateway pending control pass after merging main. Authored and unrelated provider JSON is byte-identical; failures warn.

Compatibility

No JSON, SDK, or configuration change. The separate onboarding seed restriction needs its follow-up fix.

Consumers

Standalone catalog refresh callers wait for completion. Gateway and ordinary reads keep existing behavior.

Invalidation

Existing refresh, discovery deadlines, and owner replacement rules remain in place.

Tests

Held discovery fails with the old behavior and passes with the fix. The existing Gateway control still returns pending before discovery completes.

@clawsweeper

clawsweeper Bot commented Sep 16, 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 commands Command implementations agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:46 AM ET / 06:46 UTC (Revision 3).

ClawSweeper review

What this changes

Explicit standalone model-catalog refreshes now finish discovery before printing results, with a regression test covering discovery that exceeds five seconds.

Merge readiness

✅ Ready for maintainer review

This focused fix remains necessary on the inspected main revision. No blocking correctness or security defect was found; the related LiteLLM fixes address separate problems.

Priority: P2
Reviewed head: 2f37f626662c5bb95db478c87d8cdd36c752ad39

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-level repair with relevant before/after observations and meaningful regression coverage.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body reports before/after execution of models list --provider litellm --refresh --json against a real proxy: successful discovery changes from zero displayed rows to the returned model. This exercises the changed standalone catalog wait; held-worker and Gateway controls provide supplemental coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports before/after execution of models list --provider litellm --refresh --json against a real proxy: successful discovery changes from zero displayed rows to the returned model. This exercises the changed standalone catalog wait; held-worker and Gateway controls provide supplemental coverage.
Evidence reviewed 10 items Introduced behavior: The pinned introduced diff adds a standalone-and-refresh condition before the existing foreground race. Acquisition, publication checks, and Gateway behavior remain under the existing owner.
Production entrypoint and owner propagation: The no-Gateway CLI requests writable full refresh before projecting rows. Standalone activation supplies provenance="standalone", and publication passes the actual inventory owner into the catalog builder.
Existing documented contract: The CLI documentation says explicit refresh acquires provider inventory before listing; ordinary standalone reads do not initiate discovery.
Findings None None.
Security None None.

How this fits together

The model catalog combines configured models with provider discovery and supplies model listings. Standalone CLI commands must finish discovery before exiting, while the long-running Gateway can publish results after its foreground response.

flowchart TD
  A[Model list refresh] --> B{Catalog owner}
  B -->|Standalone CLI| C[Wait for discovery]
  B -->|Gateway| D[Bounded foreground wait]
  C --> E[Publish discovered inventory]
  D --> E
  E --> F[Project model rows]
  F --> G[Display model list]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +4, Tests +163. Total +167 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 7 3 +4
Tests 1 163 0 +163
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 170 3 +167

Review metrics

None.

Technical review

Best possible solution:

Keep completion waiting in the shared catalog owner for explicit standalone refreshes while preserving bounded Gateway responses and existing discovery deadlines.

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

Yes, from source: with no Gateway and discovery taking over five seconds, current main can print the earlier catalog before discovery finishes. The added held-worker regression exercises that path; this review did not execute it.

Is this the best way to solve the issue?

Yes. The change uses the existing owner's lifecycle distinction, avoiding a second discovery implementation or CLI polling loop while preserving Gateway behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs misleading empty results from explicit standalone model discovery with a bounded CLI impact.
  • 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 captured body reports before/after execution of models list --provider litellm --refresh --json against a real proxy: successful discovery changes from zero displayed rows to the returned model. This exercises the changed standalone catalog wait; held-worker and Gateway controls provide supplemental coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports before/after execution of models list --provider litellm --refresh --json against a real proxy: successful discovery changes from zero displayed rows to the returned model. This exercises the changed standalone catalog wait; held-worker and Gateway controls provide supplemental coverage.

Evidence

What I checked:

  • Introduced behavior: The pinned introduced diff adds a standalone-and-refresh condition before the existing foreground race. Acquisition, publication checks, and Gateway behavior remain under the existing owner. (src/agents/prepared-model-runtime.catalog-access.ts:656, 2f37f626662c)
  • Production entrypoint and owner propagation: The no-Gateway CLI requests writable full refresh before projecting rows. Standalone activation supplies provenance="standalone", and publication passes the actual inventory owner into the catalog builder. (src/commands/models/list.list-command.ts:118, 2f37f626662c)
  • Existing documented contract: The CLI documentation says explicit refresh acquires provider inventory before listing; ordinary standalone reads do not initiate discovery. Public docs: docs/cli/models.md. (docs/cli/models.md:161, 2f37f626662c)
  • Still necessary on main: The inspected main implementation still races every catalog acquisition against the five-second foreground timer, without the standalone exception. (src/agents/prepared-model-runtime.catalog-access.ts:655, ce9e84331014)
  • Lifecycle and timeout safeguards: Discovery retains its existing 180-second worker deadline, generation checks, cancellation, and worker retirement. The patch changes waiting behavior without changing credentials, authorization, stored formats, or plugin APIs. (src/agents/prepared-model-catalog-worker.ts:113, 2f37f626662c)
  • Behavior proof and regression coverage: The captured PR body reports the real CLI against a proxy: one successful GET returned zero displayed rows before the fix and the returned row afterward. It also reports unchanged authored/provider JSON and passing Gateway pending controls. The added test calls modelsListCommand with a real catalog worker, holds discovery beyond five seconds, then verifies the discovered JSON row. Tests were inspected, not executed during this read-only review. (src/commands/models/list.refresh-completion.test.ts:119, 2f37f626662c)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 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 (2 earlier review cycles)
  • reviewed 2026-09-16T06:00:53.754Z sha ff75bae :: needs changes before merge. :: none
  • reviewed 2026-09-16T06:25:14.139Z sha ff75bae :: needs maintainer review before merge. :: none

@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 149752
head: ff75bae
scope: owner-review

@obviyus
obviyus marked this pull request as ready for review September 16, 2026 06:08
@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 149752
head: 2f37f62
scope: owner-review

@obviyus
obviyus merged commit e50497e into main Sep 16, 2026
187 checks passed
@obviyus
obviyus deleted the fix/models-list-discovery-projection branch September 16, 2026 07:05
@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

Proof: A standalone models list --refresh --json against a local proxy now prints the discovered rows after a successful response. Authored rows and unrelated provider output remain unchanged; failed discovery reports a warning.

  • Bug: The command could exit before discovery completed and print an empty list.
  • Fix: Standalone refresh waits for discovery to finish. Gateway refresh keeps its existing bounded wait.
Before After
Successful discovery could produce zero rows. Completed discovery appears in the command output.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…claw#149752)

Related: openclaw#149472

## What Problem This Solves

Without a Gateway, `models list --refresh` could exit with no discovered rows after a successful proxy response.

## Why This Change Was Made

The decision `whether refresh can outlive its caller` is made by exactly one mechanism at `src/agents/prepared-model-runtime.catalog-access.ts:658`; this state has one writer. Gateway refresh keeps its bounded wait. `catalog-access.ts` +5 lines; `build.ts` -1.

Growth accepted under the owner's standing acceptance (2026-09-15).

## User Impact

The command prints completed discovery instead of silently returning an earlier catalog.

## Evidence

`openclaw models list --provider litellm --refresh --json`: before, one GET `/v1/models` returned 200 but JSON had zero rows; after, one GET returned 200 and JSON listed the returned row. Twenty CLI tests and the Gateway pending control pass after merging main. Authored and unrelated provider JSON is byte-identical; failures warn.

## Compatibility

No JSON, SDK, or configuration change. The separate onboarding seed restriction needs its follow-up fix.

## Consumers

Standalone catalog refresh callers wait for completion. Gateway and ordinary reads keep existing behavior.

## Invalidation

Existing refresh, discovery deadlines, and owner replacement rules remain in place.

## Tests

Held discovery fails with the old behavior and passes with the fix. The existing Gateway control still returns pending before discovery completes.

Co-authored-by: Ayaan Zaidi <[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 commands Command implementations 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