Skip to content

fix(codex-crew): bypass codex:codex-rescue for coordinator dispatch - #78

Merged
lklimek merged 3 commits into
mainfrom
fix/codex-crew-direct-dispatch
Jul 22, 2026
Merged

fix(codex-crew): bypass codex:codex-rescue for coordinator dispatch#78
lklimek merged 3 commits into
mainfrom
fix/codex-crew-direct-dispatch

Conversation

@lklimek

@lklimek lklimek commented Jul 22, 2026

Copy link
Copy Markdown
Owner

TL;DR: Codex dispatches from a coordinator now call the Codex runtime directly instead of routing through a Claude subagent that added no value and caused most of the recurring dispatch bugs.

User story

As a developer using Claudius to orchestrate Codex Sol coding work, I want a Codex dispatch to bind reliably to the worktree I intended and never silently collide with another dispatch, so that multi-worktree coding work completes predictably instead of stalling or getting duplicated.

Scenario

Base flow

A coordinator wants to hand a coding task to Codex Sol against a specific pre-created worktree, previously by spawning the codex:codex-rescue Claude subagent, which forwards the request to the codex-companion.mjs runtime as a single shell command.

Actual behavior

codex:codex-rescue's forwarding contract never exposes the runtime's own --cwd/--prompt-file flags. As a result: the broker/workspace binds to the coordinator's own working directory, not the target worktree, so every dispatch from one session shares one broker regardless of which worktree it's meant for; two dispatches close together collide (one strands at status=running forever, or silently returns a generic canned reply instead of doing the work); long prompts with embedded quotes or Rust Debug dumps can arrive corrupted; and the wrapper agent's own completion signal (idle_notification) is unreliable in both directions, so jobs finish 40–85 minutes before anyone finds out. Working around the cwd problem required a separate EnterWorktree/ExitWorktree dance that also blocked genuinely concurrent multi-worktree dispatch.

Expected behavior

The coordinator calls the codex-companion.mjs runtime directly, passing the target worktree and the prompt (as a file) as explicit arguments. Each dispatch is self-contained — distinct worktrees never share a broker, prompts never go through shell-quoting, and there is no wrapper-agent lifecycle to produce a false completion signal. Monitoring goes straight to the job's on-disk state, which now reliably reflects the intended worktree.

Detailed discussion

What was done

  • skills/codex-crew/SKILL.md: new § Direct Dispatch documents calling codex-companion.mjs task directly with --cwd <worktree-abs-path> and --prompt-file <abs-path> for all coordinator-orchestrated dispatch; codex:codex-rescue is now scoped to the upstream, user-typed /codex:rescue interactive command only.
  • § Sandbox & Workdir rule 3 and § Plan-Approval Gate: drop the EnterWorktree/ExitWorktree requirement, since --cwd binds the worktree directly and allows real concurrent multi-worktree dispatch.
  • § Never Dispatch Concurrently to the Same --cwd (renamed from § Never Dispatch Back-to-Back from the Same cwd): collision risk is now scoped to literal same---cwd dispatches, not every dispatch in a session.
  • § Monitoring a Codex Job: reframed around "no agent lifecycle to watch" instead of "don't trust the wrapper's unreliable signal."
  • skills/codex-crew/references/sandbox-and-recovery.md: on-disk job state's workspaceRoot now reliably matches the intended worktree for direct dispatch; the old dispatching-session-cwd caveat is scoped to the interactive path only.
  • Closed 3 stale memcan:todo items (project=claudius) this change resolves at the root: d8f1a08b (--write omission / self-reinvocation collision), 4d1f3d2f (quote/Rust-Debug-dump corruption), b6f79473 (same-cwd collision manifesting as an instant generic reply).
  • .claude-plugin/plugin.json bumped 5.15.05.16.0; CHANGELOG.md updated.

No source code changed — this is a skill-doctrine change only, no new scripts.

Testing

claude plugin validate . passes (one pre-existing, unrelated warning about CLAUDE.md at plugin root).

Breaking changes

None. This changes agent guidance, not a public interface; any coordinator following the old EnterWorktree-based doctrine still works, it's just no longer necessary.

Checklist

  • plugin.json version bumped
  • CHANGELOG.md updated
  • claude plugin validate . clean
  • Related memcan:todo items closed

Prior work

None — first attempt at removing the wrapper-agent layer; prior PRs (#71#75) hardened the wrapper-based approach instead.

Attribution

🤖 Co-authored by Claudius the Magnificent AI Agent

claude added 2 commits July 22, 2026 14:54
…d task tracking

Three coordinator doctrine changes to grand-admiral and dependents:

- Prefer mcp__agent-watchdog__* tools over the built-in Monitor script when
  available; built-in mechanics (discovery sources, event grammar, STALL/GONE
  playbooks) extracted to skills/grand-admiral/references/stall-watchdog.md.
- New Development-Work Delegation doctrine: brief actual coding work (Bilby,
  Codex Sol) by goal only, not a file list — the implementer investigates and
  returns its own plan for coordinator approval before writing code. Threaded
  through delegate, both workflow skills' Phase 2, developer-bilby, and
  codex-crew's new Plan-Approval Gate (two dispatches on the SAME Codex
  thread via --resume, not independent ones, to avoid rebuilding context).
- track-minions: in-session task tracking now uses a plain durable file, not
  memcan:todo; memcan:todo reserved for cross-session/cross-project tracking.

