Named subagents intermittently ignore the requested worktree

Open 💬 2 comments Opened Jul 14, 2026 by marsmonarch-dev
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Environment

Codex Desktop on Windows with Git linked worktrees.

Expected behavior

A named subagent should begin inside the worktree and branch supplied in its task brief, or fail before analysis with a structured explanation that the target cannot be reached.

Actual behavior

Intermittently, a named subagent reports the parent workspace/branch or cannot resolve the supplied absolute worktree path. The sidecar can then inspect the wrong or an empty diff.

This is not reproduced on every launch. In the current session, the subagent reported the requested branch but its physical working directory was a sandbox-mounted path rather than the supplied host path. The issue therefore appears sensitive to sandbox path virtualization or startup timing.

Current workaround

The parent includes the expected pwd and branch in every brief, treats a mismatch as incomplete work, and supplies a committed diff packet when a sidecar cannot see the intended files.

Request

Please provide an explicit worktree/CWD binding for named subagents, validate it before analysis begins, and return a structured reason when the target is inaccessible. That would prevent silent audits of the wrong workspace.

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 1 month ago

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

  • #32842

Powered by Codex Action

briancl2 · 21 days ago

Adding a natural-use reproduction from a sanitized BMA owner task: https://github.com/briancl2/build-meta-analysis/issues/1559#issuecomment-5207186363

A named coordinator declared a dedicated fresh worktree, but its retained runtime context still had the shared parent checkout as effective CWD. A relative native patch therefore initially targeted the parent checkout. The writer immediately restored exactly those planned paths, switched to absolute target paths, and an independent reviewer verified the parent checkout clean.

This is direct evidence that a textual worktree assignment does not atomically bind the subagent runtime CWD. The requested fix here is exactly the right shape: return requested and resolved worktree/CWD in the startup receipt, expose shared-parent-cwd explicitly when that is the real mode, and fail before relative mutations when declared and effective roots differ.

No lasting damage or recurrence rate is claimed; this was one recovered internal-subagent episode.