@rallycry/conveyor-agent 10.8.1 → 10.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rallycry/conveyor-agent",
3
- "version": "10.8.1",
3
+ "version": "10.8.2",
4
4
  "description": "Conveyor Agent Runner v10 - PTY harness for the task chat (SDK harness for audit/project-chat). Agent-as-User architecture with BaseService patterns. Works locally too.",
5
5
  "keywords": [
6
6
  "agent",
@@ -835,6 +835,22 @@ trap 'echo "[pool] SIGTERM received, forwarding to agent..."; pkill -TERM -f con
835
835
  # sleep so the pod idles instead of spinning.
836
836
  GIT_PREP_MAX_RETRIES=3
837
837
  _git_prep_attempts=0
838
+ # Bounded agent-crash supervision. An agent that keeps dying is a pod that keeps
839
+ # burning; cap the restarts, report every attempt to the API (the report posts to
840
+ # the task's activity log, which is also what keeps the pod alive through
841
+ # recovery), and exit for good once the cap is hit.
842
+ AGENT_CRASH_ATTEMPTS=0
843
+ AGENT_CRASH_MAX=3
844
+
845
+ report_agent_crash() {
846
+ # $1 = exit code, $2 = attempt, $3 = final (true/false). Best-effort.
847
+ curl -s -m 10 -X POST \
848
+ -H "Authorization: Bearer ${POD_BOOTSTRAP_TOKEN}" \
849
+ -H "Content-Type: application/json" \
850
+ -d "{\"exitCode\":${1},\"attempt\":${2},\"final\":${3}}" \
851
+ "${CONVEYOR_API_URL}/api/v3/pods/agent-crash" >/dev/null 2>&1 || true
852
+ }
853
+
838
854
  while true; do
839
855
  if [ -f "$GIT_FAILED_MARKER" ]; then
840
856
  if [ "$_git_prep_attempts" -lt "$GIT_PREP_MAX_RETRIES" ]; then
@@ -852,11 +868,18 @@ while true; do
852
868
  echo "[pool] agent exited cleanly (code 0), shutting down pod."
853
869
  exit 0
854
870
  fi
871
+ AGENT_CRASH_ATTEMPTS=$((AGENT_CRASH_ATTEMPTS + 1))
872
+ if [ "$AGENT_CRASH_ATTEMPTS" -ge "$AGENT_CRASH_MAX" ]; then
873
+ echo "[pool] agent crashed (code $_exit_code) — attempt cap ${AGENT_CRASH_MAX} reached, giving up."
874
+ report_agent_crash "$_exit_code" "$AGENT_CRASH_ATTEMPTS" true
875
+ exit 1
876
+ fi
877
+ report_agent_crash "$_exit_code" "$AGENT_CRASH_ATTEMPTS" false
855
878
  if [ -f "$GIT_FAILED_MARKER" ] && [ "$_git_prep_attempts" -ge "$GIT_PREP_MAX_RETRIES" ]; then
856
- echo "[pool] agent crashed (code $_exit_code) after git prep exhausted retries, backing off (60s)..."
879
+ echo "[pool] agent crashed (code $_exit_code) after git prep exhausted retries, backing off (60s, attempt ${AGENT_CRASH_ATTEMPTS}/${AGENT_CRASH_MAX})..."
857
880
  sleep 60
858
881
  else
859
- echo "[pool] agent crashed (code $_exit_code), retrying in 10s..."
882
+ echo "[pool] agent crashed (code $_exit_code), retrying in 10s (attempt ${AGENT_CRASH_ATTEMPTS}/${AGENT_CRASH_MAX})..."
860
883
  sleep 10
861
884
  fi
862
885
  done