* feat(gateway): auto-apply safe doctor config migrations at startup Gateway startup now runs the same deterministic, prompt-free legacy config-key migrations as "openclaw doctor --fix" when an otherwise invalid single-file config can be fully migrated, instead of refusing readiness with a doctor hint. The write happens under the existing startup migration lease, after state migrations consume retired locators, only when the complete result validates including plugins, and keeps the previous config in the .bak ring. Configs using $include, Nix mode, newer-version configs, update-in-progress runs, and configs that stay invalid keep the current fail-closed refusal. This replaces the narrow two-key stable-upgrade repair with the full migration set (which subsumes it), so headless service gateways just work across upgrades instead of stopping on retired config keys. * fix(doctor): keep startup repair preview off the shared state database resolveStartupConfigSnapshot serves gateway pre-bootstrap selection and backup discovery, which run before state-database admission. The full planner resolves plugin doctor contracts through the installed-plugin registry, which opens the shared SQLite store — a broken store (or backup's pre-validation guarantee) must not break those callers. The preview tier now applies only state-free migrations with raw validation; the preflight committer and canonical-write matcher stay authoritative. * test(doctor): avoid shadowing the path module in repair fixtures * test(doctor): pin checkpoint build provenance for unbuilt test environments CI unit shards and unbuilt checkouts have no dist/build-info.json, so the checkpoint layer fails open by design and the startup-repair checkpoint assertions could never hold there. Wrap the real module with a pinned build identity so recording and needs-checks stay meaningful. * fix(doctor): reach plugin-owned migrations from the startup trust check The pre-bootstrap trust check admitted only state-free core migrations, so a config whose sole repair belongs to a plugin doctor contract was refused before the plugin-aware preflight could migrate it. The resolver now runs the full planner first and falls back to the state-free preview only when the installed-plugin registry store is unreachable, keeping backup discovery and broken-store startups fail-closed.
24 KiB
summary, read_when, title, sidebarTitle
| summary | read_when | title | sidebarTitle | |
|---|---|---|---|---|
| CLI reference for `openclaw config` (get/set/patch/unset/file/schema/validate) |
|
Config | Config |
Non-interactive helpers for openclaw.json: get/set/patch/unset a value by path, print the schema, validate, or print the active file path. Run openclaw config with no subcommand to open the same guided wizard as openclaw configure.
Root options
Repeatable guided-setup section filter when you run `openclaw config` without a subcommand.Guided sections: workspace, model, web, gateway, daemon, channels, plugins, skills, health.
Examples
openclaw config file
openclaw config file --json
openclaw config --section model
openclaw config --section gateway --section daemon
openclaw config schema
openclaw config schema --json
openclaw config get browser.executablePath
openclaw config set browser.executablePath "/usr/bin/google-chrome"
openclaw config set browser.profiles.work.executablePath "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
openclaw config set agents.defaults.heartbeat.every "2h"
openclaw config set logging.audit.executionIdentity true
openclaw config set 'agents.entries.main.tools.exec.node' "node-id-or-name"
openclaw config set agents.defaults.models '{"openai/gpt-5.4":{}}' --strict-json --merge
openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN
openclaw config set secrets.providers.vaultfile --provider-source file --provider-path /etc/openclaw/secrets.json --provider-mode json
openclaw config patch --file ./openclaw.patch.json5 --dry-run
openclaw config unset plugins.entries.brave.config.webSearch.apiKey
openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN --dry-run
openclaw config validate
openclaw config validate --json
Paths
Dot or bracket notation. Quote bracket paths in shell examples so zsh does not glob-expand [0]:
openclaw config get agents.defaults.workspace
openclaw config get agents.entries.main
openclaw config get agents.entries
openclaw config set 'agents.entries.work.tools.exec.node' "node-id-or-name"
Prefer agents.entries.<id> paths for agent edits. The legacy agents.list[0]
syntax and whole-list inputs still work with set, patch, and unset; writes
persist the canonical keyed roster. Indexed edits use the current roster order.
Within a batch, a submitted list keeps its order across subsequent keyed edits,
including when agent IDs are numeric strings. Existing roster-deletion and
$include ownership protections still apply.
config get
Reads a value from the redacted config snapshot (secrets never print). --json prints the same redacted value as JSON; otherwise strings/numbers/booleans print bare and objects/arrays print as formatted JSON.
A schema-valid but unset path explains that the runtime default applies; an unknown path suggests
openclaw config schema. With --json, both use the standard CLI JSON failure envelope
on stdout and exit with status 1. Without --json, diagnostics remain on stderr.
openclaw config get browser.executablePath
openclaw config get agents.defaults.model --json
config file
Prints the active config file path, resolved from OPENCLAW_CONFIG_PATH or the default location. The path names a regular file, not a symlink; see Write safety.
With --json, stdout contains an object with the resolved path under path.
config schema
Prints the generated JSON schema for openclaw.json to stdout.
openclaw config schema
openclaw config schema --json
openclaw config schema > openclaw.schema.json
The schema is JSON in both modes. --json is accepted as the explicit
machine-output spelling and keeps stdout reserved for the schema document.
config validate
Validates the current config against the active schema without starting the gateway. It also checks provider/source compatibility for every registry-declared SecretRef, including disabled plugin or channel configuration. This strict command can report an inactive mismatch that does not block normal Gateway startup, where SecretRef resolution remains limited to effectively active surfaces.
After schema validation, it checks every configured manual exec provider's command path using the same non-executing trust checks as startup: file presence, symlinks, trusted directories, permissions, ownership, and Windows ACL availability. config set, config patch, and config unset apply these checks only to providers changed or referenced by the operation, including during dry runs. Replacing the secrets or secrets.providers collection checks every remaining provider. An unrelated inactive provider does not block targeted repairs or removal of that provider.
Path validation does not execute providers or verify their output. Passing it does not guarantee successful secret resolution; exec dry runs require --allow-exec to test that separately.
openclaw config validate
openclaw config validate --json
Provider and runtime params bags are intentionally typed as
Record<string, unknown> because their owners define the supported keys and
values. openclaw config validate can validate the container and overall
config shape, but it cannot type-check provider-specific parameter names or
values. Passing validation does not prove that a param is supported; consult
the provider docs and verify behavior on the selected runtime and provider.
Values
Values parse as JSON5 when possible; otherwise they are treated as raw strings. Use --strict-json to require standard JSON with no string fallback (JSON5-only syntax such as comments, trailing commas, or unquoted keys is then rejected). --json is a legacy alias for --strict-json on config set.
openclaw config set agents.defaults.heartbeat.every "0m"
openclaw config set gateway.port 19001 --strict-json
openclaw config set channels.whatsapp.groups '["*"]' --strict-json
config get <path> --json prints the redacted value as JSON instead of terminal-formatted text.
When a write changes agents.defaults.model or a per-agent agents.entries.*.model, OpenClaw resolves each changed primary or fallback through the configured catalogs and the selected provider's model resolver before writing. Provider-supported exact provider/model pins are accepted even when absent from the curated picker; validation does not replace the selected model. Unknown model references are rejected without changing the active config. Run openclaw models list to browse the picker, or check the provider's documentation for an exact model ID. Successful validation does not prove that your account can call the model.
Use --merge when adding entries to those maps:
openclaw config set agents.defaults.models '{"openai/gpt-5.4":{}}' --strict-json --merge
openclaw config set models.providers.ollama.models '[{"id":"llama3.2","name":"Llama 3.2"}]' --strict-json --merge
Use --replace only when the provided value should intentionally become the complete target value.
config set modes
```bash
openclaw config set
```
```bash
openclaw config set channels.discord.token \
--ref-provider default \
--ref-source env \
--ref-id DISCORD_BOT_TOKEN
```
Targets `secrets.providers.` paths only:
```bash
openclaw config set secrets.providers.vault \
--provider-source exec \
--provider-command /usr/local/bin/openclaw-vault \
--provider-arg read \
--provider-arg openai/api-key \
--provider-timeout-ms 5000
```
```bash
openclaw config set --batch-file ./config-set.batch.json --dry-run
```
Batch files are limited to 8 MiB.
Batch parsing always uses the batch payload (--batch-json/--batch-file) as the source of truth; --strict-json / --json do not change batch parsing behavior.
Batch assignments apply in order, then validation checks the final config. A SecretRef replaced by a later assignment is not resolved or counted in dry-run output, even with --allow-exec. Providers that remain in a changed provider collection still receive command-path trust checks.
JSON path/value mode also works for SecretRefs and providers directly:
openclaw config set channels.discord.token \
'{"source":"env","provider":"default","id":"DISCORD_BOT_TOKEN"}' \
--strict-json
openclaw config set secrets.providers.vaultfile \
'{"source":"file","path":"/etc/openclaw/secrets.json","mode":"json"}' \
--strict-json
Provider builder flags
Provider builder targets must use secrets.providers.<alias> as the path.
Hardened exec provider example:
openclaw config set secrets.providers.vault \
--provider-source exec \
--provider-command /usr/local/bin/openclaw-vault \
--provider-arg read \
--provider-arg openai/api-key \
--provider-json-only \
--provider-pass-env VAULT_TOKEN \
--provider-trusted-dir /usr/local/bin \
--provider-timeout-ms 5000
config patch
Paste or pipe a config-shaped JSON5 patch instead of running many path-based config set commands. Objects merge recursively; arrays and scalar values replace the target; null deletes the target path.
openclaw config patch --file ./openclaw.patch.json5 --dry-run
openclaw config patch --file ./openclaw.patch.json5
Patch files are limited to 8 MiB. Piped --stdin patches are limited to 1 MiB.
Pipe a patch over stdin for remote setup scripts:
ssh user@gateway-host 'openclaw config patch --stdin --dry-run' < ./openclaw.patch.json5
ssh user@gateway-host 'openclaw config patch --stdin' < ./openclaw.patch.json5
Example patch:
{
channels: {
slack: {
enabled: true,
mode: "socket",
botToken: { source: "env", provider: "default", id: "SLACK_BOT_TOKEN" },
appToken: { source: "env", provider: "default", id: "SLACK_APP_TOKEN" },
groupPolicy: "open",
requireMention: false,
},
discord: {
enabled: true,
token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
dmPolicy: "disabled",
dm: { enabled: false },
groupPolicy: "allowlist",
},
},
agents: {
defaults: {
model: { primary: "openai/gpt-5.6-sol" },
models: {
"openai/gpt-5.6-sol": {
agentRuntime: { id: "openclaw" },
params: { fastMode: true },
},
},
},
},
}
The runtime pin makes this an embedded OpenClaw recipe. A valid fastMode
value is a portable typed runtime control and does not choose OpenClaw by
itself.
Use --replace-path <path> when one object or array must become exactly the provided value instead of being recursively patched:
openclaw config patch --file ./discord.patch.json5 --replace-path 'channels.discord.guilds["123"].channels'
--dry-run runs schema and SecretRef resolvability checks without writing. Exec-backed SecretRefs are skipped by default during dry-run; add --allow-exec when you intentionally want dry-run to execute provider commands.
Dry run
--dry-run validates changes without writing openclaw.json. Available on config set, config patch, and config unset.
openclaw config set channels.discord.token \
--ref-provider default \
--ref-source env \
--ref-id DISCORD_BOT_TOKEN \
--dry-run \
--json
openclaw config set channels.discord.token \
--ref-provider vault \
--ref-source exec \
--ref-id discord/token \
--dry-run \
--allow-exec
JSON output shape
{
ok: boolean,
operations: number,
configPath: string,
inputModes: ["value" | "json" | "builder" | "unset", ...],
checks: {
schema: boolean,
resolvability: boolean,
resolvabilityComplete: boolean,
},
refsChecked: number,
skippedExecRefs: number,
errors?: [
{
kind: "missing-path" | "schema" | "resolvability" | "model",
message: string,
ref?: string, // present for resolvability errors
},
],
}
Applying changes
After every successful config set / config patch / config unset, the CLI prints one of three hints so you know whether the gateway needs a restart:
| Hint | Meaning |
|---|---|
Restart the gateway to apply. |
The changed path needs a full restart. |
Change will apply without restarting the gateway. |
Hot reload picks it up automatically. |
No gateway restart needed. |
Nothing runtime-relevant changed. |
Effective changes to plugins.entries (or any subpath) require a restart, since the CLI cannot prove every plugin's reload metadata is loaded. Successful config set or config unset operations that produce no effective config diff print No change and leave the JSON5 file byte-for-byte untouched. A config unset target that is absent from the authored config exits with status 1 and also leaves the file untouched. Setting an absent key to a value equal to its runtime default is still an authored change and persists the explicit value.
Write safety
openclaw config set and other OpenClaw-owned config writers validate the full post-change config before committing it to disk. If the new payload fails schema validation or looks like a destructive clobber, the active config is left alone and the rejected payload is saved beside it as openclaw.json.rejected.*.
OpenClaw-owned writes that change config reserialize JSON5 as standard JSON. When the source contains comments, the writer warns immediately before removing them; use a direct editor when preserving comments matters.
The active config path must be a regular file. Symlinked `openclaw.json` layouts are unsupported for writes; use `OPENCLAW_CONFIG_PATH` to point directly at the real file instead.Prefer CLI writes for small edits:
openclaw config set gateway.reload.mode hybrid --dry-run
openclaw config set gateway.reload.mode hybrid
openclaw config validate
If a write is rejected, inspect the saved payload and fix the full config shape:
CONFIG="$(openclaw config file)"
ls -lt "$CONFIG".rejected.* 2>/dev/null | head
openclaw config validate
Direct editor writes are still allowed, but the running Gateway treats them as untrusted until they validate. At startup, eligible single-file configs can receive deterministic legacy-key migrations if the complete result validates, with the previous config kept in the .bak ring. Other invalid direct edits fail startup; hot reload skips invalid edits without rewriting openclaw.json. Run openclaw doctor --fix to repair prefixed/clobbered config or restore the last-known-good copy. See Gateway troubleshooting.
Whole-file recovery is reserved for doctor repair. Plugin schema changes or minHostVersion skew stay loud instead of rolling back unrelated user settings such as models, providers, auth profiles, channels, gateway exposure, tools, memory, browser, or cron config.
Repair loop
After openclaw config validate passes, use the local TUI to have an embedded agent compare the active config against the docs while you validate each change from the same terminal:
openclaw chat
Inside the TUI, a leading ! runs a literal local shell command (after a one-time per-session confirmation prompt):
!openclaw config file
!openclaw docs gateway auth token secretref
!openclaw config validate
!openclaw doctor