From 7a9616239cf1bff5204ae68cf23d46f6a93afd73 Mon Sep 17 00:00:00 2001 From: NagyVikt Date: Mon, 13 Apr 2026 18:11:42 +0200 Subject: [PATCH] Prevent review monitor crashes when dispatching Codex tasks The watch loop was invoking codex-agent with positional task arguments plus '-- exec', which old codex-agent parsing treated as a stray '--' argument and broke Codex invocation.\n\nSwitch dispatch to explicit --task/--agent/--base flags so both old and new codex-agent implementations receive a clean 'codex exec ' call path. Constraint: Must stay compatible with mixed codex-agent script versions across existing worktrees Rejected: Require users to rerun gx setup first | breaks ongoing monitor sessions Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep watch-loop invocation style option-based when passing codex subcommands Tested: node --test test/install.test.js --test-name-pattern "review-bot-watch" Tested: npm test Tested: node --check bin/multiagent-safety.js Tested: npm pack --dry-run --- README.md | 2 ++ scripts/review-bot-watch.sh | 6 +++++- templates/scripts/review-bot-watch.sh | 6 +++++- test/install.test.js | 8 ++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9134872..cb65b6f 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,8 @@ Useful flags: - `--once` run one polling cycle and exit - `--retry-failed` retry failed PRs without waiting for a new head SHA +Note: the monitor dispatches Codex through explicit `--task/--agent/--base` flags for compatibility with both older and newer `scripts/codex-agent.sh` argument parsing. + ## Important behavior defaults - No command defaults to `gx status`. diff --git a/scripts/review-bot-watch.sh b/scripts/review-bot-watch.sh index a41cefd..dd43e5d 100755 --- a/scripts/review-bot-watch.sh +++ b/scripts/review-bot-watch.sh @@ -262,7 +262,11 @@ process_one_pr() { echo "[review-bot-watch] Dispatching Codex agent for PR #${pr} (${head_branch})" set +e - bash "$repo_root/scripts/codex-agent.sh" "$task_name" "$AGENT_NAME" "$BASE_BRANCH" -- exec "$prompt" + bash "$repo_root/scripts/codex-agent.sh" \ + --task "$task_name" \ + --agent "$AGENT_NAME" \ + --base "$BASE_BRANCH" \ + -- exec "$prompt" local exit_code="$?" set -e diff --git a/templates/scripts/review-bot-watch.sh b/templates/scripts/review-bot-watch.sh index a41cefd..dd43e5d 100755 --- a/templates/scripts/review-bot-watch.sh +++ b/templates/scripts/review-bot-watch.sh @@ -262,7 +262,11 @@ process_one_pr() { echo "[review-bot-watch] Dispatching Codex agent for PR #${pr} (${head_branch})" set +e - bash "$repo_root/scripts/codex-agent.sh" "$task_name" "$AGENT_NAME" "$BASE_BRANCH" -- exec "$prompt" + bash "$repo_root/scripts/codex-agent.sh" \ + --task "$task_name" \ + --agent "$AGENT_NAME" \ + --base "$BASE_BRANCH" \ + -- exec "$prompt" local exit_code="$?" set -e diff --git a/test/install.test.js b/test/install.test.js index 96807de..bdaee80 100644 --- a/test/install.test.js +++ b/test/install.test.js @@ -293,6 +293,14 @@ test('review-bot-watch script prints help after setup', () => { assert.match(helpResult.stdout, /Continuously monitor GitHub pull requests targeting a base branch/); }); +test('review-bot-watch uses explicit codex-agent flags for argument parsing compatibility', () => { + const script = fs.readFileSync(path.resolve(__dirname, '..', 'scripts', 'review-bot-watch.sh'), 'utf8'); + assert.match(script, /--task \"\$task_name\"/); + assert.match(script, /--agent \"\$AGENT_NAME\"/); + assert.match(script, /--base \"\$BASE_BRANCH\"/); + assert.match(script, /-- exec \"\$prompt\"/); +}); + test('setup blocks in-place maintenance writes on protected main after initialization', () => { const repoDir = initRepoOnBranch('main');