55 pull_request :
66 types : [labeled]
77
8+ # Prevent race conditions when multiple repairs trigger for same PR
9+ concurrency :
10+ group : repair-${{ github.event.pull_request.head.ref }}
11+ cancel-in-progress : false
12+
813jobs :
914 update-plot :
1015 name : Regenerate Plot from AI Feedback
8893 # Update sub-issue
8994 if [ -n "$SUB_ISSUE" ]; then
9095 gh issue edit $SUB_ISSUE \
91- --remove-label "ai-rejected,reviewing" \
96+ --remove-label "ai-rejected" \
97+ --remove-label "reviewing" \
9298 --add-label "not-feasible"
9399 fi
94100
@@ -199,7 +205,8 @@ jobs:
199205 # Update sub-issue
200206 if [ -n "$SUB_ISSUE" ]; then
201207 gh issue edit $SUB_ISSUE \
202- --remove-label "ai-rejected,reviewing" \
208+ --remove-label "ai-rejected" \
209+ --remove-label "reviewing" \
203210 --add-label "generating"
204211 fi
205212
@@ -287,8 +294,8 @@ jobs:
287294 f.write(content)
288295 PYEOF
289296
290- # Call Claude API
291- RESPONSE=$(curl -s https://api.anthropic.com/v1/messages \
297+ # Call Claude API (with timeout)
298+ RESPONSE=$(curl -s --max-time 120 --connect-timeout 10 https://api.anthropic.com/v1/messages \
292299 -H "Content-Type: application/json" \
293300 -H "x-api-key: $ANTHROPIC_API_KEY" \
294301 -H "anthropic-version: 2023-06-01" \
@@ -301,6 +308,13 @@ jobs:
301308 }]
302309 }")
303310
311+ # Validate API response
312+ if ! echo "$RESPONSE" | jq -e '.content[0].text' > /dev/null 2>&1; then
313+ echo "::error::API response invalid or empty"
314+ echo "Response: $(echo "$RESPONSE" | jq -r '.error // .' 2>/dev/null || echo "$RESPONSE")"
315+ exit 1
316+ fi
317+
304318 # Extract improved code
305319 IMPROVED_CODE=$(echo "$RESPONSE" | jq -r '.content[0].text // empty')
306320
@@ -334,11 +348,7 @@ jobs:
334348 echo "No changes to commit"
335349 else
336350 git add plots/
337- git commit -m "fix($LIBRARY): address AI review feedback for $SPEC_ID (attempt $ATTEMPT/3)
338-
339- :robot: Generated with [Claude Code](https://claude.com/claude-code)
340-
341- Co-Authored-By: Claude <noreply@anthropic.com>"
351+ git commit -m "fix($LIBRARY): address AI review feedback for $SPEC_ID (attempt $ATTEMPT/3)"
342352
343353 git push
344354 echo "Changes pushed"
@@ -389,3 +399,8 @@ jobs:
389399 COMMENTEOF
390400
391401 gh issue comment "$SUB_ISSUE" --body-file /tmp/update_comment.md
402+
403+ - name : Cleanup temporary files
404+ if : always()
405+ run : |
406+ rm -f /tmp/improve_prompt.txt /tmp/latest_feedback.md /tmp/all_attempts.md /tmp/update_comment.md
0 commit comments