openclaw - ✅(Solved) Fix [Bug]: Gateway does not load model configuration from openclaw.json on restart [2 pull requests, 3 comments, 3 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#44611Fetched 2026-04-08 00:44:34
View on GitHub
Comments
3
Participants
3
Timeline
8
Reactions
0
Timeline (top)
commented ×3cross-referenced ×2labeled ×2referenced ×1

The OpenClaw gateway is failing to apply model configuration changes from ~/.openclaw/openclaw.json after a service restart. It continues to use the model that was active before the configuration file was changed, effectively ignoring the updated settings on disk.

Root Cause

The OpenClaw gateway is failing to apply model configuration changes from ~/.openclaw/openclaw.json after a service restart. It continues to use the model that was active before the configuration file was changed, effectively ignoring the updated settings on disk.

Fix Action

Fixed

PR fix notes

PR #2: OpenClaw 紧急未修复

Description (problem / solution / changelog)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: The Gateway crashes with an unhandled promise rejection when the Discord API returns a 503 error, as response.json() is called without checking response.ok.
  • Why it matters: This causes the entire gateway process to exit, leading to a complete service interruption for all connected Discord channels for several minutes.
  • What changed: Added a check for response.ok before attempting to parse the JSON response. Errors are now emitted via this.emitter.emit("error") and this.handleReconnectionAttempt() is called to trigger a graceful reconnection attempt, preventing a full process crash. Updated tests to cover the 503 error path.
  • What did NOT change (scope boundary): Other identified issues (#44544, #44611, #44562, #44549) were either already fixed, determined not to be code bugs, or required a dedicated test environment for safe implementation and are not part of this PR.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #44529
  • Related #

User-visible / Behavior Changes

The gateway will no longer crash when the Discord API returns a 503 error during client registration. Instead, it will log the error and attempt to reconnect gracefully.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: Linux (typical Node.js environment)
  • Runtime/container: Node.js
  • Model/provider: N/A
  • Integration/channel (if any): Discord
  • Relevant config (redacted): N/A

Steps

  1. Configure OpenClaw Gateway with a Discord integration.
  2. During the GatewayPlugin.registerClient() call (e.g., when the health monitor triggers a Discord bot reconnection), simulate a Discord API returning a 503 HTTP status code with a non-JSON body.
  3. Observe the gateway process.

Expected

  • The gateway logs an error about the Discord 503 response.
  • The gateway attempts to reconnect to Discord without crashing the entire Node.js process.

Actual

  • The gateway process crashes with an unhandled promise rejection.

Evidence

  • Failing test/log before + passing after (New test should handle 503 response gracefully without crashing added to provider.proxy.test.ts which now passes.)
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: Added and passed a new unit test specifically for the 503 error case in provider.proxy.test.ts, ensuring the response.ok check and error handling logic are correctly implemented.
  • Edge cases checked: Specifically addressed the case where response.json() would throw an error on a non-2xx response.
  • What you did not verify: Did not verify in a live production environment with an actual Discord 503 error.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert this PR.
  • Files/config to restore: N/A
  • Known bad symptoms reviewers should watch for: Gateway still crashing on Discord 503, or Discord reconnection issues.

Risks and Mitigations

  • Risk: The error handling or reconnection logic might not fully cover all edge cases of Discord API errors.
    • Mitigation: The current fix addresses the immediate crash by preventing response.json() on bad responses and uses existing reconnection mechanisms. Further monitoring of Discord integration health is always recommended.
<div><a href="https://cursor.com/agents/bc-7023bdfd-1d36-48c0-818c-2346ec9378b5"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/background-agent?bcId=bc-7023bdfd-1d36-48c0-818c-2346ec9378b5"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div> <!-- CURSOR_AGENT_PR_BODY_END -->

Changed files

  • .detect-secrets.cfg (modified, +19/-4)
  • .github/FUNDING.yml (removed, +0/-1)
  • .github/ISSUE_TEMPLATE/bug_report.yml (modified, +31/-0)
  • .github/actions/ensure-base-commit/action.yml (added, +47/-0)
  • .github/actions/setup-node-env/action.yml (modified, +8/-4)
  • .github/actions/setup-pnpm-store-cache/action.yml (modified, +9/-7)
  • .github/codeql/codeql-javascript-typescript.yml (added, +18/-0)
  • .github/pull_request_template.md (modified, +7/-0)
  • .github/workflows/auto-response.yml (modified, +55/-0)
  • .github/workflows/ci.yml (modified, +85/-50)
  • .github/workflows/codeql.yml (added, +134/-0)
  • .github/workflows/docker-release.yml (modified, +77/-10)
  • .github/workflows/install-smoke.yml (modified, +63/-19)
  • .github/workflows/labeler.yml (modified, +256/-82)
  • .github/workflows/openclaw-npm-release.yml (added, +79/-0)
  • .github/workflows/sandbox-common-smoke.yml (modified, +1/-1)
  • .github/workflows/stale.yml (modified, +62/-3)
  • .gitignore (modified, +10/-0)
  • .npmignore (added, +1/-0)
  • .pi/prompts/reviewpr.md (modified, +37/-8)
  • .pre-commit-config.yaml (modified, +27/-1)
  • .secrets.baseline (modified, +229/-316)
  • .swiftformat (modified, +1/-1)
  • .swiftlint.yml (modified, +3/-1)
  • AGENTS.md (modified, +38/-0)
  • CHANGELOG.md (modified, +717/-137)
  • CONTRIBUTING.md (modified, +36/-4)
  • Dockerfile (modified, +165/-50)
  • Dockerfile.sandbox (modified, +6/-3)
  • Dockerfile.sandbox-browser (modified, +7/-5)
  • Dockerfile.sandbox-common (modified, +6/-4)
  • README.md (modified, +1/-1)
  • SECURITY.md (modified, +9/-0)
  • appcast.xml (modified, +499/-328)
  • apps/android/README.md (modified, +1/-1)
  • apps/android/app/build.gradle.kts (modified, +49/-4)
  • apps/android/app/proguard-rules.pro (modified, +1/-1)
  • apps/android/app/src/main/AndroidManifest.xml (modified, +1/-9)
  • apps/android/app/src/main/java/ai/openclaw/android/InstallResultReceiver.kt (removed, +0/-33)
  • apps/android/app/src/main/java/ai/openclaw/android/ScreenCaptureRequester.kt (removed, +0/-65)
  • apps/android/app/src/main/java/ai/openclaw/android/node/AppUpdateHandler.kt (removed, +0/-295)
  • apps/android/app/src/main/java/ai/openclaw/android/node/ScreenHandler.kt (removed, +0/-25)
  • apps/android/app/src/main/java/ai/openclaw/android/node/ScreenRecordManager.kt (removed, +0/-165)
  • apps/android/app/src/main/java/ai/openclaw/app/CameraHudState.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/DeviceNames.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/LocationMode.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/MainActivity.kt (renamed, +3/-7)
  • apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt (renamed, +11/-10)
  • apps/android/app/src/main/java/ai/openclaw/app/NodeApp.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/NodeForegroundService.kt (renamed, +6/-28)
  • apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt (renamed, +64/-44)
  • apps/android/app/src/main/java/ai/openclaw/app/PermissionRequester.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/SecurePrefs.kt (renamed, +45/-6)
  • apps/android/app/src/main/java/ai/openclaw/app/SessionKey.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/VoiceWakeMode.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/WakeWords.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/chat/ChatModels.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/BonjourEscapes.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/DeviceAuthPayload.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/DeviceAuthStore.kt (renamed, +4/-3)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/DeviceIdentityStore.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayDiscovery.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayEndpoint.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayProtocol.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt (renamed, +225/-20)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayTls.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/gateway/InvokeErrorParser.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/node/A2UIHandler.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CalendarHandler.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CameraCaptureManager.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CameraHandler.kt (renamed, +4/-4)
  • apps/android/app/src/main/java/ai/openclaw/app/node/CanvasController.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/ConnectionManager.kt (renamed, +9/-9)
  • apps/android/app/src/main/java/ai/openclaw/app/node/ContactsHandler.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/DebugHandler.kt (renamed, +4/-4)
  • apps/android/app/src/main/java/ai/openclaw/app/node/DeviceHandler.kt (renamed, +3/-18)
  • apps/android/app/src/main/java/ai/openclaw/app/node/DeviceNotificationListenerService.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/node/GatewayEventHandler.kt (renamed, +3/-3)
  • apps/android/app/src/main/java/ai/openclaw/app/node/InvokeCommandRegistry.kt (renamed, +14/-22)
  • apps/android/app/src/main/java/ai/openclaw/app/node/InvokeDispatcher.kt (renamed, +14/-24)
  • apps/android/app/src/main/java/ai/openclaw/app/node/JpegSizeLimiter.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/node/LocationCaptureManager.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/node/LocationHandler.kt (renamed, +4/-20)
  • apps/android/app/src/main/java/ai/openclaw/app/node/MotionHandler.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/NodeUtils.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/NotificationsHandler.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/PhotosHandler.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/SmsHandler.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/SmsManager.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/node/SystemHandler.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/protocol/OpenClawCanvasA2UIAction.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/protocol/OpenClawProtocolConstants.kt (renamed, +1/-12)
  • apps/android/app/src/main/java/ai/openclaw/app/tools/ToolDisplay.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/CameraHudOverlay.kt (renamed, +1/-1)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/CanvasScreen.kt (renamed, +2/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/ChatSheet.kt (renamed, +3/-3)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/ConnectTabScreen.kt (renamed, +5/-2)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayConfigResolver.kt (renamed, +24/-6)
  • apps/android/app/src/main/java/ai/openclaw/app/ui/MobileUiTokens.kt (renamed, +2/-2)

PR #51348: fix: clear session model override when it matches config default

Description (problem / solution / changelog)

Fixes #44611 - Gateway restart now applies openclaw.json model changes

Root Cause

Session model overrides had higher priority than config file, preventing config updates from taking effect on restart.

Solution

Detect when session override matches current config default and clear it, allowing config changes to apply while preserving explicit user-set overrides.

Changes

  • Added logic to clear matching overrides in getReplyFromConfig()
  • Import updateSessionStore for session persistence
  • Fixed variable naming conflict (shouldCheckOverride)
  • Added 6 unit tests with 100% pass rate
  • Verified no regression in existing tests (25/25 pass)

Testing

  • ✅ 6 new unit tests cover all edge cases
  • ✅ All existing tests pass (25/25)
  • ✅ Compilation successful
  • ✅ Comprehensive code review completed

Impact

24 lines of core logic in src/auto-reply/reply/get-reply.ts

Changed files

  • src/auto-reply/reply/dispatch-from-config.ts (modified, +43/-0)
  • src/auto-reply/reply/get-reply.model-override-clear.unit.test.ts (added, +242/-0)
  • src/auto-reply/reply/get-reply.ts (modified, +24/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

The OpenClaw gateway is failing to apply model configuration changes from ~/.openclaw/openclaw.json after a service restart. It continues to use the model that was active before the configuration file was changed, effectively ignoring the updated settings on disk.

Steps to reproduce

  1. Configure ~/.openclaw/openclaw.json to use a specific model as the primary, for example: "primary":
    "google/gemini-2.5-pro".
  2. Start the gateway service (sudo systemctl start clawdbot.service).
  3. Connect to an agent and verify it is using the correct model.
  4. Modify ~/.openclaw/openclaw.json to change the primary model, for example: "primary": "anthropic/claude-opus-4-5".
  5. Restart the gateway service (sudo systemctl restart clawdbot.service).
  6. Connect to an agent and check its active model.

Expected behavior

The agent's active model should be anthropic/claude-opus-4-5, as defined in the now-modified openclaw.json file.

Actual behavior

The agent's active model remains google/gemini-2.5-pro. The gateway appears to be using a cached or stale
configuration and is not reloading the file from disk on restart.

OpenClaw version

OpenClaw Version: 2026.3.7

Operating system

Linux

Install method

No response

Model

google/gemini-2.5-pro

Provider / routing chain

openclaw -> gateway -> gemini

Config file / key location

No response

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

Troubleshooting Steps Performed

  • Verified file permissions and content of openclaw.json are correct.
  • Attempted restarts using file-watching (by saving the file), openclaw gateway restart, and sudo systemctl restart
    clawdbot.service.
  • A deep diagnostic (openclaw status --deep) revealed a conflicting and broken user-level systemd service, which has
    since been removed.
  • The issue persists even with a single, clean system-level service, indicating the problem is not with the service
    management environment but likely within the gateway's configuration loading logic itself.

extent analysis

Fix Plan

To resolve the issue of the OpenClaw gateway not applying model configuration changes from ~/.openclaw/openclaw.json after a service restart, we need to ensure that the configuration is reloaded properly.

Here are the steps to fix the issue:

  • Check Configuration Loading Logic: Review the OpenClaw gateway's configuration loading logic to ensure it reloads the configuration file on restart.
  • Implement Configuration Reload: Modify the gateway to reload the configuration file from disk on restart. This can be achieved by:
    • Adding a configuration reload mechanism in the gateway's startup script.
    • Using a file watcher to detect changes to the configuration file and reload it accordingly.
  • Example Code: In Python, you can use the watchdog library to watch for changes to the configuration file and reload it:

from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler

class ConfigReloadHandler(FileSystemEventHandler): def on_modified(self, event): if event.src_path == '~/.openclaw/openclaw.json': # Reload configuration logic here print("Configuration reloaded")

if name == "main": event_handler = ConfigReloadHandler() observer = Observer() observer.schedule(event_handler, path='~/.openclaw/', recursive=False) observer.start()

* **Verify Configuration Reload**: After implementing the configuration reload mechanism, verify that the gateway reloads the configuration file correctly by modifying the `openclaw.json` file and restarting the service.

### Verification
To verify that the fix worked:
* Restart the gateway service.
* Connect to an agent and check its active model.
* The agent's active model should match the one defined in the modified `openclaw.json` file.

### Extra Tips
* Ensure that the configuration file permissions and content are correct.
* Use a deep diagnostic tool like `openclaw status --deep` to identify any conflicting services or issues.
* Consider implementing a backup and restore mechanism for the configuration file to prevent data loss.

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…

FAQ

Expected behavior

The agent's active model should be anthropic/claude-opus-4-5, as defined in the now-modified openclaw.json file.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING