Skip to content

apply_patch writes to session CWD instead of requested workspace, causing edits in wrong repo #3749

Closed

Description

@shlomi-lr

What version of Codex is running?

codex-cli 0.27.0

Which model were you using?

gpt-5

What platform is your computer?

Darwin 24.6.0 arm64 arm

What steps can reproduce the bug?

AI_GENERATED_CONTENT_DISCLAIMER :)
codex-bug-workspace-mismatch.md

What is the expected behavior?

Expected Behavior

After a user asks to "set workspace" (or otherwise selects a workspace), all subsequent write operations should target that workspace consistently, not the session CWD.
Alternatively, the agent should be required to choose a single active workspace and all tools should use it implicitly.
If multiple projects are trusted and the agent is about to write relative to a different workspace than referenced by recent reads or user instruction, Codex CLI should warn and ask for confirmation.

What do you see instead?

Actual Behavior

apply_patch writes to the session CWD, ignoring the user's requested workspace and the read workdir used by the agent, leading to edits in the wrong repo.

Additional information

it's all in the doc codex made :)

Activity

  1. added
    bug
    on Sep 16, 2025
  2. added
    tool-calls
    on Nov 16, 2025
  3. etraut-openai commented on Jan 13, 2026

    @etraut-openai
    Contributor

    Closing stale bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions