New handoff to worktree doesn't use environments
What version of the Codex App are you using (From “About Codex” dialog)?
Version 26.417.41555 (1858)
What subscription do you have?
Pro Lite
What platform is your computer?
Darwin 25.4.0 arm64 arm
What issue are you seeing?
When creating a new conversation using a new worktree, you get to choose environment which sets up stuff for you for the worktree. Now, if I'm working in a local thread and I want to hand it off to a new worktree, it creates the worktree but without the environment. I think there should maybe be an option to select the environment when handing off a local thread to worktree (for the first time). The environment is already setup in the case of creating new worktree with environment, handoff to local and handoff back to worktree.
What steps can reproduce the bug?
- Start a thread in a project locally.
- At the work locally drop down, click handoff to worktree.
It'll create a new worktree and branch but without the environment.
What is the expected behavior?
We should be allowed to choose environment when handing off to worktree for the first time.
Additional information
_No response_
3 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Can confirm a very concrete worktree-env bug here: in Codex Desktop, the worktree shell/handoff path appears to drop
SSH_AUTH_SOCKeven when the original shell has it.That breaks signed git flows in the worktree:
SSH_AUTH_SOCKis present,ssh-add -lshows my key, signed commits workSSH_AUTH_SOCKis empty, sogit commit -S/ signedgit rebasefail because git cannot talk to the existing ssh-agentI also verified this is not a limitation of git worktrees themselves. From the main-repo Codex shell I successfully created a signed commit in a plain non-worktree clone. From the worktree Codex shell, I used that same plain clone and the signed commit failed. Same repo, same clone, same key config; only the worktree-shell environment changed.
This feels like a specific worktree/handoff variant of #14064: the worktree session is not inheriting the existing auth/session environment, and
SSH_AUTH_SOCKis one of the missing variables.Similar issue for me, when working on a codex web session locally and handing off to a local worktree, the environment also would not pass along.
This is my workaround until this can be fixed.
Add this function to your ~/.zshrc (or ~/.bashrc), then run
source ~/.zshrcor open a new terminal to load it. After that,cdinto any orphan worktree and runcodex-sync-envto pull your .codex/ config over from the main checkout.```# in your ~/.zshrc or ~/.bashrc
codex-sync-env() {
local main_root
main_root="$(git worktree list --porcelain | awk '/^worktree/{print $2; exit}')"
if [ -z "$main_root" ] || [ "$main_root" = "$PWD" ]; then
echo "Not in a linked worktree" >&2
return 1
fi
mkdir -p .codex
rsync -av --ignore-existing "$main_root/.codex/" ".codex/"
echo "Synced .codex/ from $main_root"
}