Repository navigation
feat(cli): run agent exec against the ambient config, composed in memory - #116038
Conversation
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.
|
Codex review: needs real behavior proof before merge. Reviewed July 29, 2026, 3:21 PM ET / 19:21 UTC. ClawSweeper reviewWhat this changesThe branch makes Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 6 items remain Keep this PR open. The in-memory configuration composition is a plausible fix, but it changes the established credential-source default from environment-only to config, stored-profile, and external-CLI discovery without maintainer-confirmed upgrade direction or real after-fix behavior proof. Priority: P1 Review scores
Verification
How this fits together
flowchart LR
A[CLI flags and prompt] --> B[Agent exec command]
C[Ambient or pinned config] --> D[In-memory config composition]
B --> D
D --> E[Credential and provider resolution]
E --> F[Agent runtime and harness selection]
F --> G[One-shot agent result]
Decision needed
Why: This is a user-visible credential and provider-routing contract change; tests can verify either implementation but cannot choose the upgrade policy. Before merge
Findings
Agent review detailsSecurityNeeds attention: The patch removes a temporary on-disk config exposure, but its new default broadens credential discovery for existing unattended CLI calls and needs explicit approval. PR surfaceSource +172, Tests +361, Docs +8, Other +5. Total +546 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep environment-only credential sourcing as the compatibility default and add an explicit, documented opt-in for ambient configuration, unless a maintainer deliberately accepts the credential-source default change with clear upgrade guidance and real behavior proof. Do we have a high-confidence way to reproduce the issue? Yes, from source: invoking Is this the best way to solve the issue? No. The in-memory composition avoids the temporary secret-bearing config file, but silently reversing the credential-source default is not the narrowest compatibility-safe solution without a maintainer product decision. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against 46ec7a43a8af. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
|
Merged via squash.
|
* origin/main: (39 commits) feat(apple): media renditions, Now Playing, video upload (#116051) feat(android): media renditions, MediaSession, video upload (#116037) feat(cli): run agent exec against the ambient config, composed in memory (#116038) fix #95351: [Feature]: Generic JSONL line-parsing hook for CliBackendPlugin (native tool-card support beyond claude-stream-json) (#95386) feat(plugins): allow per-turn tool narrowing in prompt hooks (#114151) docs(hooks): mark pairing hook observation-only (#116055) docs(control-ui): document composer capability menu (#115858) fix(build): bound declaration memory use (#116021) fix: Slack replies recover after gateway startup replay (#115991) fix(azure-speech): keep valid voices from malformed catalogs (#115067) fix(agents): prevent model runtime startup timeout (#116039) fix(ui): explain unavailable MCP tool catalogs (#115994) fix(skills): run experience review outside released request roots (#116040) docs(security): add safe Gmail reader setup (#116041) chore: refresh browser gateway runtime (#116043) test: isolate gateway sequence lifecycle coverage docs: note gateway reconnect sequence fix test: cover gateway sequence reset on restart test: cover gateway sequence reset on reconnect fix: reset gateway event sequence on reconnect ...
…ory (openclaw#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
What Problem This Solves
openclaw agent execignored the operator's config entirely. A one-shot turn could not reach configured providers, credentials, oragentRuntimeharness selection, socodeModeEngagedcame backfalseon a machine where code mode was enabled, and a configured Codex/Pi harness silently did not apply. Exec is the folder-scoped coding entrypoint; behaving unlikecodexorclaude, which always read their configuration, made it surprising.It also wrote its config to a temporary file and repointed
OPENCLAW_CONFIG_PATHat it.Why This Change Was Made
Config is now layered in three parts and composed in memory:
codingtool profile, fs restricted to--cwd, full exec policy for a headless turn).--cwd, never bootstraps, and explicit flags outrank the resolved config.The temp file is gone.
clearConfigCacheis a no-op shim whose comment states "runtime snapshot is the only in-process cache now", sosetRuntimeConfigSnapshotis the actual config mechanism — the file was a disk round trip to reach an in-memory setter. Harmless when it held five hardcoded defaults; once it held a real config it wrote${ENV}-substituted provider keys to a same-UID file the run's ownexectool could read, defeating env-var indirection. Nothing in the exec path spawns a subprocess that readsOPENCLAW_CONFIG_PATH, and no agent or tool path callswriteConfigFile, so the file justified nothing.Config fields that outrank invocation-owned facts are stripped from the run config rather than overlaid, because a deep merge cannot remove a key:
agents.entries.*.agentDirbeats the state dir for session and transcript storage, so an ephemeral run would write state into the operator's persistent agent directory where deleting the temp state dir cannot reach it.agents.entries.*.runtime.acp.cwdbeats--cwd, so a native harness could edit the wrong repository. (agents.bindings[].acp.cwdneeds no equivalent: exec runs no channel, so no binding matches.)Stored-credential lookup deliberately reads the pre-strip base via
resolveDefaultAgentDir(baseConfig). Run state must be ephemeral, but credential ownership must still follow the operator's configured agent directory, or a run authenticates against the wrong profile store.--auth-env-onlynow reads no config at all, and pairing it with--configis rejected rather than silently ignored. Sanitizing was whack-a-mole:apiKey, then secretheaders, thenrequest.auth, then an inlineenvblock, then login-shell import. A config is a credential store by design, so the only closed way to promise environment-only credentials is not to read one.Both process globals the command touches — the runtime config snapshot and config-applied env vars — are captured before resolution and restored during cleanup, so a programmatic caller gets its own state back.
User Impact
openclaw agent execnow behaves like the other folder-scoped coding CLIs: configured providers, credentials, and harness selection apply, andcodeModeEngagedreports truthfully.Two behavior changes worth calling out:
--configis read through the normal loader, so JSON5 syntax and$includeresolve relative to it.Escape hatches are unchanged in spirit:
--isolatedignores the ambient config,--config <path>pins an exact file, and--auth-env-onlyrestricts credentials to the process environment.Known limitation, documented in
docs/cli/agent.md: the state directory is also where installed plugins live, so the default ephemeral one cannot discover plugins installed withopenclaw plugins install. If your config selects a provider or harness from a non-bundled plugin, use--state-dir ~/.openclaw. Splitting those two meanings ofOPENCLAW_STATE_DIRis a separate change.Evidence
node scripts/run-vitest.mjs src/commands/agent-exec.test.ts— 47 passed.node scripts/run-vitest.mjs src/config— 2933 passed across 212 files.node scripts/run-tsgo.mjs -p tsconfig.json --noEmit— clean.gpt-5.6-sol, xhigh): clean, no accepted/actionable findings.Mutation-checked rather than assumed — each of these fails its test when the production line is broken and passes when restored:
setRuntimeConfigSnapshot(runConfig)→clearRuntimeConfigSnapshot()resolveDefaultAgentDir(baseConfig)→resolveDefaultAgentDir({})Two review findings were rejected with evidence rather than patched, and both are pinned by tests or comments:
createConfigIO(...).loadConfig()cannot be shadowed by a published runtime snapshot (that is the factory loader, which reads the file directly; only the module-level loader pins), and a failed config load leaks no env vars (applyConfigEnvVarsruns last inside the try, and the loader restores from its own catch).Guard allowlist
src/commands/agent-exec.tsis added toPROCESS_BOUNDARY_DIRECT_CONFIG_LOAD_FILESinscripts/lib/config-boundary-guard.mjs, alongside the two existing CLI entries. The guard's own message sanctionsgetRuntimeConfig()"at an explicit process boundary", and that is exactly what the ambient path uses.--config <path>cannot:getRuntimeConfig()reads the ambient location and resolves from an already published runtime snapshot, so it cannot express a pinned run. The file-scoped loader is the point of the flag, and the accompanying test asserts a pinned config is not shadowed by a snapshot.