openclaw - ✅(Solved) Fix models.json bloat — ensureOpenClawModelsJson() uses accumulated runtime snapshot instead of active config [1 pull requests, 1 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#65020Fetched 2026-04-12 13:26:00
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2renamed ×2closed ×1

Fix Action

Fix

The runtimeSource ?? loaded fix is correct for its case. But the broader bloat requires:

  1. resolveImplicitProviders should respect an empty models.providers as "don't discover anything"
  2. OR the models.mode should default to replace instead of merge when providers list is empty
  3. OR plugin discovery should only add providers that have actual auth configured

Workaround

guard-models-json.sh runs every 10 minutes, restores the lean reference, confirmed working.

See: PR with partial fix → https://github.com/karlhillx/openclaw/pull/1

PR fix notes

PR #1: fix: resolveModelsConfigInput uses runtimeSource snapshot instead of active config when config is undefined

Description (problem / solution / changelog)

The bug (refined)

resolveModelsConfigInput(undefined) returns runtimeSource ?? loaded — but runtimeSource is a persistent in-memory accumulator that grows as providers are touched across sessions. After the first session, it's always truthy, so loaded (the actual openclaw.json config) is never reached.

However: After testing with the fix applied, the main bloat path is NOT this undefined case — it's plugin provider discovery adding catalog providers even when models.providers is empty in openclaw.json. The runtimeSource ?? loaded fix is correct for its code path, but the broader bloat requires a separate fix in resolveImplicitProviders.

The fix in this PR

-      config: runtimeSource ?? loaded,
+      config: loaded,

When ensureOpenClawModelsJson(undefined) is called without a config, it should fall back to loaded (the lean reference) rather than the accumulated snapshot. sourceConfigForSecrets still uses runtimeSource so secret resolution is unaffected.

Testing

Built and ran. Fix confirmed present in runtime code. The bloat still occurs via a separate path (plugin discovery), but this fix is correct for the case it addresses.

What still needs fixing (separate issue)

resolveImplicitProviders / plugin provider discovery adds all catalogued providers regardless of models.providers being empty. This is the remaining bloat path and should be filed as a separate issue.

Closes #65020

Changed files

  • .agent/workflows/update_clawdbot.md (removed, +0/-380)
  • .agents/skills/openclaw-ghsa-maintainer/SKILL.md (added, +87/-0)
  • .agents/skills/openclaw-parallels-smoke/SKILL.md (added, +135/-0)
  • .agents/skills/openclaw-pr-maintainer/SKILL.md (added, +75/-0)
  • .agents/skills/openclaw-qa-testing/SKILL.md (added, +148/-0)
  • .agents/skills/openclaw-qa-testing/agents/openai.yaml (added, +4/-0)
  • .agents/skills/openclaw-release-maintainer/SKILL.md (added, +267/-0)
  • .agents/skills/openclaw-test-heap-leaks/SKILL.md (added, +75/-0)
  • .agents/skills/openclaw-test-heap-leaks/agents/openai.yaml (added, +4/-0)
  • .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs (added, +553/-0)
  • .agents/skills/parallels-discord-roundtrip/SKILL.md (added, +62/-0)
  • .agents/skills/security-triage/SKILL.md (added, +111/-0)
  • .codex (renamed, +0/-0)
  • .dockerignore (modified, +3/-1)
  • .github/ISSUE_TEMPLATE/bug_report.yml (modified, +36/-25)
  • .github/actions/ensure-base-commit/action.yml (modified, +16/-2)
  • .github/actions/setup-node-env/action.yml (modified, +4/-18)
  • .github/actions/setup-pnpm-store-cache/action.yml (modified, +1/-1)
  • .github/labeler.yml (modified, +61/-10)
  • .github/pr-assets/compaction-checkpoints/sessions-checkpoints-inline.png (added, +0/-0)
  • .github/pr-assets/compaction-checkpoints/sessions-overview-inline.png (added, +0/-0)
  • .github/pull_request_template.md (modified, +39/-7)
  • .github/workflows/auto-response.yml (modified, +10/-0)
  • .github/workflows/ci.yml (modified, +977/-412)
  • .github/workflows/codeql.yml (modified, +1/-1)
  • .github/workflows/control-ui-locale-refresh.yml (added, +172/-0)
  • .github/workflows/docker-release.yml (modified, +10/-4)
  • .github/workflows/docs-sync-publish.yml (added, +70/-0)
  • .github/workflows/docs-translate-trigger-release.yml (added, +42/-0)
  • .github/workflows/install-smoke.yml (modified, +120/-21)
  • .github/workflows/labeler.yml (modified, +162/-2)
  • .github/workflows/macos-release.yml (added, +93/-0)
  • .github/workflows/openclaw-npm-release.yml (modified, +387/-78)
  • .github/workflows/plugin-clawhub-release.yml (added, +276/-0)
  • .github/workflows/plugin-npm-release.yml (added, +217/-0)
  • .github/workflows/sandbox-common-smoke.yml (modified, +3/-1)
  • .github/workflows/stale.yml (modified, +2/-2)
  • .github/workflows/workflow-sanity.yml (modified, +13/-4)
  • .gitignore (modified, +19/-2)
  • .markdownlint-cli2.jsonc (modified, +3/-0)
  • .npmignore (modified, +2/-0)
  • .npmrc (modified, +3/-0)
  • .oxfmtrc.jsonc (modified, +3/-2)
  • .oxlintrc.json (modified, +36/-8)
  • .vscode/settings.json (modified, +1/-2)
  • AGENTS.md (modified, +174/-165)
  • CHANGELOG.md (modified, +2056/-454)
  • CONTRIBUTING.md (modified, +31/-7)
  • Dockerfile (modified, +37/-11)
  • Dockerfile.sandbox-browser (modified, +1/-0)
  • INCIDENT_RESPONSE.md (added, +52/-0)
  • Makefile (added, +4/-0)
  • README.md (modified, +76/-21)
  • SECURITY.md (modified, +33/-2)
  • appcast.xml (modified, +191/-209)
  • apps/android/README.md (modified, +66/-4)
  • apps/android/app/build.gradle.kts (modified, +64/-36)
  • apps/android/app/src/main/AndroidManifest.xml (modified, +15/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/AssistantLaunch.kt (added, +43/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/MainActivity.kt (modified, +28/-6)
  • apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt (modified, +270/-95)
  • apps/android/app/src/main/java/ai/openclaw/app/NodeApp.kt (modified, +12/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/NodeForegroundService.kt (modified, +6/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt (modified, +335/-116)
  • apps/android/app/src/main/java/ai/openclaw/app/NotificationForwardingPolicy.kt (added, +102/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/PermissionRequester.kt (modified, +89/-22)
  • apps/android/app/src/main/java/ai/openclaw/app/SecurePrefs.kt (modified, +202/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/SessionKey.kt (modified, +11/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt (modified, +156/-52)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/DeviceAuthStore.kt (modified, +67/-7)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayHostSecurity.kt (added, +124/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt (modified, +108/-34)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayTls.kt (modified, +33/-7)
  • apps/android/app/src/main/java/ai/openclaw/app/node/A2UIHandler.kt (modified, +7/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CameraCaptureManager.kt (modified, +36/-30)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CameraHandler.kt (modified, +5/-3)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CanvasActionTrust.kt (added, +51/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CanvasController.kt (modified, +28/-14)
  • apps/android/app/src/main/java/ai/openclaw/app/node/ConnectionManager.kt (modified, +20/-3)
  • apps/android/app/src/main/java/ai/openclaw/app/node/ContactsHandler.kt (modified, +5/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/DeviceHandler.kt (modified, +55/-7)
  • apps/android/app/src/main/java/ai/openclaw/app/node/DeviceNotificationListenerService.kt (modified, +120/-24)
  • apps/android/app/src/main/java/ai/openclaw/app/node/InvokeCommandRegistry.kt (modified, +25/-6)
  • apps/android/app/src/main/java/ai/openclaw/app/node/InvokeDispatcher.kt (modified, +62/-3)
  • apps/android/app/src/main/java/ai/openclaw/app/node/LocationCaptureManager.kt (modified, +4/-9)
  • apps/android/app/src/main/java/ai/openclaw/app/node/LocationHandler.kt (modified, +75/-17)
  • apps/android/app/src/main/java/ai/openclaw/app/node/MotionHandler.kt (modified, +14/-18)
  • apps/android/app/src/main/java/ai/openclaw/app/node/PhotosHandler.kt (modified, +49/-34)
  • apps/android/app/src/main/java/ai/openclaw/app/node/SmsHandler.kt (modified, +22/-5)
  • apps/android/app/src/main/java/ai/openclaw/app/node/SmsManager.kt (modified, +909/-12)
  • apps/android/app/src/main/java/ai/openclaw/app/protocol/OpenClawCanvasA2UIAction.kt (modified, +6/-3)
  • apps/android/app/src/main/java/ai/openclaw/app/protocol/OpenClawProtocolConstants.kt (modified, +1/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/CanvasScreen.kt (modified, +34/-3)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/ConnectTabScreen.kt (modified, +111/-11)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayConfigResolver.kt (modified, +129/-18)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayDiagnostics.kt (added, +78/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayPairingRetry.kt (added, +45/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/OnboardingFlow.kt (modified, +195/-55)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/OpenClawTheme.kt (modified, +13/-0)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/PostOnboardingTabs.kt (modified, +61/-8)

Code Example

minimax-cn, openrouter, openai-codex, arcee, codex, github-copilot,
minimax-portal, minimax-portal-cn, xai, x-ai
RAW_BUFFERClick to expand / collapse

Problem

Every time OpenClaw starts a session, it overwrites models.json with a bloated snapshot instead of the lean 4-provider config in openclaw.json. File goes from ~2KB to ~22KB within 60 seconds of startup. Confirmed happening ~4-5× per hour, every hour.

What's actually happening (updated)

The fix for resolveModelsConfigInput(undefined) addresses a real bug in the fallback code path, but the actual bloat has a different cause.

When openclaw.json has models: { providers: {} } (empty providers), the plugin provider discovery system still discovers all catalogued providers and adds them to models.json. This is not a runtimeSource ?? loaded bug — it's a plugin discovery behavior.

12 extra providers appear even with the fix applied:

minimax-cn, openrouter, openai-codex, arcee, codex, github-copilot,
minimax-portal, minimax-portal-cn, xai, x-ai

These are plugin-catalog providers, not hardcoded. They get resolved even when models.providers is empty.

Confirmed bloat path

ensureOpenClawModelsJson(params.cfg, agentDir) at startup → passes a valid config → resolveModelsConfigInput(cfg)projectConfigOntoRuntimeSourceSnapshot(cfg)resolveProvidersForModelsJsonWithDepsresolveImplicitProvidersresolvePluginDiscoveryProviders → adds all catalog providers regardless of models.providers setting.

Fix

The runtimeSource ?? loaded fix is correct for its case. But the broader bloat requires:

  1. resolveImplicitProviders should respect an empty models.providers as "don't discover anything"
  2. OR the models.mode should default to replace instead of merge when providers list is empty
  3. OR plugin discovery should only add providers that have actual auth configured

Workaround

guard-models-json.sh runs every 10 minutes, restores the lean reference, confirmed working.

See: PR with partial fix → https://github.com/karlhillx/openclaw/pull/1

extent analysis

TL;DR

To prevent models.json from being overwritten with a bloated snapshot, modify the resolveImplicitProviders function to respect an empty models.providers setting or change the models.mode default to replace when the providers list is empty.

Guidance

  • Review the resolveImplicitProviders function to ensure it correctly handles empty models.providers settings and does not add unnecessary providers to models.json.
  • Consider modifying the models.mode default to replace when the models.providers list is empty to prevent unwanted provider additions.
  • Evaluate the plugin discovery behavior to determine if it should only add providers with actual authentication configured.
  • Use the provided guard-models-json.sh script as a temporary workaround to restore the lean reference models.json file every 10 minutes.

Example

No explicit code example is provided, but the fix involves modifying the resolveImplicitProviders function or the models.mode default setting.

Notes

The actual cause of the bloat is the plugin provider discovery system adding all catalogued providers to models.json, even when models.providers is empty. The provided fix and workaround address this issue, but further evaluation of the plugin discovery behavior may be necessary.

Recommendation

Apply the workaround using the guard-models-json.sh script to immediately mitigate the issue, and then modify the resolveImplicitProviders function or the models.mode default setting to provide a permanent fix. This approach allows for a temporary solution while a more permanent fix is implemented.

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 models.json bloat — ensureOpenClawModelsJson() uses accumulated runtime snapshot instead of active config [1 pull requests, 1 participants]