Repository navigation
fix(gateway): read-only persisted fast path for models.list catalog - #76406
vincentkoc merged 4 commits into
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. for the source-level hot path: current main calls Next step before merge Security Review detailsBest possible solution: Land this PR after maintainer approval, keeping normal model pickers on the read-only fast path and reserving the full catalog for explicit diagnostic/discovery calls. Do we have a high-confidence way to reproduce the issue? Yes for the source-level hot path: current main calls Is this the best way to solve the issue? Yes: the PR is the narrow maintainable fix because it uses the existing read-only contract for picker-sized calls, adds a persisted local fast path with registry fallback, and keeps What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 411df5991608. |
The gateway model catalog refresh calls loadModelCatalog without readOnly, triggering ensureOpenClawModelsJson (60-70s), full PI SDK registry instantiation, auth storage discovery, and live provider plugin augmentation on every Control UI list/refresh. None of this is needed for a read-only UI listing. Three changes: 1. Gateway catalog refresh now passes readOnly: true to loadModelCatalog. 2. In readOnly mode, skip augmentModelCatalogWithProviderPlugins — live provider discovery is explicit admin/background work, not a UI list operation. 3. Add a persisted models.json fast path: when readOnly is true, first try reading the existing models.json directly and converting providers.<provider>.models[] to catalog rows. Falls back to the full PI registry path if the file is missing or unreadable. Observed improvement on a production install: loadGatewayModelCatalog: 967 entries / 4651ms → 89 entries / 8ms Live models.list during startup: ~18s → ~2s Co-Authored-By: Claude Opus 4.6 <[email protected]>
…penclaw#76406) * fix(gateway): read-only fast path for models.list catalog loading The gateway model catalog refresh calls loadModelCatalog without readOnly, triggering ensureOpenClawModelsJson (60-70s), full PI SDK registry instantiation, auth storage discovery, and live provider plugin augmentation on every Control UI list/refresh. None of this is needed for a read-only UI listing. Three changes: 1. Gateway catalog refresh now passes readOnly: true to loadModelCatalog. 2. In readOnly mode, skip augmentModelCatalogWithProviderPlugins — live provider discovery is explicit admin/background work, not a UI list operation. 3. Add a persisted models.json fast path: when readOnly is true, first try reading the existing models.json directly and converting providers.<provider>.models[] to catalog rows. Falls back to the full PI registry path if the file is missing or unreadable. Observed improvement on a production install: loadGatewayModelCatalog: 967 entries / 4651ms → 89 entries / 8ms Live models.list during startup: ~18s → ~2s Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(gateway): preserve full model catalog view * fix(agents): preserve read-only catalog defaults * fix(agents): preserve provider catalog defaults --------- Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
…penclaw#76406) * fix(gateway): read-only fast path for models.list catalog loading The gateway model catalog refresh calls loadModelCatalog without readOnly, triggering ensureOpenClawModelsJson (60-70s), full PI SDK registry instantiation, auth storage discovery, and live provider plugin augmentation on every Control UI list/refresh. None of this is needed for a read-only UI listing. Three changes: 1. Gateway catalog refresh now passes readOnly: true to loadModelCatalog. 2. In readOnly mode, skip augmentModelCatalogWithProviderPlugins — live provider discovery is explicit admin/background work, not a UI list operation. 3. Add a persisted models.json fast path: when readOnly is true, first try reading the existing models.json directly and converting providers.<provider>.models[] to catalog rows. Falls back to the full PI registry path if the file is missing or unreadable. Observed improvement on a production install: loadGatewayModelCatalog: 967 entries / 4651ms → 89 entries / 8ms Live models.list during startup: ~18s → ~2s Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(gateway): preserve full model catalog view * fix(agents): preserve read-only catalog defaults * fix(agents): preserve provider catalog defaults --------- Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
…penclaw#76406) * fix(gateway): read-only fast path for models.list catalog loading The gateway model catalog refresh calls loadModelCatalog without readOnly, triggering ensureOpenClawModelsJson (60-70s), full PI SDK registry instantiation, auth storage discovery, and live provider plugin augmentation on every Control UI list/refresh. None of this is needed for a read-only UI listing. Three changes: 1. Gateway catalog refresh now passes readOnly: true to loadModelCatalog. 2. In readOnly mode, skip augmentModelCatalogWithProviderPlugins — live provider discovery is explicit admin/background work, not a UI list operation. 3. Add a persisted models.json fast path: when readOnly is true, first try reading the existing models.json directly and converting providers.<provider>.models[] to catalog rows. Falls back to the full PI registry path if the file is missing or unreadable. Observed improvement on a production install: loadGatewayModelCatalog: 967 entries / 4651ms → 89 entries / 8ms Live models.list during startup: ~18s → ~2s Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(gateway): preserve full model catalog view * fix(agents): preserve read-only catalog defaults * fix(agents): preserve provider catalog defaults --------- Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
…penclaw#76406) * fix(gateway): read-only fast path for models.list catalog loading The gateway model catalog refresh calls loadModelCatalog without readOnly, triggering ensureOpenClawModelsJson (60-70s), full PI SDK registry instantiation, auth storage discovery, and live provider plugin augmentation on every Control UI list/refresh. None of this is needed for a read-only UI listing. Three changes: 1. Gateway catalog refresh now passes readOnly: true to loadModelCatalog. 2. In readOnly mode, skip augmentModelCatalogWithProviderPlugins — live provider discovery is explicit admin/background work, not a UI list operation. 3. Add a persisted models.json fast path: when readOnly is true, first try reading the existing models.json directly and converting providers.<provider>.models[] to catalog rows. Falls back to the full PI registry path if the file is missing or unreadable. Observed improvement on a production install: loadGatewayModelCatalog: 967 entries / 4651ms → 89 entries / 8ms Live models.list during startup: ~18s → ~2s Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(gateway): preserve full model catalog view * fix(agents): preserve read-only catalog defaults * fix(agents): preserve provider catalog defaults --------- Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
Summary
readOnly: truetoloadModelCatalog()augmentModelCatalogWithProviderPlugins()— live provider discovery is admin/background workmodels.jsonfast path: read the existing file directly instead of instantiating the full PI SDK registry, auth storage, and model suppression pipelinemodels.jsonis missing or unreadableProblem
models.listin the Control UI triggersloadGatewayModelCatalog(), which callsloadModelCatalog()withoutreadOnly. This runs the full catalog pipeline:ensureOpenClawModelsJson()— regeneratesmodels.jsonfrom provider configs (measured at 62s on a production install)augmentModelCatalogWithProviderPlugins()— live provider/plugin model discovery (~5s)Total observed: 60-70s blocking the event loop for a read-only UI list call. The existing 750ms timeout on
sessions.list's model catalog dependency couldn't help because the synchronous/CPU work starts before timers can fire.Fix
Gateway read-only flag:
startGatewayModelCatalogRefresh()now passesreadOnly: true. This was the original intent of thereadOnlyparameter but was never wired up in the gateway path.Skip plugin augmentation in read-only mode:
augmentModelCatalogWithProviderPlugins()discovers live provider models — useful for explicit admin refresh, not for polling UI lists. Skipped whenreadOnlyis true.Persisted models.json fast path: When
readOnlyis true,loadModelCatalog()first triesloadReadOnlyPersistedModelCatalog():agents/main/agent/models.jsondirectly viareadFileproviders.<provider>.models[]toModelCatalogEntryrowsbuildConfiguredModelCatalog()Entry count note: The fast path returns persisted + configured models only (e.g. 89 entries), not the full generated registry catalog (e.g. 967 entries). This is the correct shape for a Control UI list. If
view=allsemantics need to include generated registry models, that should be a separate explicit API path.Measurements (production install)
loadGatewayModelCatalog()models.listat startupTest plan
models.listreturns persisted + configured models in read-only modemodels.jsonfalls back to full catalog path without errormarkGatewayModelCatalogStaleForReload()triggers fresh read on next call🤖 Generated with Claude Code