fix: inherit exec policy for /bash chat sessions#50392
Conversation
Greptile SummaryThis PR fixes
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/auto-reply/reply/bash-command.ts
Line: 337-339
Comment:
**Unused `execPolicy` variable for three fields**
`execPolicy` was introduced on line 336 to avoid repeated optional-chain lookups, but the three lines below still access `params.cfg.tools?.exec?.` directly instead of using it. This is a minor inconsistency worth cleaning up.
```suggestion
const timeoutSec = execPolicy?.timeoutSec;
const notifyOnExit = execPolicy?.notifyOnExit;
const notifyOnExitEmptySuccess = execPolicy?.notifyOnExitEmptySuccess;
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/auto-reply/reply/bash-command.ts
Line: 349
Comment:
**`approvalRunningNoticeMs` not forwarded from exec policy**
`ExecToolConfig` has an `approvalRunningNoticeMs` field that controls how long before a running notice is emitted when an approval-backed exec runs for a long time. `ExecToolDefaults` accepts this field as well. Since this PR is about inheriting the full exec policy into `/bash` sessions, it is worth forwarding this field here alongside the other policy fields. If omitted, the tool silently falls back to its internal default (10 000 ms), which may not match what the operator configured.
Consider adding `approvalRunningNoticeMs: execPolicy?.approvalRunningNoticeMs` to the `createExecTool` call.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "fix: inherit exec po..." |
| const timeoutSec = params.cfg.tools?.exec?.timeoutSec; | ||
| const notifyOnExit = params.cfg.tools?.exec?.notifyOnExit; | ||
| const notifyOnExitEmptySuccess = params.cfg.tools?.exec?.notifyOnExitEmptySuccess; |
There was a problem hiding this comment.
Unused
execPolicy variable for three fields
execPolicy was introduced on line 336 to avoid repeated optional-chain lookups, but the three lines below still access params.cfg.tools?.exec?. directly instead of using it. This is a minor inconsistency worth cleaning up.
| const timeoutSec = params.cfg.tools?.exec?.timeoutSec; | |
| const notifyOnExit = params.cfg.tools?.exec?.notifyOnExit; | |
| const notifyOnExitEmptySuccess = params.cfg.tools?.exec?.notifyOnExitEmptySuccess; | |
| const timeoutSec = execPolicy?.timeoutSec; | |
| const notifyOnExit = execPolicy?.notifyOnExit; | |
| const notifyOnExitEmptySuccess = execPolicy?.notifyOnExitEmptySuccess; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/bash-command.ts
Line: 337-339
Comment:
**Unused `execPolicy` variable for three fields**
`execPolicy` was introduced on line 336 to avoid repeated optional-chain lookups, but the three lines below still access `params.cfg.tools?.exec?.` directly instead of using it. This is a minor inconsistency worth cleaning up.
```suggestion
const timeoutSec = execPolicy?.timeoutSec;
const notifyOnExit = execPolicy?.notifyOnExit;
const notifyOnExitEmptySuccess = execPolicy?.notifyOnExitEmptySuccess;
```
How can I resolve this? If you propose a fix, please make it concise.| safeBins: execPolicy?.safeBins, | ||
| safeBinTrustedDirs: execPolicy?.safeBinTrustedDirs, | ||
| safeBinProfiles: execPolicy?.safeBinProfiles, | ||
| timeoutSec, |
There was a problem hiding this comment.
approvalRunningNoticeMs not forwarded from exec policy
ExecToolConfig has an approvalRunningNoticeMs field that controls how long before a running notice is emitted when an approval-backed exec runs for a long time. ExecToolDefaults accepts this field as well. Since this PR is about inheriting the full exec policy into /bash sessions, it is worth forwarding this field here alongside the other policy fields. If omitted, the tool silently falls back to its internal default (10 000 ms), which may not match what the operator configured.
Consider adding approvalRunningNoticeMs: execPolicy?.approvalRunningNoticeMs to the createExecTool call.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/bash-command.ts
Line: 349
Comment:
**`approvalRunningNoticeMs` not forwarded from exec policy**
`ExecToolConfig` has an `approvalRunningNoticeMs` field that controls how long before a running notice is emitted when an approval-backed exec runs for a long time. `ExecToolDefaults` accepts this field as well. Since this PR is about inheriting the full exec policy into `/bash` sessions, it is worth forwarding this field here alongside the other policy fields. If omitted, the tool silently falls back to its internal default (10 000 ms), which may not match what the operator configured.
Consider adding `approvalRunningNoticeMs: execPolicy?.approvalRunningNoticeMs` to the `createExecTool` call.
How can I resolve this? If you propose a fix, please make it concise.|
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Keep this PR open. Current main still does not implement the intended Best possible solution: Keep this PR open and update it, or apply an equivalent current-main patch, so What I checked:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 6d323ee73640. |
Summary
tools.execpolicy in/bashchat sessionscreateExecTool(...)/bashpolicy inheritanceProblem
/bashcreated an exec tool with elevated defaults but did not inherit configuredtools.execpolicy. In host-troubleshooting setups this caused/bashto fall back to approval-pending behavior even when the instance was explicitly configured with host exec policy such astools.exec.security=fullandtools.exec.ask=off.Testing
src/auto-reply/reply/bash-command.test.ts