Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions autonomous/agent-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ sync_state() {
fi
}

CLAUDE_RC=0

run_claude() {
local prompt="$1"
local rc=0
timeout "$CLAUDE_TIMEOUT" claude --dangerously-skip-permissions --print \
--output-format stream-json --verbose "$prompt" || CLAUDE_RC=$?
--output-format stream-json --verbose "$prompt" || rc=$?
if [ "$rc" -ne 0 ]; then
echo "WARNING: claude exited with code $rc" >&2
fi
return "$rc"
}

load_prompt() {
Expand Down Expand Up @@ -197,25 +200,25 @@ EOF

execute-tasks)
ISSUE_NUM=$(get_issue_num)
run_claude "$(load_prompt execute-tasks)"
run_claude "$(load_prompt execute-tasks)" || true
sync_state "feat(#${ISSUE_NUM}): implement tasks"
;;

create-tasks)
ISSUE_NUM=$(get_issue_num)
run_claude "$(load_prompt create-tasks)"
run_claude "$(load_prompt create-tasks)" || true
sync_state "plan(#${ISSUE_NUM}): create task breakdown"
;;

apply-review)
ISSUE_NUM=$(get_issue_num)
run_claude "$(load_prompt apply-review)"
run_claude "$(load_prompt apply-review)" || true
sync_state "plan(#${ISSUE_NUM}): apply brief review feedback"
;;

review-brief)
ISSUE_NUM=$(get_issue_num)
run_claude "$(load_prompt review-brief)"
run_claude "$(load_prompt review-brief)" || true
sync_state "plan(#${ISSUE_NUM}): review brief"
;;

Expand Down Expand Up @@ -269,7 +272,7 @@ EOF
PROMPT=$(load_prompt pick-issue)
PROMPT="${PROMPT//\{\{ISSUE_BODY\}\}/$ISSUE_BODY}"

run_claude "$PROMPT"
run_claude "$PROMPT" || true
sync_state "plan(#${ISSUE_NUM}): initial brief from issue"
fi
else
Expand All @@ -285,10 +288,8 @@ EOF
PROMPT=$(load_prompt pick-issue)
PROMPT="${PROMPT//\{\{ISSUE_BODY\}\}/$ISSUE_BODY}"

run_claude "$PROMPT"
run_claude "$PROMPT" || true
sync_state "plan(#${ISSUE_NUM}): initial brief from issue"
fi
;;
esac

exit $CLAUDE_RC
7 changes: 2 additions & 5 deletions autonomous/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ for i in $(seq 1 "$MAX_ITERATIONS"); do
EXIT_CODE=0
bash /usr/local/bin/agent-loop.sh || EXIT_CODE=$?

if [ "$EXIT_CODE" -ne 0 ] && [ "$EXIT_CODE" -ne 124 ]; then
echo "Iteration $i failed with exit code $EXIT_CODE"
break
elif [ "$EXIT_CODE" -eq 124 ]; then
echo "Iteration $i timed out (exit code 124), continuing..."
if [ "$EXIT_CODE" -ne 0 ]; then
echo "Iteration $i exited with code $EXIT_CODE, continuing to next state..."
fi

# Done?
Expand Down
Loading