Also fixes two open codex-crew gaps surfaced while writing the Plan-Approval
Gate: the broker binds to the invoking session's actual cwd, not any path
injected into the dispatch prompt (EnterWorktree is now required before
dispatching), and the "stagger" mitigation for same-cwd collisions is
rewritten as a hard poll-for-terminal-status rule. Closes memcan:todo
445f8637 and 8d5cc5fb (project=claudius).

Consistency-audited by project-reviewer-adams; 5 low-severity cross-reference
issues found and fixed. plugin.json bumped to 5.15.0.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
codex:codex-rescue's forwarding contract never exposes --cwd/--prompt-file
to the underlying codex-companion.mjs runtime, forcing worktree binding
through EnterWorktree/ExitWorktree (serializing concurrent multi-worktree
dispatch) and shell-inlined prompts (corrupting on embedded quotes/Rust
Debug dumps). Both flags are already supported by the script directly.

codex-crew now documents calling `codex-companion.mjs task` directly with
--cwd and --prompt-file for all coordinator-orchestrated dispatch, fixing
both structurally and removing the wrapper agent's unreliable
idle_notification/stall-watchdog signal (no agent lifecycle, nothing to
watch). codex:codex-rescue is scoped to the upstream interactive
/codex:rescue command only.

Bump plugin.json to 5.16.0 per versioning policy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…-dispatch

# Conflicts:
#	.claude-plugin/plugin.json
#	CHANGELOG.md
#	skills/codex-crew/SKILL.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Claudius’ coordination doctrine to make Codex dispatches more reliable by removing the codex:codex-rescue wrapper from coordinator-orchestrated flows, and aligns several workflow/delegation skills around “goal-first, plan-gated” implementation.

Changes:

  • Document direct coordinator dispatch to codex-companion.mjs task using explicit --cwd + --prompt-file, and adjust Codex monitoring/recovery guidance accordingly.
  • Introduce/propagate “Development-Work Delegation (WHAT, not HOW)” guidance across workflow skills, delegate, and developer agent prompts (plan first, coordinator approval, then implement).
  • Refactor watchdog doctrine: prefer MCP watchdog when available, keep built-in Monitor as fallback, and extract detailed fallback mechanics into a reference file; bump plugin version and update changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
skills/codex-crew/SKILL.md Switches coordinator doctrine to direct Codex runtime dispatch; updates plan/monitoring rules.
skills/codex-crew/references/sandbox-and-recovery.md Updates job-state mapping notes for direct dispatch vs interactive wrapper path.
skills/grand-admiral/SKILL.md Adds “Development-Work Delegation” doctrine and MCP-watchdog preference; trims fallback details.
skills/grand-admiral/references/stall-watchdog.md New extracted reference for built-in watchdog mechanics and playbooks.
skills/delegate/SKILL.md Updates pre-delegation checklist for watchdog choice + plan gate.
skills/track-minions/SKILL.md Reframes durable tracking: in-session file primary; memcan for cross-session/project.
skills/workflow-trivial/SKILL.md Aligns trivial workflow implementation phase guidance with new delegation doctrine.
skills/workflow-simplified/SKILL.md Requires implementer-authored plan + coordinator sign-off per task before coding.
skills/workflow-feature/SKILL.md Same plan gate + acceptance-criteria briefing pattern for feature workflow.
agents/developer-bilby.md Adds an explicit “Implementation Plan Gate” before coding.
agents/architect-nagatha.md Adjusts architecture guidance to leave file-level placement to implementer plan.
CHANGELOG.md Adds release notes for new doctrine/version.
.claude-plugin/plugin.json Bumps plugin version to 5.16.0.
Comments suppressed due to low confidence (1)

CHANGELOG.md:22

  • The changelog introduces both 5.15.0 and 5.16.0 sections, but .claude-plugin/plugin.json is bumped directly to 5.16.0 in this PR. That makes the release notes ambiguous, and the 5.15.0 “Fixed” bullet about requiring EnterWorktree conflicts with the new 5.16.0 direct-dispatch doctrine (--cwd removes that requirement). Consider collapsing these notes into a single 5.16.0 entry so the changelog matches the single version bump and the final guidance.
## [5.15.0] - 2026-07-22

### Added

- **`skills/grand-admiral/references/stall-watchdog.md`**: new reference file — the built-in Monitor's discovery sources, event grammar, Multi-Session Hygiene traps, and STALL/GONE playbooks, extracted from `grand-admiral` § Recovery so they load only when the fallback path is actually used.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Resolve the installed `codex` plugin's script root once per session — version-pinned cache dirs shift on plugin updates, so never hardcode a version:

```bash
CODEX_ROOT=$(find ~/.claude/plugins/cache/openai-codex/codex -maxdepth 1 -mindepth 1 -type d | sort -V | tail -1)
@lklimek
lklimek marked this pull request as ready for review July 22, 2026 15:52
@lklimek
lklimek merged commit 8120a45 into main Jul 22, 2026
1 check passed
@lklimek
lklimek deleted the fix/codex-crew-direct-dispatch branch July 22, 2026 16:30
lklimek pushed a commit that referenced this pull request Jul 23, 2026
origin/main squash-merged PR #78 as 8120a45, whose tree was already
byte-identical to this branch's own 44e0c52 merge commit (same
underlying change, different commit SHA) — git's merge-base landed on
an older common ancestor and flagged plugin.json, CHANGELOG.md, and
codex-crew/SKILL.md as conflicting even though our side is a strict
superset (same content plus this branch's own fixes layered on top).
Resolved by keeping our side throughout; verified no residual content
was lost from origin/main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants