-
-
Notifications
You must be signed in to change notification settings - Fork 69.3k
Race condition in agents.create: runtimeConfigSnapshot not invalidated, causing agents.update to fail on second WebSocket connection #37175
Description
Bug Report
Summary
When Mission Control (or any client) calls agents.create followed immediately by agents.update on a separate WebSocket connection, the agents.update fails with agent not found despite the agent having been successfully created 8ms earlier.
Root Cause
In daemon-cli.js, the local writeConfigFile function calls clearConfigCache() but does not reset runtimeConfigSnapshot. This means the in-memory snapshot remains stale after a config write. Any subsequent loadConfig() call on a different connection returns the old snapshot, which doesn't include the newly created agent.
async function writeConfigFile(cfg, options = {}) {
clearConfigCache(); // ✅ clears disk cache
// ❌ runtimeConfigSnapshot is NOT reset here
// ...
}Fix
Add runtimeConfigSnapshot = null; immediately after clearConfigCache() in the local writeConfigFile in daemon-cli.js:
async function writeConfigFile(cfg, options = {}) {
clearConfigCache();
runtimeConfigSnapshot = null; // ← add this line
// ...
}Reproduction
- Configure a fresh OpenClaw gateway
- Pair it with Mission Control
- Observe:
agents.createsucceeds,agents.updatefails 8ms later withagent not found - MC generates a new UUID on every retry — pairing never completes
Log Evidence
agents.create ✓ 51ms conn=eb477c21
agents.update ✗ 1ms conn=549eea83 — agent not found
[reload] config change applied ← 500ms too late
Impact
Every new OpenClaw instance paired with Mission Control fails on first setup. The workaround (manually patching daemon-cli.js) is not acceptable for production deployments.
Version
OpenClaw 2026.3.2 (85377a2)