mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
feat(cli): run agent exec against the ambient config, composed in memory (#116038)
* feat(cli): run agent exec against the ambient config, composed in memory Exec previously ignored the operator's config entirely, so a one-shot turn could not reach configured providers, credentials, or agentRuntime harness selection. It now layers config the way other folder-scoped coding CLIs do. The composed config is published as this process's runtime snapshot rather than serialized to a temp file and re-read through OPENCLAW_CONFIG_PATH. The snapshot is the only in-process config cache, so the file only ever fed it -- while writing env-substituted provider keys to disk where the run's own exec tool could read them. * fix(cli): resolve exec stored credentials from the configured agent dir * chore(scripts): allow agent exec the file-scoped config loader at its process boundary * test(cli): cover the exec credential default and pinned-config flags
This commit is contained in:
committed by
GitHub
parent
d2f2123da5
commit
d6f9affe79
+13
-5
@@ -24,11 +24,17 @@ openclaw agent exec --message-file task.md --cwd ./repo
|
||||
cat task.md | openclaw agent exec --message-file - --json
|
||||
```
|
||||
|
||||
By default, the command creates and later removes a temporary state directory. Its implicit config skips workspace bootstrap files, disables the agent sandbox, selects the `coding` tool profile, restricts filesystem tools to `--cwd`, and enables full Gateway-host execution policy for the embedded local tool runtime. `--cwd` defaults to the process working directory and is passed as both the agent workspace and tool working directory.
|
||||
By default, the command creates and later removes a temporary state directory, and it runs against your ordinary OpenClaw config, so configured providers, credentials, and `agentRuntime` harness selection apply exactly as they do elsewhere. `--cwd` defaults to the process working directory and is passed as both the agent workspace and tool working directory.
|
||||
|
||||
Use `--state-dir <dir>` to retain sessions and other run state. The directory must already exist and is never created or deleted by the command. The command still uses its isolated implicit policy config; it does not read the ordinary OpenClaw config from that directory.
|
||||
Config is layered in three parts, entirely in memory: exec composes the run config and publishes it as this process's runtime config rather than writing a copy to disk. Exec defaults apply only where your config leaves a setting unset: workspace bootstrap files are skipped, the agent sandbox is off, the `coding` tool profile is selected, filesystem tools are restricted to `--cwd`, and exec runs under the full execution policy a headless turn needs. Anything your config sets wins over those defaults, so a configured sandbox, shell env, or tool profile is never downgraded, and exec host routing stays with the sandbox when your config enables one. The invocation itself always wins last: the run is scoped to `--cwd` and never bootstraps.
|
||||
|
||||
`--auth-env-only` is enabled by default. In this mode, the run can use provider keys already present in the process environment, but it does not load OpenClaw auth profiles or external Codex, Claude, or other CLI credential stores. Provider auth variables remain available to model authentication but are omitted from agent-launched host commands. Use `--no-auth-env-only` only when the run intentionally relies on those stored credentials.
|
||||
Use `--state-dir <dir>` to retain sessions and other run state. The directory must already exist and is never created or deleted by the command.
|
||||
|
||||
The state directory is also where installed plugins live, so the default ephemeral one cannot discover plugins you installed with `openclaw plugins install`. If your config selects a provider, channel, or harness from a non-bundled plugin, point the run at your real state directory with `--state-dir ~/.openclaw`.
|
||||
|
||||
For reproducible runs, pin the config instead of inheriting it. `--config <path>` runs against exactly that config file, read through the normal loader so JSON5 syntax and `$include` resolve relative to it; a missing or invalid file fails the run rather than falling back to defaults, as does an ambient config that exists but cannot be parsed. `--isolated` ignores the ambient config entirely and uses only the exec defaults above. Both are the right choice for CI, where inheriting operator state would make runs machine-dependent.
|
||||
|
||||
Stored credentials are used by default, so a folder-scoped run reaches the same logins as the rest of the CLI. Pass `--auth-env-only` to restrict the run to provider keys already present in the process environment. That mode loads no config at all, and pairing it with `--config` is rejected rather than silently ignored, because a config supplies provider credentials through several surfaces at once: [inline keys and secret headers](/reference/secretref-credential-surface), an `env` block, and login-shell import. It also skips OpenClaw auth profiles and external Codex, Claude, or other CLI credential stores. Provider auth variables remain available to model authentication but are omitted from agent-launched host commands.
|
||||
|
||||
Select a primary and ordered fallback chain with repeatable flags:
|
||||
|
||||
@@ -107,13 +113,15 @@ This is evaluation-only evidence, not a CI or release gate. Results do not chang
|
||||
- `--message-file <path>`: read a UTF-8 prompt from a file; `-` reads stdin
|
||||
- `--cwd <dir>`: set both the agent workspace and tool working directory
|
||||
- `--state-dir <dir>`: use an existing state directory without deleting it
|
||||
- `--config <path>`: run against this config file instead of the ambient config (JSON5 and `$include` supported)
|
||||
- `--isolated`: ignore the ambient config and use only exec defaults
|
||||
- `--model <provider/model>`: explicit primary model
|
||||
- `--code-mode <mode>`: select `direct`, `auto`, or forced `code` tool mode
|
||||
- `--local-model-lean`: use the reduced local-model tool surface
|
||||
- `--thinking <level>`: one-run thinking level
|
||||
- `--fallback <provider/model>`: ordered fallback model; repeatable and requires `--model`
|
||||
- `--auth-env-only`: ignore stored and external CLI credentials (default)
|
||||
- `--no-auth-env-only`: allow stored and external CLI credentials
|
||||
- `--auth-env-only`: use only environment provider keys; skips stored credentials, external CLI credentials, and config entirely
|
||||
- `--no-auth-env-only`: allow stored and external CLI credentials (default)
|
||||
- `--timeout <seconds>`: deadline in seconds (default `600`; `0` disables it)
|
||||
- `--json`: emit the stable JSON envelope
|
||||
|
||||
|
||||
Reference in New Issue
Block a user