fix(cli): order Codex -C before resume so maestro-cli send resumes work#954
fix(cli): order Codex -C before resume so maestro-cli send resumes work#954chr1syy wants to merge 1 commit into
Conversation
…work `exec resume` is a subcommand of `codex exec`; once consumed, trailing flags are parsed against `codex exec resume`, which doesn't accept `-C`. Emit `workingDirArgs` before `resumeArgs` (matching the desktop builder in `src/main/utils/agent-args.ts` and the canonical example in `definitions.ts`). Fixes `maestro-cli send` failing on follow-up Codex messages with `error: unexpected argument '-C' found`. Tightens the existing CLI spawn test to assert `-C` precedes `resume`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ChangesCodex Argument Ordering Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Greptile SummaryFixes a broken argument order in Confidence Score: 5/5Safe to merge — minimal, targeted fix with no regressions and a strengthened test guard. The change is a two-line reorder with a clear root cause, matches the already-correct desktop code path, and adds a regression-preventing ordering assertion in the test. No other agents are affected since workingDirArgs is gated on toolType === 'codex' in the CLI spawner. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as maestro-cli send
participant Spawner as agent-spawner.ts
participant Codex as codex binary
CLI->>Spawner: "spawnJsonLineAgent(codex, cwd, prompt, sessionId)"
Note over Spawner: Build preOverrideArgs
Spawner->>Spawner: "push workingDirArgs: ['-C', cwd]"
Spawner->>Spawner: "push resumeArgs: ['resume', sessionId]"
Note over Spawner: "args: [..., '-C', cwd, 'resume', sessionId]"
Spawner->>Codex: "codex exec --json -C /cwd resume id -- prompt"
Codex-->>Spawner: JSON lines response
Spawner-->>CLI: AgentResult success
Reviews (1): Last reviewed commit: "fix(cli): order Codex -C before resume s..." | Re-trigger Greptile |
|
Thanks for the contribution, @chr1syy! 🙏 Took a careful look — the fix is exactly right:
Mergeable, CI green, CodeRabbit + Greptile both clean. Approving. ✅ |
|
Closing in favor of #960 (@pedramamini), which supersedes this PR. #960 diagnoses the deeper root cause from #959: Codex treats #960 also fixes the desktop path ( |
1 similar comment
|
Closing in favor of #960 (@pedramamini), which supersedes this PR. #960 diagnoses the deeper root cause from #959: Codex treats #960 also fixes the desktop path ( |
Summary
maestro-cli sendfailed on follow-up messages to a Codex agent witherror: unexpected argument '-C' found ... Usage: codex exec resume [OPTIONS] [SESSION_ID] [PROMPT]. The first message worked becausesessionIdwas null and the resume branch was skipped; once a session id was saved, every subsequent send hit the resume path and broke.src/cli/services/agent-spawner.tsappendedresumeArgsbeforeworkingDirArgs, producingcodex exec ... resume <id> -C <cwd> -- <prompt>.resumeis a subcommand ofcodex exec, so once it's consumed, trailing flags are parsed againstcodex exec resume, which doesn't accept-C.workingDirArgsbeforeresumeArgsfor Codex. Matches the canonical comment insrc/main/agents/definitions.ts([-C dir] [resume <id>]) and the desktop buildersrc/main/utils/agent-args.ts, which already had the right order.-Cprecedesresumeso this can't silently regress.This was originally surfaced as a "Failed to get response from agent" error in the Maestro Discord bot — the bot was just relaying the upstream maestro-cli failure.
Test plan
vitest run src/__tests__/cli/services/agent-spawner.test.ts -t "Codex spawn preserves working-dir flag and resume args"— passes with the new ordering assertioneslintclean on the two touched filesprettier --checkclean on the two touched filesmaestro-cli send(or via Maestro Discord) — both should succeed; previously the second send failed🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests