-
-
Notifications
You must be signed in to change notification settings - Fork 56.3k
Description
Problem
Agents are silently modifying ~/.openclaw/openclaw.json — specifically changing agent model settings and the agents list — without any user action or consent. This causes the entire system to break.
Real-world impact: Config has been corrupted 15+ times in a single morning session, causing 4+ hours of lost productivity. Every time the config gets changed, the user has to diagnose what broke, find which field was overwritten, and manually restore it.
What's happening
- Main agent
modelfield gets changed (e.g. set tokimi-coding/kimi-for-codingwhen it should beminimax/MiniMax-M2.5) - Auth profiles lose providers (e.g.
anthropicprofile disappears fromauth-profiles.json) - The agents list in
openclaw.jsonfluctuates wildly — goes from 10 agents down to 1, then back to 8, then none work - No log, no warning, no indication that the config was modified
- Nothing in the UI indicates a write happened
Root cause hypothesis
Everything lives in one monolithic openclaw.json. Any agent or gateway process that writes config rewrites the whole file. With multiple agents running concurrently, they race each other — last writer wins — and whichever agent wrote last dictates what models, auth, and agent list the whole system sees.
Proposed fix: separate per-agent config files
Instead of one shared openclaw.json, consider:
- One file per agent:
~/.openclaw/agents/<id>/config.json— owned by that agent only, never touched by other agents - One function, one export per config concern: model selection, auth, agent list, routing — each in its own file/module with a single owner
- A read-only master registry that lists agent IDs but delegates all per-agent settings to per-agent files
- The gateway assembles the full picture at runtime but never merges everything back into one file
This way:
- Agent A changing its model can't affect Agent B
- The agents list can't be accidentally truncated by a concurrent write
- Each agent config is independently lockable/auditable
Current impact
- 10 agents configured → agents list gets overwritten → drops to 1, then 3, then 8, then 0
- Main agent model resets to wrong provider
- Auth profiles lose entries
- Result: nothing works until manually diagnosed and restored
Suggested immediate mitigations
- Write guard: Log every write to
openclaw.jsonwith a stack trace - Atomic writes with diff check: Before saving, diff against on-disk state and warn if unexpected fields changed
- Audit all
config.save()callsites — any agent-triggered path that can overwrite user-set model fields or the agents list is a bug - Lock file or mutex around config writes to prevent concurrent overwrites