Skip to content

Agents silently mutate openclaw.json config (model/auth settings changed without user consent) #24237

@fwends

Description

@fwends

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 model field gets changed (e.g. set to kimi-coding/kimi-for-coding when it should be minimax/MiniMax-M2.5)
  • Auth profiles lose providers (e.g. anthropic profile disappears from auth-profiles.json)
  • The agents list in openclaw.json fluctuates 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

  1. Write guard: Log every write to openclaw.json with a stack trace
  2. Atomic writes with diff check: Before saving, diff against on-disk state and warn if unexpected fields changed
  3. Audit all config.save() callsites — any agent-triggered path that can overwrite user-set model fields or the agents list is a bug
  4. Lock file or mutex around config writes to prevent concurrent overwrites

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions