#model corrupts openclaw.json
21 messages · Page 1 of 1 (latest)
Let me check the docs and source so I don’t make up config behavior.
Short version: yes for a couple of cases, but not a fully generic self-healer yet.
What exists now:
- config writes use temp-file + replace, and keep backup rotation (
openclaw.json.bak,.bak.1....bak.4) openclaw doctor --fixalso writes a backup and repairs some config issues- there is a targeted auto-restore for the known “config got clobbered down to just
update.channel” case, it restores from.bakand saves the bad file asopenclaw.json.clobbered.<timestamp>
What does not exist today:
- arbitrary “model mangled
openclaw.jsonin some random way, recover everything automatically” recovery - with a single instance, once config is invalid, the Gateway does not fully boot, so you’re down to diagnostics/doctor, not normal agent behavior
So for truly no-human recovery on one box, I’d recommend:
- keep
openclaw.jsonmostly static - put model-managed bits in a separate
$includefile - only mutate via
openclaw config setorconfig.patch, not full-fileconfig.apply - add an out-of-band watchdog, systemd/cron/launcher, that validates and restores last good
.bakif load fails
That is the important bit: “fully automated” usually needs something outside the main agent loop, even if it’s on the same machine.
Docs:
- https://docs.openclaw.ai/help/faq
- https://docs.openclaw.ai/gateway/configuration
- https://docs.openclaw.ai/gateway/doctor
If you want, paste openclaw --version and I can sketch a concrete self-heal pattern for your setup.
config.patch?what is this?
config.patch is the partial-update config API.
Think of it like this:
config.apply= replace the wholeopenclaw.jsonconfig.patch= change only the bits you send
Semantics:
- objects merge recursively
nulldeletes a key- arrays replace the whole array
Example:
Current config:
{
gateway: { mode: "local", port: 18789 },
channels: { telegram: { enabled: true } }
}
Patch:
{ gateway: { port: 18888 } }
Result:
{
gateway: { mode: "local", port: 18888 },
channels: { telegram: { enabled: true } }
}
So it is much safer than config.apply if you only want to tweak one section.
Important bit:
- it is mainly a Gateway RPC / API method
- from shell, if you just want one simple change,
openclaw config set ...is usually easier - if a tool/UI/agent is doing programmatic edits,
config.patchis the safer choice
Typical RPC flow:
config.getto fetch current config +hashconfig.patchwith your partial object + thatbaseHash
If you want, I can show the exact same change done with:
config.patchopenclaw config set
side by side.
how to use config.patch?
config.patch is a Gateway RPC, so the usual flow is:
- get the current config hash
- send a partial patch with that hash
Example, change just gateway.port:
openclaw gateway call config.get --params '{}'
Take the returned hash, then:
openclaw gateway call config.patch --params '{
"raw": "{ gateway: { port: 18888 } }",
"baseHash": "<paste-hash-here>"
}'
What it does:
- merges objects
nulldeletes keys- arrays are fully replaced
Examples:
Set a nested field:
openclaw gateway call config.patch --params '{
"raw": "{ channels: { telegram: { enabled: true } } }",
"baseHash": "<hash>"
}'
Delete a section:
openclaw gateway call config.patch --params '{
"raw": "{ channels: { telegram: null } }",
"baseHash": "<hash>"
}'
Important:
baseHashmatters, it prevents overwriting someone else’s newer config- this is safer than
config.apply, because it does not replace the whole file
If you are just changing one key from shell, this is usually easier:
openclaw config set gateway.port 18888
So, practical rule:
- one key →
openclaw config set - partial programmatic update →
config.patch - full replacement →
config.apply
Docs: https://docs.openclaw.ai/gateway/configuration
If you want, I can give you a ready-made config.patch example for your exact change.
how to use and what this command can do : openclaw gateway call
Let me check the CLI docs so I give you the right shape.
openclaw gateway call is the low-level RPC client for a running Gateway.
Think of it as:
“send one raw RPC method call to the Gateway, with JSON params”
What it can do
Anything the Gateway exposes as an RPC method, for example:
statushealthconfig.getconfig.patchlogs.tail
So yes, it can do powerful stuff, including config reads/writes, but only through defined Gateway methods. It is not a generic shell runner.
Basic shape
openclaw gateway call <method> --params '<json>'
Examples:
openclaw gateway call status
openclaw gateway call health
openclaw gateway call logs.tail --params '{"sinceMs":60000}'
openclaw gateway call config.get --params '{}'
Important flags
--params <json>JSON object string, default is{}--jsonmachine-readable output--url <url>target a specific gateway--token/--passwordauth--timeout <ms>--expect-finalfor methods that stream intermediate events first
Important gotcha
--params must be valid JSON, not JSON5.
So this is valid:
--params '{"sinceMs":60000}'
This is not:
--params '{sinceMs:60000}'
When to use it
Good for:
- scripting
- debugging
- calling RPC methods that don’t have a nicer CLI wrapper yet
Usually easier alternatives exist for normal tasks:
- config key edits →
openclaw config set - health/status →
openclaw status,openclaw gateway status - repairs →
openclaw doctor