Skip to content

Preserve command cwd in permission and post-tool hooks - #57203

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/ef5dad2a0634dda9edb2f841ef4fe49ae0d1187d
Oct 26, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/ef5dad2a0634dda9edb2f841ef4fe49ae0d1187d

Conversation

@copyberry

@copyberry copyberry Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Preserve command cwd in permission and post-tool hooks

Why

PermissionRequest and PostToolUse hook inputs could report the turn's working directory instead of the local command's execution directory. This also affected commands whose results were collected in a later turn after the working directory changed.

What changed

  • Report the local command's execution directory in hook input cwd, consistent with PreToolUse.
  • Preserve the original directory through write_stdin approvals and delayed completion, including network permission requests.
  • Retain the host directory for remote commands and keep hook process working directories unchanged.

Testing

Add coverage for relative and absolute workdirs, approval denials, command rewrites, completion and stdin approval across turns, remote command fallback, network approvals, and Unix and Windows path formatting.

## Why

`PermissionRequest` and `PostToolUse` hook inputs could report the turn's working directory instead of the local command's execution directory. This also affected commands whose results were collected in a later turn after the working directory changed.

## What changed

- Report the local command's execution directory in hook input `cwd`, consistent with `PreToolUse`.
- Preserve the original directory through `write_stdin` approvals and delayed completion, including network permission requests.
- Retain the host directory for remote commands and keep hook process working directories unchanged.

## Testing

Add coverage for relative and absolute workdirs, approval denials, command rewrites, completion and stdin approval across turns, remote command fallback, network approvals, and Unix and Windows path formatting.

GitOrigin-RevId: ef5dad2a0634dda9edb2f841ef4fe49ae0d1187d
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/ef5dad2a0634dda9edb2f841ef4fe49ae0d1187d branch from 6f19373 to beb34ce Compare October 26, 2026 19:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T19:22:27.047573Z 6f19373 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@copyberry
copyberry Bot merged commit beb34ce into main Oct 26, 2026
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/ef5dad2a0634dda9edb2f841ef4fe49ae0d1187d branch October 26, 2026 19:21
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant