openclaw - ✅(Solved) Fix [Bug]: Gateway writes gateway.auth.token to user config on startup, triggering self-induced config change detection and full restart loop [1 pull requests, 2 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#58620Fetched 2026-04-08 02:00:04
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2referenced ×2closed ×1

Gateway writes gateway.auth.token to user config on startup, triggering self-induced config change detection and full restart loop

Root Cause

  1. Run OpenClaw gateway as a LaunchAgent on macOS (always-on deployment)
  2. Gateway starts and writes runtime state (gateway.auth.token, meta.lastTouchedAt, wizard.lastRunAt, session, skills) back into ~/.openclaw/openclaw.json
  3. The config file watcher detects the write
  4. Because gateway.auth.token is under the gateway.* prefix (restart-required in the hot-reload matrix), the gateway schedules a full process restart
  5. Restart triggers another startup → another state write → another detection → loop

Fix Action

Fix / Workaround

Workaround: None available. gateway.reload.mode is section-based with no field-level exclusion.

PR fix notes

PR #58678: fix: treat gateway.auth and gateway.controlUi as no-op in reload plan (#58620)

Description (problem / solution / changelog)

Summary

Fixes #58620.

At startup, ensureGatewayStartupAuth auto-generates and persists gateway.auth.token to the config file. Similarly, maybeSeedControlUiAllowedOriginsAtStartup writes gateway.controlUi.allowedOrigins. The config file watcher (started later) detects these writes and matches them against the catch-all { prefix: "gateway", kind: "restart" } rule in BASE_RELOAD_RULES_TAIL, triggering a full gateway restart — which regenerates the token — creating an infinite restart loop.

Changes

  • Added { prefix: "gateway.auth", kind: "none" } and { prefix: "gateway.controlUi", kind: "none" } rules to BASE_RELOAD_RULES in src/gateway/config-reload-plan.ts. These take precedence over the catch-all gateway restart rule in TAIL, preventing the self-induced restart loop.
  • Added test coverage for gateway.auth.token, gateway.auth.mode, and gateway.controlUi.allowedOrigins paths to verify they are classified as no-op.

Test plan

  • pnpm test -- src/gateway/config-reload.test.ts — all 30 tests pass

Changed files

  • src/gateway/config-reload-plan.ts (modified, +8/-0)
  • src/gateway/config-reload.test.ts (modified, +28/-0)

Code Example

Log excerpt from ~/.openclaw/logs/gateway.log showing the cycle:

16:00:43 [reload] config change detected; evaluating reload (meta.lastTouchedAt, wizard.lastRunAt, wizard.lastRunCommand, tools.profile, gateway.auth.token, session, skills)
16:01:04 [gateway] signal SIGTERM received
16:01:04 [gateway] received SIGTERM; shutting down

gateway.auth.token is under the gateway.* restart-required prefix in the hot-reload matrix. No reloadIgnore field exists in the config schema to exclude housekeeping fields. Confirmed via openclaw config schema inspection and docs.

Workaround: None available. gateway.reload.mode is section-based with no field-level exclusion.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Gateway writes gateway.auth.token to user config on startup, triggering self-induced config change detection and full restart loop

Steps to reproduce

  1. Run OpenClaw gateway as a LaunchAgent on macOS (always-on deployment)
  2. Gateway starts and writes runtime state (gateway.auth.token, meta.lastTouchedAt, wizard.lastRunAt, session, skills) back into ~/.openclaw/openclaw.json
  3. The config file watcher detects the write
  4. Because gateway.auth.token is under the gateway.* prefix (restart-required in the hot-reload matrix), the gateway schedules a full process restart
  5. Restart triggers another startup → another state write → another detection → loop

Expected behavior

Internal gateway state writes on startup should not trigger the config change detection restart loop. Either runtime state should be written to a separate file, or the file watcher should distinguish between gateway-initiated writes and external writes, or housekeeping fields should be excluded from restart-triggering change detection.

Actual behavior

Gateway takes 5-6 minutes to stabilize after any restart due to the self-induced restart loop. Any external health monitor that fires a kickstart during this window compounds the loop. The gateway appears dead during the full stabilization window.

OpenClaw version

2026.3.8 (3caab92)

Operating system

macOS 26.4 (macmini)

Install method

npm

Model

anthropic/claude-sonnet-4-6

Provider / routing chain

anthropic

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Log excerpt from ~/.openclaw/logs/gateway.log showing the cycle:

16:00:43 [reload] config change detected; evaluating reload (meta.lastTouchedAt, wizard.lastRunAt, wizard.lastRunCommand, tools.profile, gateway.auth.token, session, skills)
16:01:04 [gateway] signal SIGTERM received
16:01:04 [gateway] received SIGTERM; shutting down

gateway.auth.token is under the gateway.* restart-required prefix in the hot-reload matrix. No reloadIgnore field exists in the config schema to exclude housekeeping fields. Confirmed via openclaw config schema inspection and docs.

Workaround: None available. gateway.reload.mode is section-based with no field-level exclusion.

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

  • The gateway can be fixed by excluding housekeeping fields like gateway.auth.token from restart-triggering change detection, possibly by introducing a reloadIgnore field in the config schema.

Guidance

  • Review the hot-reload matrix to understand which fields trigger a restart and consider updating it to exclude gateway.* fields that are written on startup.
  • Investigate adding a reloadIgnore field to the config schema to allow excluding specific fields from change detection.
  • Consider writing runtime state to a separate file to prevent self-induced config change detection.
  • Evaluate the gateway.reload.mode configuration to see if there are any existing options to achieve field-level exclusion.

Example

No code snippet is provided as the issue does not imply a specific code change.

Notes

The provided logs and issue description suggest that the problem is related to the config change detection mechanism and the hot-reload matrix. However, without more information about the config schema and the hot-reload matrix, it's difficult to provide a precise solution.

Recommendation

Apply workaround: Introduce a reloadIgnore field in the config schema to exclude housekeeping fields like gateway.auth.token from restart-triggering change detection, as this seems to be the most straightforward way to address the issue without modifying the underlying logic of the gateway.

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

Internal gateway state writes on startup should not trigger the config change detection restart loop. Either runtime state should be written to a separate file, or the file watcher should distinguish between gateway-initiated writes and external writes, or housekeeping fields should be excluded from restart-triggering change detection.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING