#11854: fix: resolve per-agent tools.exec config in pi-tools
agents
stale
Cluster:
Cron Session Enhancements
## Summary
`resolveExecConfig()` in `pi-tools.ts` only reads global `tools.exec` config, ignoring agent-specific overrides in `agents.list[].tools.exec`. This causes agents configured with restricted exec settings (e.g., `security: "allowlist"`, `host: "gateway"`) to silently inherit global defaults, potentially running with more permissive settings than intended.
- Update `resolveExecConfig` to accept `agentId` and merge agent-specific config with `??` fallback
- Follow the same pattern already used in `directive-handling.impl.ts` (`resolveExecDefaults`)
- `agentId` was already available in scope (resolved by `resolveEffectiveToolPolicy`)
Closes #11832
## Test plan
- [x] Added unit tests for `resolveExecConfig` covering:
- Global-only config (no agent override)
- Agent-specific config overriding global
- Partial agent override (non-overridden fields fall back to global)
- Undefined config handled gracefully
- [x] Existing `pi-tools-agent-config`, `pi-tools.safe-bins` tests pass
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates `resolveExecConfig()` in `src/agents/pi-tools.ts` to merge global `tools.exec` config with per-agent overrides from `agents.list[].tools.exec`, using `agentId` (already resolved by `resolveEffectiveToolPolicy`) to select the agent scope. It also adds a new Vitest suite covering global-only config, full and partial agent overrides, and undefined config.
This fits into the tool wiring in `createOpenClawCodingTools()` by ensuring the `exec`/`process` tools receive the correct agent-scoped defaults rather than silently inheriting global settings, aligning behavior with other agent-scoped config resolution patterns in the codebase.
<h3>Confidence Score: 4/5</h3>
- This PR is close to safe to merge, but there is one agent-scoped config hole remaining.
- The core change (merging agent exec settings with global defaults) is straightforward and covered by unit tests. However, apply-patch configuration is still sourced only from the global `tools.exec.applyPatch` path, so agent-level overrides for that nested config won’t work despite the rest of exec config being agent-aware.
- src/agents/pi-tools.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#14734: test(agents): guard against stale allowAgents in existing sessions
by davidahmann · 2026-02-12
83.0%
#11816: fix(cron): forward agent-specific exec config to isolated cron sess...
by AnonO6 · 2026-02-08
83.0%
#10189: fix: resolve file_path param in tool display for read/write tools
by Yida-Dev · 2026-02-06
79.8%
#10261: fix(agents): prevent exec tool errors from leaking to channels (#9651)
by nu-gui · 2026-02-06
79.5%
#10975: fix: add missing clientTools parameter to runEmbeddedAttempt call
by xamdel · 2026-02-07
79.3%
#4897: fix: config logic issues (#4689, #4654)
by lailoo · 2026-01-30
79.0%
#8332: fix: add per-tool-call timeout to prevent agent hangs (v2 - fixes m...
by vishaltandale00 · 2026-02-03
78.9%
#11300: feat(exec): make shell configurable via tools.exec.shell
by imjszhang · 2026-02-07
78.4%
#18934: fix(agents): suppress exec tool output from channel delivery
by BinHPdev · 2026-02-17
78.4%
#3872: improve bash-tools.exec.ts code quality
by Bestom927 · 2026-01-29
78.1%