commit 949727f9c13d71ef967da16e797d8fd9128ee775
Author: Ben Sima <ben@bensima.com>
Date: Thu Jan 1 00:40:58 2026
Fix orchestrator REQUEST_CHANGES detection (t-318)
- pi-review.sh now exits with code 2 for REQUEST_CHANGES verdict
- Orchestrator treats exit 2 as 'needs another iteration'
- This allows proper retry loop when reviewer requests changes
Previously the orchestrator would incorrectly mark tasks as done
when reviewer returned REQUEST_CHANGES (exit 0).
Task-Id: t-318
diff --git a/Omni/Agent/Telegram/Orchestrator.hs b/Omni/Agent/Telegram/Orchestrator.hs
index cfc08889..fd31e222 100644
--- a/Omni/Agent/Telegram/Orchestrator.hs
+++ b/Omni/Agent/Telegram/Orchestrator.hs
@@ -291,7 +291,7 @@ runReviewer cfg = do
Process.terminateProcess ph
pure (Left "Reviewer timeout")
Just Exit.ExitSuccess -> do
- -- Get commit hash from git
+ -- Reviewer approved - get commit hash from git
(_, Just hOut, _, ph') <- Process.createProcess
(Process.proc "git" ["rev-parse", "--short", "HEAD"])
{ Process.cwd = Just (orchWorkDir cfg),
@@ -300,7 +300,11 @@ runReviewer cfg = do
_ <- Process.waitForProcess ph'
commit <- Text.strip <$> TextIO.hGetContents hOut
pure (Right commit)
+ Just (Exit.ExitFailure 2) ->
+ -- Exit code 2 = REQUEST_CHANGES (needs another iteration)
+ pure (Left "Reviewer requested changes")
Just (Exit.ExitFailure code) ->
+ -- Other exit codes = error or rejection
pure (Left ("Reviewer rejected (exit " <> tshow code <> ")"))
-- | Create a status message, returns message_id
diff --git a/Omni/Ide/pi-review.sh b/Omni/Ide/pi-review.sh
index 78c784ef..98de6ef5 100755
--- a/Omni/Ide/pi-review.sh
+++ b/Omni/Ide/pi-review.sh
@@ -360,6 +360,7 @@ case "$VERDICT" in
FEEDBACK=$(echo "$REVIEW_OUTPUT" | sed '/^VERDICT:/d')
$TASK_CMD comment "$TASK_ID" "CHANGES REQUESTED: $FEEDBACK" --json > /dev/null
echo "Feedback added to task $TASK_ID. Coder can retry."
+ exit 2 # Distinct exit code for REQUEST_CHANGES (not 0=approve, not 1=error)
;;
*)