Bug: Codex worktree context leaks across all worktrees (shared chats)
Open 💬 4 comments Opened Apr 26, 2026 by jacobcoro
Summary
I’m seeing cross-thread context leakage in Codex across git worktrees. A single chat thread context appears shared across multiple worktrees instead of being isolated.
Steps to reproduce
- On Linux/WSL, create multiple git worktrees for the same repo.
- Open each worktree in VS Code and run/open Codex in each.
- Start or open a Codex chat/thread in one worktree, then switch to another worktree.
- In the second worktree, observe the visible Codex chat history/context.
Expected behavior
Each worktree should isolate Codex conversations, matching expected local-context behavior (or at minimum, clearly indicate thread/worktree ownership).
Actual behavior
Chats/threads from one worktree are visible in all worktrees; context bleeds across them.
Impact
This causes accidental context confusion and cross-task contamination during multi-worktree parallel work.
Environment
- Date/time: 2026-04-26 (UTC+8)
- Date for issue reproduction: 2026-04-26
- OS: WSL2 Ubuntu on Windows
- Client: VS Code Codex extension + local
wtnew-managed git worktrees - Repo path:
/home/jacob/outlandish/outlandish_web - Current worktrees:
/home/jacob/outlandish/outlandish_web, plus multiple.worktrees/* - Repo setup has
.vscode/settings.json,.worktree-ports, and symlinked sharednode_modules/vendorin worktrees - Codex CLI version:
0.125.0-alpha.3 - Codex path in shell:
/home/jacob/.local/bin/codex
Additional details
This was reproducible while using stable Codex CLI shim + wtnew/wtopen flows.
/home/jacob/.zshenvcontains a shim socodexresolves to/home/jacob/.local/bin/codex- Multiple worktrees are created and opened together through helper functions, then Codex UI shows cross-worktree thread visibility
4 Comments
Repro details (extra)
I’m following the same machine/setup used to report issue #19647.
Observed command sequence:
I open all worktrees from the helper, then Codex thread list/context in one worktree appears in others.
Shell state used for Codex
Why this matters
Cross-worktree contamination happens during active parallel coding and can cause wrong-file or wrong-task assumptions in long sessions.
If helpful I can paste a short screen capture / HAR style log next, but at this stage behavior is deterministic and currently fully reproducible on this setup.
same
Codex Mac App Shows Sibling Git Worktrees as Separate Projects but Assigns Chats to the Wrong Worktree
Product
Codex Mac app / desktop app (Version 26.623.141536 • Released Jul 7, 2026)
Environment
/path/to/repo/mainSummary
The Codex app correctly discovers and displays my sibling Git worktrees as separate projects in the sidebar, but chat/session history is not isolated per worktree.
Chats from multiple worktree projects appear to be grouped under one worktree project, while the other worktree projects show "No chats".
This makes it difficult to use Codex with multiple parallel worktrees because sessions are shown under the wrong project.
Repository Layout
These are sibling directories, not nested worktrees.
Observed Behavior
In the Codex app sidebar, the projects are listed separately:
However:
mainappears to maintain its own sessions correctly.main.worktree-ashows multiple chats.main.worktree-bshows "No chats".main.worktree-cshows "No chats".main.worktree-a.Expected Behavior
Each worktree project should have independent chat/session history keyed by its worktree root path.
For example:
Git Diagnostics
For one affected worktree:
Output:
Command:
Output:
This is normal Git worktree behavior: sibling worktrees have distinct working tree roots but share the main repo's Git common directory.
Suspected Cause
The Codex app appears to use different identity logic for project discovery versus session/history association.
Project discovery seems path-aware, since the app displays each sibling worktree separately. But chat/session history appears to be keyed by shared Git metadata, such as:
or another canonical repository identity, instead of the worktree root from:
Because all sibling worktrees share
/path/to/repo/main/.git, their chats may be getting grouped under one worktree project.Impact
This breaks a common Git workflow where multiple worktrees are used for parallel feature work, investigations, or offloaded Codex tasks.
The app sidebar becomes unreliable because chats are shown under the wrong worktree or missing from the project where they were created.
Requested Fix
Please key Codex app project chat/session history by the worktree root path, for example:
rather than by shared Git common directory:
or any other shared repository identity.
For the shared-history / accidental-selection part of this worktree issue, I maintain a small unofficial workaround:
https://github.com/cixiangtao/codex-vscode-project-patch
It locally patches the installed
openai.chatgptextension so Webview-originatedthread/listrequests include the activevscode.workspace.workspaceFolderspaths. Because matching is based on exact savedcwd, separate Git worktree roots can be shown as separate task histories when each worktree is opened as its own VS Code workspace.Apply it without a global install:
Restore the official file:
This is only a temporary UI/history mitigation, not a fix for the context-leakage bug reported here. It does not change session ownership, rebind an active thread, enforce filesystem/tool boundaries, or prevent manually resuming a thread from another worktree. Its value is limited to reducing cross-worktree history noise and the chance of selecting the wrong thread.
The CLI uses a strict extension-version and bundle-hash allowlist, creates a verified backup, validates the patched JavaScript, and refuses unknown builds. It modifies the existing local installation and does not redistribute the official VSIX. An upstream fix still needs explicit thread/worktree ownership and safe resume behavior.