openclaw - ✅(Solved) Fix Gateway startup: models.mode=replace should skip pricing fetches [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74020Fetched 2026-04-30 06:29:44
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
cross-referenced ×4commented ×1

Fix Action

Fixed

PR fix notes

PR #74038: fix(gateway): skip pricing bootstrap in replace mode

Description (problem / solution / changelog)

Problem

When models.mode: "replace" is configured, Gateway startup still bootstraps remote OpenRouter/LiteLLM pricing metadata by default. That surprises users who intentionally replaced the model catalog and can add avoidable network work during startup.

Root cause

models.pricing.enabled previously defaulted to enabled independently of models.mode, so replace-mode configs still loaded the remote pricing bootstrap path unless users explicitly disabled pricing.

Complete fix boundary

  • Runtime default: models.pricing.enabled now remains an explicit override, but when omitted it defaults to disabled for models.mode: "replace" and enabled otherwise.
  • Startup/cache behavior: bootstrap and refresh paths respect the derived pricing enablement.
  • User/model-visible surfaces: schema help, generated base schema, config docs, model docs, token-use docs, config tools docs, generated config baseline, and changelog all describe the replace-mode default and explicit opt-in.
  • Regression coverage: direct pricing cache behavior, Gateway startup import behavior, schema/help wording, and existing adjacent startup/cron shards.

What intentionally did not change

  • models.pricing.enabled: true still force-enables pricing bootstrap in replace mode.
  • Non-replace modes keep the existing default pricing behavior.
  • Pricing provider URL/cache/storage semantics are unchanged.
  • Model resolution and provider routing semantics are unchanged.

Tests run

Local on head 4aeef953afbc3cf57ef3d92f7d972703659ca092:

  • pnpm config:schema:check
  • pnpm config:docs:check
  • pnpm test src/gateway/model-pricing-cache.test.ts src/gateway/server-runtime-services.test.ts src/config/schema.help.quality.test.ts src/gateway/server-startup-plugins.test.ts src/cron/service.read-ops-nonblocking.test.ts src/cron/service/ops.test.ts
  • pnpm exec oxfmt --check --threads=1 src/gateway/model-pricing-config.ts src/gateway/model-pricing-cache.test.ts src/gateway/server-runtime-services.test.ts src/config/schema.help.ts src/config/schema.help.quality.test.ts src/config/schema.base.generated.ts
  • git diff --check FETCH_HEAD...HEAD
  • pnpm check:changed
  • pnpm lint --threads=8
  • pnpm docs:list

Linked issue

Fixes #74020.

CI red analysis

Current head 4aeef953afbc3cf57ef3d92f7d972703659ca092 has a fresh CI run in progress after rebasing onto upstream fixes for agent wait/deferred dispatch behavior. GitHub currently reports the PR as mergeable; no conflict is shown.

Previous superseded head 4428c0c272665e76728b9fd38630dec457bf82df had all regular CI checks passing. The only completed red check was the parity gate: OpenAI lane passed 12/12, Opus 4.6 lane passed 11/12 and failed only instruction-followthrough-repo-contract with agent.wait returned timeout: no error. The artifact/logs place that failure in qa-channel/agent followthrough behavior, not in this PR's pricing bootstrap, schema/help, docs, or changelog diff. I do not have repository admin rights to rerun failed checks directly, so the branch was rebased and pushed to pick up upstream qa/agent wait fixes and start a new run.

Earlier superseded reds after older heads were also outside this diff and were resolved by rebasing to upstream fixes: one gateway startup plugin mock missing pruneUnknownBundledRuntimeDepsRoots, and one cron startup catch-up timing issue.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • docs/.generated/config-baseline.sha256 (modified, +2/-2)
  • docs/concepts/models.md (modified, +1/-0)
  • docs/gateway/config-tools.md (modified, +1/-0)
  • docs/gateway/configuration-reference.md (modified, +5/-3)
  • docs/reference/token-use.md (modified, +4/-2)
  • src/config/schema.base.generated.ts (modified, +2/-2)
  • src/config/schema.help.quality.test.ts (modified, +3/-0)
  • src/config/schema.help.ts (modified, +1/-1)
  • src/gateway/model-pricing-cache.test.ts (modified, +65/-0)
  • src/gateway/model-pricing-config.ts (modified, +5/-1)
  • src/gateway/server-runtime-services.test.ts (modified, +18/-0)

PR #74045: fix(gateway): skip model pricing fetches when mode is replace

Description (problem / solution / changelog)

When models.mode is set to replace, all model configurations are provided manually and the built-in pricing catalog from OpenRouter/LiteLLM is not used. However, the gateway still performs pricing fetches during startup, which can take up to 60 seconds to timeout.

This change makes isGatewayModelPricingEnabled() return false when models.mode === "replace", consistent with the existing models.pricing.enabled: false option that already allows skipping these fetches.

Closes #74020

Changed files

  • src/gateway/model-pricing-config.ts (modified, +1/-1)

PR #73557: fix(agents): skip implicit provider discovery when models.mode is replace [AI-assisted]

Description (problem / solution / changelog)

🤖 AI-assisted (built with Claude Code via Hermes orchestration). Test level: fully tested. Prompt summary available on request.

Summary

  • Problem: models.mode="replace" is documented to use only explicitly configured providers, but resolveProvidersForModelsJsonWithDeps unconditionally calls resolveImplicitProviders(), causing unnecessary provider discovery and 72+ second startup delays.
  • Why it matters: Users who explicitly set models.mode="replace" to avoid implicit provider discovery still get the full discovery cost, defeating the purpose of the config.
  • What changed: Guarded the resolveImplicitProviders call with a mode !== "replace" check so replace mode skips implicit discovery entirely and uses only explicit providers.
  • What did NOT change (scope boundary): No changes to merge mode behavior, no changes to provider discovery logic itself, no changes to how explicit providers are handled.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Core agent runtime

Linked Issue/PR

  • Closes #66957
  • This PR fixes a bug or regression

Root Cause

  • Root cause: resolveProvidersForModelsJsonWithDeps called resolveImplicitProviders unconditionally at line 58, before any mode-specific handling. The mode check only happened later in resolveProvidersForMode() which only affects merge behavior, not whether implicit discovery runs.
  • Missing detection / guardrail: No test for the replace mode skipping implicit provider discovery.
  • Contributing context: The mode handling in resolveProvidersForMode was only designed for merge-vs-replace provider merging, not for gating discovery itself.

Regression Test Plan

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: src/agents/models-config.replace-mode-skip-implicit-discovery.test.ts
  • Scenario the test should lock in: When models.mode="replace", resolveImplicitProviders is never called and only explicit providers are returned.
  • Why this is the smallest reliable guardrail: The test injects a mock resolveImplicitProviders and verifies it is/isn't called based on the mode setting.

User-visible / Behavior Changes

  • Users with models.mode="replace" will see significantly faster startup (no implicit provider discovery delay).

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? No
  • This fix only changes when implicit provider discovery runs. No security surface changes.

Changed files

  • src/agents/models-config.plan.ts (modified, +24/-18)
  • src/agents/models-config.replace-mode-skip-implicit-discovery.test.ts (added, +169/-0)
RAW_BUFFERClick to expand / collapse

When starting the gateway with \models.mode=replace, the gateway still runs pricing fetches (e.g. OpenRouter, LiteLLM) which take up to 60 seconds to timeout. Since the mode is
eplace\ and models are manually configured, these fetches are unnecessary and significantly delay startup. Please skip pricing fetches when mode is
eplace.

extent analysis

TL;DR

Modify the gateway startup logic to skip pricing fetches when the models.mode is set to replace.

Guidance

  • Check the gateway's configuration and startup code to identify where pricing fetches are triggered and how the models.mode is evaluated.
  • Consider adding a conditional statement to bypass pricing fetches when models.mode equals replace.
  • Verify that manually configured models are properly loaded and functional when pricing fetches are skipped.
  • Review the gateway's documentation and existing issues to ensure this change does not introduce unintended side effects.

Example

if models.mode != 'replace':
    # Run pricing fetches (e.g., OpenRouter, LiteLLM)
    run_pricing_fetches()

Notes

This solution assumes that the models.mode is correctly set and evaluated during gateway startup. Additional logging or debugging may be necessary to confirm the issue and verify the fix.

Recommendation

Apply workaround: Modify the gateway startup logic to conditionally skip pricing fetches based on the models.mode value, as this directly addresses the reported issue and avoids unnecessary delays.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Gateway startup: models.mode=replace should skip pricing fetches [3 pull requests, 1 comments, 2 participants]