Automatically isolate and coordinate concurrent writes across chats and agents

Open 💬 3 comments Opened Aug 6, 2026 by tianalei
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What feature would you like to see?

Codex should automatically isolate and coordinate filesystem writes when multiple chats or agents work on the same local project.

Today, chat isolation is not filesystem isolation. A main chat, side/fork chat, or subagent can share the same Local checkout and modify the same file concurrently. This can overwrite newer changes, make an agent operate on stale file contents, or leave the user to resolve conflicts that the orchestration layer created.

The current workaround—manually deciding which chat uses Local, creating a separate worktree for every writing chat, assigning file ownership, and coordinating handoff/merge order—is too much concurrency management to push onto the user. Worktrees and Handoff already provide useful primitives, but Codex should apply them automatically.

Example scenario

  1. Open a local Git project in the Codex desktop app.
  2. Start Chat A in Local and ask it to modify a file.
  3. Start a side/fork chat, or have the task use a subagent, and ask it to work on an overlapping feature or the same file.
  4. Both executions read and write the shared checkout without a clear ownership or coordination boundary.
  5. One execution may overwrite or invalidate the other's changes, or the user must manually coordinate worktrees and integration.

The same underlying problem applies to multiple independent Codex chats that point at the same Local checkout.

Expected behavior

Codex should make concurrent writing safe by default. For example:

  • Automatically give each writing chat an isolated managed worktree, while allowing read-only chats to share the Local checkout.
  • Detect overlapping write sets and serialize them, or assign explicit file/directory ownership between agents.
  • Before applying a patch, verify that the file still matches the version the agent read; if it changed, re-read and recompute instead of overwriting it.
  • Have the parent agent coordinate subagent writes and integrate their commits in a deterministic queue.
  • Automatically rebase/merge isolated results and run relevant validation.
  • Ask the user only when there is a genuine semantic conflict that Codex cannot resolve safely.
  • Clearly show which checkout/worktree owns each active writing task.

Starting another chat or delegating to an agent should not require the user to understand and manually operate Git worktrees merely to prevent data loss.

Related issues

  • openai/codex#5807 covers overwriting files changed externally due to stale file state.
  • openai/codex#24224 covers workspace context leaking across concurrent sessions in different projects.

This request is distinct: it is about safe, automatic coordination of concurrent writes by multiple Codex chats/agents intentionally working in the same project.

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 22 days ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #36719

Powered by Codex Action

etraut-openai contributor · 20 days ago

There's a "Hand off to worktree" option in the UI. Does this meet your needs?

<img width="524" height="246" alt="Image" src="https://github.com/user-attachments/assets/0788d73c-b28e-4ac3-a929-ea4cba29bb6c" />

Also, worktrees are typically pretty cheap (unless you're dealing with a really large repo), so many Codex users simply create a new worktree for each new task / session.

If you want more sophisticated isolation and merging for subagents, you can instruct codex to do this in the prompt or by using a custom skill.

tianalei · 11 days ago

Thanks for the clarification. I'll give the worktree flow a try. However, I still feel that it doesn't completely address the original concern.

I'm a pretty heavy user of side chats, and in practice I often start a side chat simply to explore a new idea or approach. At that point, it's usually difficult to know beforehand whether the task will eventually need an isolated worktree, because the implementation path and even the files that may be touched are not clear yet from the user's perspective. Also, side chats currently don't seem to have the same support for creating a new worktree.

My main concern is that coordinating write conflicts between the main chat, side chats, and subagents feels like something the system should ideally handle automatically, rather than something users need to manually manage. Since Codex already knows the context of these agents and the exact files they are working on, it seems like there could be a smoother way to handle isolation and integration.

I'm not familiar with the underlying implementation details, but I hope this is something Codex can eventually solve at the product level, without requiring users to understand Git worktrees or decide in advance when to create one. For comparison, I haven't run into this kind of workflow complexity in tools like Cursor, where these details are mostly hidden from users.

Thanks again for the reply!