Concurrent Sessions Leak Workspace Root Across Projects
What version of the Codex App are you using (From “About Codex” dialog)?
26.519.22136 (3003)
What subscription do you have?
Pro 5x
What platform is your computer?
Darwin 24.6.0 arm64 arm
What issue are you seeing?
Codex Desktop appears to leak workspace and project context between concurrent chat sessions.
When a long-running chat is active in Project A, a new or separate chat opened in Project B can incorrectly inherit Project A's workspace state. The leaked state may include:
- project root
- current working directory
- repository context
- file tree / indexing context
AGENTS.mdSKILLS.md- tool execution scope
- terminal execution context
This appears to be a session-isolation bug, not a history/sidebar issue.
The core problem is that project/workspace state does not always remain scoped to the active chat/session.
What I'm Experiencing
While a long-running task/chat is active in Project A, creating or using a separate chat session in Project B may incorrectly:
- resolve relative paths from
Project A - reference files from
Project A - load the wrong
AGENTS.mdorSKILLS.md - assume commands should run in
Project A - behave as though
Project Ais still the active workspace
<img width="761" height="706" alt="Image" src="https://github.com/user-attachments/assets/20e03d49-2450-41b7-b559-b4058eb4dd3c" />
What steps can reproduce the bug?
The issue appears intermittent, but it becomes easier to trigger with:
- multiple active chats
- long-running agent tasks
- rapid switching between projects
- concurrent background execution
Steps
- Open
Project Ain Codex Desktop. - Start a long-running task/chat in
Project A. - Before that task finishes, open
Project B. - Start a new chat/task in
Project B. - Observe that the new session may:
- reference files from
Project A - assume
cwdfromProject A - load the wrong project instructions/context
- behave as if
Project Ais still the active workspace
What is the expected behavior?
Each chat session should maintain fully isolated project state, including:
- project root
cwd- repository context
- file indexing context
AGENTS.md/SKILLS.md- tool execution context
- terminal execution scope
A chat opened in Project B should never inherit context from Project A.
Additional information
Why this is distinct
This is not just:
- a stale
cwdafter clicking between chats - a renamed/moved workspace path mismatch
- missing chat history
- sidebar/chat visibility problems
- generic indexing issues
The distinct repro here is concurrent active sessions across different projects.
The failure mode is that a new session in Project B can behave as though Project A is still the active workspace, even though the user intentionally started the new session under a different project.
Scenario
- multiple unrelated repositories/projects open concurrently
- multiple long-running agent/chat sessions active at the same time
Suspected cause
This looks like some form of workspace/session state being stored or reused too broadly, for example:
- global active workspace state
- shared
cwdcache - non-isolated agent execution context
- shared repository metadata across sessions
- workspace binding stored outside per-session scope
The observed behavior suggests workspace root context is being managed globally, or partially globally, rather than being strictly scoped per chat/session.
Severity: High.
This can cause:
- edits in the wrong repository
- command execution in the wrong repository
- wrong file modifications
- cross-project context contamination
- accidental commits to unrelated repositories
- incorrect
AGENTS.md/SKILLS.mdloading - loss of trust in multi-project agent workflows
For users running multiple concurrent coding agents across repositories, this is a data-integrity and safety issue.
Related issues
This appears related to, but distinct from:
- #20725: Agent runtime CWD/worktree is not rebound when navigating between project chats
The difference here is that this report is specifically about concurrent active sessions across different projects leaking workspace/session state between chats, including project root, cwd, repo context, and possibly AGENTS.md / SKILLS.md.
Last Notes
This issue is distinct from:
- missing chat history
- disappearing sidebar chats
- indexing/search issues
The underlying concern here is concurrent session/workspace isolation.
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
cblanquera-actions(jk)I checked #24186, #23437, and #23331.
I do not think this is a duplicate of #24186.
cwdduringresumeis ignored and the resumed session keeps the oldcwd.I also do not think it is a duplicate of #23437, though that one is related.
codex app-serverpolluting later TUI session metadata (cwd/source/originator) in persisted records.Project Bbehaving as thoughProject Ais still active, including possible leakage of project root,cwd, repo context, file tree/indexing context, andAGENTS.md/SKILLS.md.#23331 is the closest in impact, but still not the same repro.
Project A, a separate chat opened inProject Bcan inheritProject A’s workspace state.So I agree these are related, especially around wrong-workspace / wrong-repo integrity failures, but this report is intended to track the distinct concurrent-session Desktop isolation repro.
Thanks @bummerlazarus for potentially identifying the root cause in your https://github.com/bummerlazarus/factory/pull/26 . This is a helpful clue.
Adding a macOS/Codex Desktop data point with persisted JSONL evidence. This appears to be the same workspace/session isolation failure, with one narrower variant: the wrong workspace is already present in
session_meta.cwdand the firstturn_context.cwd/workspace_roots, before any tool call, skill, or repo-specific command runs.Environment:
26.527.60818(3437)/Applications/Codex.app/Contents/Resources/codex->codex-cli 0.136.0-alpha.2Darwin 25.5.0 arm64 arm/opt/homebrew/bin/codexdoes not explain this because the bad sessions record the app embedded0.136.0-alpha.2runtime.What I found in
~/.codex/sessions/**/rollout-*.jsonl:| local session id | injected workspace | first real prompt target |
| --- | --- | --- |
|
019e8491-a3ec-7610-9760-64d90b5ac1cf|<DEV>/project-a|<DEV>/project-b/ issue-specific task ||
019e8492-4be8-77c3-aa33-31777d58e560|<DEV>/project-a|<DEV>/project-c/ issue-specific task ||
019e87e0-bb6c-7aa0-9c7a-11d1f7c1f985|<DEV>/project-a|<DEV>/project-d/ prompt explicitly saysContinue in <DEV>/project-d||
019e87e1-8d0e-7080-929d-1659a56e113b|<DEV>/project-a|<DEV>/project-e/ prompt explicitly saysUse <DEV>/project-e||
019e87e6-068c-73a2-b836-2e9d56c64e60|<DEV>/project-a|<DEV>/project-c/ prompt references files under that repo |Common fields on the bad sessions:
originator = Codex Desktopsource = vscodethread_source = usercli_version = 0.136.0-alpha.2session_meta.cwdand firstturn_context.cwdpoint to the stale/wrong workspaceworkspace_rootscontains the stale/wrong workspaceWhy this matters: this is not only a tool-runtime CWD drift after navigation. In these cases the thread appears to be born with the wrong workspace binding. The model then receives the wrong repo
AGENTS.md/ workspace context at turn zero, so downstream guardrails in tools or skills can only fail closed; they cannot fully repair the contaminated initial context.Expected invariant:
selected project/workspace==session_meta.cwd== firstturn_context.cwd==workspace_roots== repo implied by the generated/suggested promptIf Codex cannot satisfy that invariant when launching from a suggested prompt or while multiple sessions are active, it should block the new thread and ask the user to confirm/rebind the workspace before injecting repo-local instructions or enabling file/git/tool operations.
Local mitigation I added: a global instruction requiring the agent to compare the target repo implied by the prompt with the injected
cwd/workspace_roots, runpwdandgit rev-parse --show-toplevel, and hard-stop on mismatch. That reduces damage, but the bug is upstream in Desktop session bootstrap/workspace binding.Adding a macOS/Codex Desktop
0.146.0-alpha.9.2data point with persistent-state and turn-context evidence. This confirms that the leak reaches effective filesystem write permissions, not only sidebar placement or working-directory context.Observed sequence
workspace_roots.The incorrect root was persisted in Codex Desktop’s per-thread
thread-writable-rootsstate. Later turns therefore continued receiving real write access to the unrelated project.A second propagation path was also observed: two new tasks created from another task, while explicitly targeting the correct saved project, inherited the creator task’s visualization directory instead of receiving only their own task-specific visualization root.
Scope
A read-only audit examined 181 stored local-task records. 106 failed the workspace-isolation check, although that count includes historical and archived records. A current task and seven manually created replacement tasks remain clean.
Restarting or replacing a task can produce a clean successor, but it does not repair the contaminated writable-root list stored for an existing task.
Expected behavior
For a single-folder local project, Codex Desktop should rebuild each task’s effective writable roots from:
It should never merge in the previously active project’s root or the creating task’s visualization directory unless the user explicitly attached that folder through Edit project.
If the saved-project assignment and effective writable roots disagree, the task should fail before model or tool execution receives access.
Environment and diagnostics
codex-cli 0.146.0-alpha.9.2codex doctor --jsonreports the installation, configuration load, state-database integrity, and rollout/database thread inventory as healthyI retained the exact affected task IDs and timestamped, redacted root transitions and can provide them through a private feedback channel if maintainers request them.
Adding another macOS Codex Desktop data point. Multiple concurrent local tasks abruptly lost their assigned project or worktree root from the effective sandbox
writable_roots.The task CWD remained correct, but affected turns often listed only a task visualization directory as writable. In some records, the visualization directory belonged to another task. Ordinary
apply_patchoperations inside the correct project CWD were consequently treated as outside-workspace writes and routed through Guardian auto-review, producing repeated declines or internal reviewer errors.Example shape:
The assigned Development worktree was absent. This occurred across multiple active tasks, while other tasks retained the correct project root, suggesting intermittent per-task workspace-state corruption rather than repository permissions.
Restarting Codex restored normal workspace writes. This variant is especially confusing because the CWD and project association remain visibly correct while only the effective write policy is corrupted.
The cross-project leakage makes this a useful persisted session-isolation case. I’m field-testing
codex-rescue==0.1.0a4against durablecwd/workspace/tool-state mismatches.If you still have a rollout from a session that inherited the wrong project context, could you run a read-only diagnostic:
pipx install codex-rescue==0.1.0a4codex-rescue doctor --json "/path/to/the-affected-rollout.jsonl"It won’t fix the Desktop runtime’s project scoping, but it can help distinguish incorrectly persisted session metadata from a purely in-memory/runtime leak.
A sanitized findings/status summary is enough. Please don’t post raw rollouts, databases, prompts, tool arguments/output, credentials, repository names, session IDs, or private paths.