Skip to content

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

@shlomi-lr

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtool-callsIssues related to tool calling

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions