Skip to content

fix(models): relist provider model lists older than 15 minutes on picker reads - #200988

Merged
obviyus merged 1 commit into
mainfrom
fix/model-listing-max-age
Nov 18, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/model-listing-max-age

Conversation

@obviyus

@obviyus obviyus commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

A model that a provider launches does not appear in the Gateway model picker until the Gateway restarts, its config or credentials change, the next 6-hourly hosted catalog revision is adopted, or the user presses Refresh. Example: OpenAI launched gpt-6.2-astra and gpt-6.2-sol on 2026-11-17. Typed openai/gpt-6.2-sol turns worked on every release, but the picker kept the OpenAI listing saved before the launch.

Cause: #167008 stopped ordinary models.list reads from renewing an expired provider listing, because that expiry was the provider's 60-second HTTP response-cache TTL and almost every picker open rebuilt the catalog. Nothing replaced it, so a saved live listing never ages on its own.

Why This Change Was Made

  • A successful live listing now expires at the later of its response-cache deadline and 15 minutes after acquisition (discoveryDeadline). The floor keeps short TTLs from renewing on almost every read (perf(models): keep inventory reads on published catalogs #167008). A longer TTL still wins (fix(models): avoid needless ClawRouter catalog refreshes #168050, ClawRouter's one hour), so the expiry relist, which honors each feed's cache, always reaches the provider instead of re-stamping a cached response as fresh.
  • models.list calls the catalog owner's existing refreshExpiredModelCatalog, which relists only expired providers in the background. The read returns the published rows at once; open pickers update through the existing catalog publication push.
  • Expiry and failed-discovery retry relists no longer mark providers pending. They revalidate rows the user already sees, so pickers show no loading state and chat /models adds no checking models… line for them. First sign-in, changed credentials and explicit Refresh still report progress.
  • The listing still decides which models a signed-in provider shows (fix(openai): prevent onboarding from offering unavailable account models #114356). This change only keeps that listing fresh.

Accepted cost: at most one background relist per live-listed provider per 15 minutes (or per its cache TTL, when longer), and only while someone opens a picker. Providers whose listing is not retained in the live response cache (ttlMs: 0, self-hosted discovery) keep the previous behavior.

User Impact

A newly launched provider model appears in the picker within about 15 minutes of the provider listing it, on the first picker open, with no restart, no Refresh, no loading indicator and no OpenClaw release.

Evidence

  • Regression (vitest-source): models-list.freshness.integration.test.ts keeps the real live response cache (500 ms TTL, no cache clearing). It asserts that the listing ages out on the 15-minute floor rather than the short TTL, and that an ordinary models.list read on an aged listing serves saved rows with no pendingProviders, relists once in the background, then publishes the new model. Fails on merge base e235b2b983b6 (3/3, deadline equals the cache TTL); the no-pending assertion also fails on this PR's previous head 41ee4d30 (3/3, provider listed as pending); passes on this head (3/3).

  • Renewal contract (vitest-source): server-chat-metadata-lifecycle.catalog-renewal.test.ts now asserts that an expiry renewal never publishes a pending provider and that settling it sends only the real catalog change, with no refresh-status broadcast. An explicit refresh in the same file still reports refresh status.

  • E2E, CLI reads (fix: source tier; base: e235b2b983b6 dist-nodts): two isolated Gateways, each with a fake LiteLLM proxy as its live listing and hosted catalog refresh disabled. At 04:03:46Z each proxy starts listing fake-2; an ordinary gateway call models.list (no refresh) runs once a minute.

    Time (UTC) Fix Gateway picker Base Gateway picker
    04:03:41 (before) fake-1 fake-1
    04:04 to 04:17 fake-1 fake-1
    04:18:58 fake-1, fake-2 fake-1
    04:23:58 fake-1, fake-2 fake-1

    Proxy request logs: the fix Gateway listed at startup and once more at 04:17:58, the first read after the listing aged; no other requests. The base Gateway never listed again.

  • E2E, Control UI (dist-nodts, real browser): this head and the previous head 41ee4d30, each with a fake LiteLLM listing whose /models response is held for 25 s after a new model is added. The picker is opened once the listing aged (proxy logs show the relist request at that moment), then again after release. During the relist both pickers render the saved models immediately with no loading state; the new model appears after the relist publishes. The visible difference from the previous head is the pending flag (pendingProviders, and chat /models checking models…), which the tests above pin as absent. Screenshots: fix(models): relist provider model lists older than 15 minutes on picker reads #200988 (comment)

  • Affected suites (vitest-source, exact head): freshness, renewal, worker recovery, publication events, auth-login catalog, prepared-runtime sources, native picker failures and configured catalog index: 52 tests across 5 shards pass.

  • Review and CI: local ClawSweeper review (gpt-6.1-sol) on 3fd0cae6 found no issues; required CI is green on the same head.

@clawsweeper

clawsweeper Bot commented Nov 18, 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 gateway Gateway runtime agents Agent runtime and tooling size: S labels Nov 18, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes ordinary model-picker reads trigger background renewal of expired provider listings after a minimum of 15 minutes.

Example: A provider initially lists fake-1, then starts advertising fake-2.

  • Before: Ordinary models.list requests continue returning fake-1 until another refresh trigger occurs.
  • After: The first read after the listing deadline returns saved rows immediately and starts background discovery, which publishes fake-1 and fake-2.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with supplied production-entry-point comparison, meaningful Gateway regression coverage, and no actionable findings; current-head CI is still pending.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied base/candidate Gateway RPC observations exercise real elapsed listing age against an HTTP LiteLLM endpoint: saved rows remain available, the candidate performs one subsequent listing request, and fake-2 appears while the base remains unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Newly advertised provider models can remain absent from the picker until manual Refresh or another catalog lifecycle event.
Reason: The bounded automatic-renewal policy has maintainer direction through authorship, preserves responsive reads, and addresses the short-TTL rebuild concern behind the earlier passive-read design.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a focused, supported freshness improvement that current main lacks, with no actionable correctness or security findings.

Priority: P2
Reviewed head: 41ee4d30f346358264183e28acec2f3ef5ef58c6

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway model-list handler reads published catalogs from the prepared model runtime, whose existing inventory owner acquires provider listings and publishes updated picker rows.

flowchart LR
  A[Model picker or CLI] --> B[Gateway models list]
  B --> C[Prepared catalog owner]
  C --> D[Published model rows]
  D --> A
  C --> E[Expiry check]
  E --> F[Provider discovery worker]
  F --> C
Loading

Technical review

Best possible solution:

Keep renewal in the existing catalog owner, using the shared 15-minute floor while preserving longer provider lifetimes and immediate explicit Refresh.

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

Current-main source establishes the passive-read limitation, and the supplied isolated Gateway comparison demonstrates it through ordinary models.list calls; this review executed no target code.

Is this the best way to solve the issue?

The patch is the smallest complete implementation using existing owners: it changes the shared successful deadline, invokes existing renewal, updates the established Gateway regression, and documents the policy.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Ordinary Gateway inventory reads changes intended behavior with a stated reason (cd8b5d3: Avoid repeated catalog rebuilds caused by short response-cache TTLs, while retaining explicit Refresh and SDK renewal.)
  • Successful deadlines and failed-discovery backoff changes intended behavior with a stated reason (eea11f9: Retry failed discovery without requiring reader activity and retain successful provider cache deadlines; this PR changes only the successful deadline policy.)
  • Longer provider response-cache lifetimes keeps the original intent (2a17573: Avoid needless ClawRouter discovery while preserving immediate explicit refresh and feed-specific cache lifetimes.)
  • Nonblocking native discovery keeps the original intent (94223e1: Return prepared picker rows while optional native discovery completes independently.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a825abb adds src/agents/prepared-model-runtime.discovery-retry.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a825abb1fae4; files: src/agents/prepared-model-runtime.discovery-retry.ts)
  • Ayaan Zaidi: Raw commit eea11f9 adds src/agents/prepared-model-runtime.discovery-retry.ts:12 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: eea11f9739d9; files: src/agents/prepared-model-runtime.discovery-retry.ts)
  • Vincent Koc: Raw commit 625945b adds src/gateway/server-methods/models.ts:122 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 625945b7ae01; files: src/gateway/server-methods/models.ts)

