feat(core): let the model change working directory - #27932
Closed
fcoury-oai wants to merge 2 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4ebf65be2
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
fcoury-oai
force-pushed
the
fcoury/set-working-directory
branch
6 times, most recently
from
June 15, 2026 16:52
e67a279 to
da8b665
Compare
fcoury-oai
force-pushed
the
fcoury/set-working-directory
branch
from
June 15, 2026 17:10
da8b665 to
dd04b75
Compare
Contributor
|
Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Long-running Codex tasks can move beyond the directory where the session started. The model may need to continue from another checkout, repository, generated workspace, or other directory, but tool resolution remains pinned to the original cwd. Changing cwd outside the current workspace must also update the session-scoped permission boundary coherently because every later tool call inherits the new location.
The immediate use case that motivated this PR was my sibling Git worktree workflow: Codex can create the worktree, but the active session cannot continue naturally inside it and keeps resolving tools against the original checkout. This PR adds the smallest model-facing API needed to change the active cwd, without exposing a separate general-purpose workspace-root mutation tool or app-server API.
The new tool also exposed an existing Guardian failure mode. With
approvals_reviewer = "auto_review", requesting access to a sibling worktree starts a nested Guardian session on a dedicated thread. The default macOS pthread stack can overflow while that session materializes its turn context, aborting Codex withSIGABRTbefore the user can grant permission. This PR incorporates the focused fix from #26663 so the workflow is usable with automatic approval review.What changed
set_working_directory(path)tool for sessions with exactly one execution environment.SessionSettingsUpdateso cwd changes retain the existing implicit workspace-root retargeting behavior.How to Test
approvals_reviewer = "auto_review", on-request approvals, and workspace-write permissions.SIGABRTand approves the requested session scope.pwd, shell command, patch, or image read in the same model response resolves from the new worktree.Targeted tests:
just test -p codex-core set_working_directory_auto_review_updates_same_batch_shell_cwdjust test -p codex-core request_permissions_routes_to_guardian_when_reviewer_is_enabledjust test -p codex-core environment_count_controls_environment_backed_toolsLocal validation:
just test -p codex-core set_working_directory_auto_review_updates_same_batch_shell_cwdpassed.just test -p codex-core request_permissions_routes_to_guardian_when_reviewer_is_enabledpassed.just test -p codex-core environment_count_controls_environment_backed_toolspassed after rebasing onto currentmain.just fix -p codex-corejust test -p codex-corecompiled successfully and passed 2,725 tests. The run did not complete cleanly because this checkout's shell startup error contaminated subprocess-output assertions, two abort tests timed out, and one Guardian integration test timed out.sqlx 0.9, which requires Rust 1.94. The touched Rust callsites were inspected manually.