codex icon indicating copy to clipboard operation
codex copied to clipboard

[CLI] Concurrent interactive sessions in the same repository interfere with each other's tasks

Open Ethan-Ceng opened this issue 3 weeks ago • 3 comments

Summary

I'm running multiple interactive Codex CLI sessions simultaneously in separate terminals, all pointing to the same Git repository / working directory.

Each session is explicitly assigned a different task in a different module, with clear scope and objectives. However, while the sessions run concurrently, they sometimes appear to influence each other's task context or execution plan. A session may shift away from its originally assigned work and become distracted by work associated with the other session.

It feels as though the sessions are communicating or sharing task context unexpectedly, but I cannot confirm direct inter-session communication. This could also be caused by shared repository files, plan/task artifacts, working-tree state, or session-state leakage.

Steps to reproduce

  1. Open Terminal A in an existing Git repository and start an interactive codex session.
  2. Assign Session A a clearly scoped task in Module A, with its own plan.
  3. Open Terminal B in the same repository and working directory and start another independent interactive codex session.
  4. Assign Session B a separate task in Module B, with no intended overlap.
  5. Let both sessions work concurrently.
  6. Observe that task focus or the execution plan can drift in one or both sessions, seemingly influenced by the other session's work.

Actual behavior

  • The two sessions appear to affect one another despite distinct instructions and module boundaries.
  • One or both sessions may deviate from their original plan or focus on tasks outside their assigned scope.
  • It is unclear whether the interference comes from session/context sharing or from filesystem/Git artifacts shared by the two processes.

Expected behavior

Each interactive Codex CLI session should preserve independent conversation and task-planning context. Working in the same repository should not, by itself, cause a session to absorb another session's objectives or change plans without an explicit request.

Shared files and Git working-tree changes are expected to be visible to both processes, but session-level task intent should remain isolated. If a shared workspace creates conflicts, Codex should make the conflict explicit instead of silently drifting in scope.

Questions

  1. Is there any intended mechanism by which concurrent interactive Codex CLI sessions in the same repository can share or influence task context?
  2. Are there known session-state, task-plan, or workspace-scoping issues that would explain this behavior?
  3. What is the recommended way to run multiple Codex CLI sessions on independent modules of the same repository without cross-session interference? Is a separate Git worktree required for isolation?

Environment / diagnostics

  • Client: Codex CLI (interactive sessions, not codex exec)
  • Setup: multiple terminal sessions using the same repository and working directory
  • CLI version, operating system, model, and debug logs: not provided yet
  • Reproduction details: observed during real parallel module development; no minimal log-based reproduction attached yet

Related issues

  • #11435 — Multiple parallel codex exec instances interfere via shared session restore (different mode: non-interactive exec).
  • #23515 — Codex CLI worktree session is interrupted when another Codex session is active in the base worktree (related concurrent-session behavior, but a different symptom).

I'd appreciate clarification on whether this is expected shared-workspace behavior or a CLI session-isolation issue, and guidance on how to safely run parallel interactive sessions.

Ethan-Ceng avatar Nov 07 '26 05:11 Ethan-Ceng

For independent module work, separate Git worktrees give each session its own working files, branch and index; have one person or session integrate the changes afterward. That reduces interference through edits and shared plan files, but does not prove conversation isolation or create a security boundary. To investigate the drift, capture the first reference to the other task and whether that session had just read a shared file containing it, along with the CLI version.

Zyph3rKeaton avatar Nov 07 '26 17:11 Zyph3rKeaton

I run several interactive Codex sessions on the same repo every day and saw the same drift. In my case it was never sessions talking to each other: it was the shared working tree. Session B runs git status or reads a plan/TODO file, sees Session A's half-finished edits in Module A, and starts "helping".

What fixed it for me:

  1. Start each session in its own checkout. The CLI now has a flag for this: codex --worktree ("Start in a new managed Git worktree" in the CLI reference; it works for new interactive sessions, codex fork, codex exec and codex exec fork). Each session then only sees its own changes.
  2. Keep plan files per task (or outside the repo), so one session's plan is not sitting in the other's tree.
  3. Open each prompt with the files or folders it may touch and "ignore unrelated changes in git status".
  4. Merge the branches yourself at the end instead of letting either session integrate.

Since doing that I have not seen a session pick up the other one's goal.

Disclosure: I build VibeiDE, a desktop app that queues Codex and Claude Code tasks with a worktree per task, but the flag above is all you need for this.

ngPati avatar Nov 16 '26 18:11 ngPati

I build Concord, so I'm biased, but this is the problem it was built for. +1 to codex --worktree for the file side. The other half of the drift is that neither session knows what the other one owns, so when Session B sees Module A's changes or reads a shared plan, it can't tell "another session's work" from "work I should help with".

Concord MCP is an open-source MCP server for that. Each Codex session claims its task and module with start_work, and if it reaches into something another session already claimed it's told before it edits. When a session finishes, finish_work records the commit, test result and any decisions, so the other session (or you at merge time) can read what changed and why with inspect_work instead of guessing from git status.

Happy to try it with you on one real pair of sessions if you want to see whether it stops the drift.

alexechoi avatar Nov 17 '26 09:11 alexechoi