PR surface

Source +9, Tests -4, Docs +5. Total +10 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 12 3 +9
Tests 1 19 23 -4
Docs 2 16 11 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 47 37 +10

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Successful-listing renewal floor 15 minutes The shared deadline affects Gateway reads and expiry-driven SDK getters; longer provider cache lifetimes still win.

Labels

Label changes:

  • add P2: Automatic catalog freshness improves model discovery, while explicit Refresh already provides an in-product recovery path.
  • add merge-risk: 🚨 compatibility: SDK consumers with shorter provider TTLs also receive the shared 15-minute renewal floor; this documented freshness tradeoff is accepted by the maintainer-authored direction.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Automatic catalog freshness improves model discovery, while explicit Refresh already provides an in-product recovery path.
  • merge-risk: 🚨 compatibility: SDK consumers with shorter provider TTLs also receive the shared 15-minute renewal floor; this documented freshness tradeoff is accepted by the maintainer-authored direction.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 17, 2026, 11:40 PM ET / November 18, 2026, 04:40 UTC.

…ker reads

A saved live model listing never aged after #167008, so a newly launched
provider model stayed out of the picker until a restart, config change,
hosted catalog revision or explicit Refresh.

- A successful live listing expires at the later of its response-cache
  deadline and 15 minutes after acquisition. The floor keeps short TTLs
  from renewing on almost every read (#167008); a longer TTL still wins
  (#168050), so the relist always reaches the provider.
- models.list asks the catalog owner to relist expired providers in the
  background; the read still returns published rows at once.
- Expiry and failure-retry relists no longer mark providers pending, so
  pickers and chat /models show no loading state for them.
@obviyus
obviyus force-pushed the fix/model-listing-max-age branch from 41ee4d3 to 3fd0cae Compare November 18, 2026 06:00
@obviyus

obviyus commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Control UI picker, real browser, opened while the background relist of an aged listing is held in flight (fake LiteLLM listing): saved models render immediately with no loading state; the newly listed model appears once the relist publishes.

Picker during background relist: saved models, no loading state

Picker after relist publishes

@obviyus
obviyus merged commit 2f658fc into main Nov 18, 2026
120 checks passed
@obviyus
obviyus deleted the fix/model-listing-max-age branch November 18, 2026 07:05
@obviyus

obviyus commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 2f658fc. Provider model lists now go stale after 15 minutes (or the provider's own cache lifetime, when longer). The next picker open refetches the stale list in the background with no loading state, so a newly launched model appears without a restart, Refresh or release. Proof: a regression test that fails on the base commit and passes here, base vs fix Gateways with a fake listing, Control UI screenshots taken during a held refetch, a clean local review and green CI on the exact head.

Copy link
Copy Markdown

Maintainer routing question — narrow follow-up to #200988, not a fix for #194240.

This PR intentionally makes expiry-driven provider relists silent (no picker-visible pendingProviders). The existing createCatalogAttemptReporter also consults its pending scope to distinguish a newly admitted failure from a duplicate late failure. That leaves a potential failure-accounting gap when a provider has already failed and a subsequent silent background acquisition fails again.

We prepared a source-only follow-up that tracks silent in-flight provider scope separately from picker-visible pending state, without adding a scheduler or changing the renewal cadence. On pinned upstream d2db7b2267faf4521b3c3a08acd062edd7cbf910, the official agents-core Vitest reporter file yielded 4 pass / 2 targeted failures with unmodified production code and 6 pass / 0 failures with the correction; the strict case-identity check and GitHub Actions job passed: https://github.com/Footloose9/openclaw-conformance-lab/actions/runs/44404323885 . The public source patch is two production files plus one test file. It applies mechanically alongside open #197124 in either order, but combined runtime behavior has not been tested.

This is not a reproduction or solution for #194240's startup/catalog-adoption inventory loss, which is marked no-new-fix-pr. No upstream PR has been opened.

Would maintainers welcome a separate focused PR for silent-renewal failure accounting, prefer it tracked elsewhere, or prefer no PR pending further investigation?

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…ker reads (openclaw#200988)

## What Problem This Solves

A model that a provider launches does not appear in the Gateway model picker until the Gateway restarts, its config or credentials change, the next 6-hourly hosted catalog revision is adopted, or the user presses **Refresh**. Example: OpenAI launched `gpt-6.2-astra` and `gpt-6.2-sol` on 2026-11-17. Typed `openai/gpt-6.2-sol` turns worked on every release, but the picker kept the OpenAI listing saved before the launch.

Cause: openclaw#167008 stopped ordinary `models.list` reads from renewing an expired provider listing, because that expiry was the provider's 60-second HTTP response-cache TTL and almost every picker open rebuilt the catalog. Nothing replaced it, so a saved live listing never ages on its own.

## Why This Change Was Made

- A successful live listing now expires at the later of its response-cache deadline and 15 minutes after acquisition (`discoveryDeadline`). The floor keeps short TTLs from renewing on almost every read (openclaw#167008). A longer TTL still wins (openclaw#168050, ClawRouter's one hour), so the expiry relist, which honors each feed's cache, always reaches the provider instead of re-stamping a cached response as fresh.
- `models.list` calls the catalog owner's existing `refreshExpiredModelCatalog`, which relists only expired providers in the background. The read returns the published rows at once; open pickers update through the existing catalog publication push.
- Expiry and failed-discovery retry relists no longer mark providers pending. They revalidate rows the user already sees, so pickers show no loading state and chat `/models` adds no `checking models…` line for them. First sign-in, changed credentials and explicit **Refresh** still report progress.
- The listing still decides which models a signed-in provider shows (openclaw#114356). This change only keeps that listing fresh.

Accepted cost: at most one background relist per live-listed provider per 15 minutes (or per its cache TTL, when longer), and only while someone opens a picker. Providers whose listing is not retained in the live response cache (`ttlMs: 0`, self-hosted discovery) keep the previous behavior.

## User Impact

A newly launched provider model appears in the picker within about 15 minutes of the provider listing it, on the first picker open, with no restart, no **Refresh**, no loading indicator and no OpenClaw release.

## Evidence

- **Regression (vitest-source):** `models-list.freshness.integration.test.ts` keeps the real live response cache (500 ms TTL, no cache clearing). It asserts that the listing ages out on the 15-minute floor rather than the short TTL, and that an ordinary `models.list` read on an aged listing serves saved rows with no `pendingProviders`, relists once in the background, then publishes the new model. Fails on merge base `9decc8090873` (3/3, deadline equals the cache TTL); the no-pending assertion also fails on this PR's previous head `41ee4d30` (3/3, provider listed as pending); passes on this head (3/3).
- **Renewal contract (vitest-source):** `server-chat-metadata-lifecycle.catalog-renewal.test.ts` now asserts that an expiry renewal never publishes a pending provider and that settling it sends only the real catalog change, with no refresh-status broadcast. An explicit refresh in the same file still reports refresh status.
- **E2E, CLI reads (fix: source tier; base: `9decc8090873` dist-nodts):** two isolated Gateways, each with a fake LiteLLM proxy as its live listing and hosted catalog refresh disabled. At 04:03:46Z each proxy starts listing `fake-2`; an ordinary `gateway call models.list` (no refresh) runs once a minute.

  | Time (UTC) | Fix Gateway picker | Base Gateway picker |
  |---|---|---|
  | 04:03:41 (before) | `fake-1` | `fake-1` |
  | 04:04 to 04:17 | `fake-1` | `fake-1` |
  | 04:18:58 | `fake-1`, `fake-2` | `fake-1` |
  | 04:23:58 | `fake-1`, `fake-2` | `fake-1` |

  Proxy request logs: the fix Gateway listed at startup and once more at 04:17:58, the first read after the listing aged; no other requests. The base Gateway never listed again.
- **E2E, Control UI (dist-nodts, real browser):** this head and the previous head `41ee4d30`, each with a fake LiteLLM listing whose `/models` response is held for 25 s after a new model is added. The picker is opened once the listing aged (proxy logs show the relist request at that moment), then again after release. During the relist both pickers render the saved models immediately with no loading state; the new model appears after the relist publishes. The visible difference from the previous head is the pending flag (`pendingProviders`, and chat `/models` `checking models…`), which the tests above pin as absent. Screenshots: openclaw#200988 (comment)
- **Affected suites (vitest-source, exact head):** freshness, renewal, worker recovery, publication events, auth-login catalog, prepared-runtime sources, native picker failures and configured catalog index: 52 tests across 5 shards pass.
- **Review and CI:** local ClawSweeper review (`gpt-6.1-sol`) on `3fd0cae6` found no issues; required CI is green on the same head.

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 docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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.

2 participants