Skip to content

Commit ada1cc5

Browse files
committed
chore: update agent-process-issue.yml
1 parent 0f4d2b4 commit ada1cc5

1 file changed

Lines changed: 42 additions & 22 deletions

File tree

.github/workflows/agent-process-issue.yml

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,48 +78,68 @@ jobs:
7878
model: anthropic/claude-haiku-4-5-20251001
7979
use_github_token: "true"
8080
prompt: |
81-
You are processing issue #${{ needs.validate.outputs.issue }} on ${{ github.repository }}.
81+
You are an autonomous agent processing issue #${{ needs.validate.outputs.issue }} on ${{ github.repository }}.
8282
83-
First, read the issue:
83+
Step 1 — Read the issue:
8484
gh issue view ${{ needs.validate.outputs.issue }} -R ${{ github.repository }} --json title,body,comments
8585
86-
Then follow the issue's instructions exactly.
86+
Step 2 — Implement the task following the issue's instructions exactly.
8787
88-
Your contract:
89-
1. Follow the "## Task" and "## Acceptance criteria" sections exactly.
90-
2. Do not expand scope.
91-
3. Run every verification check before opening a PR.
92-
4. Create a branch, commit changes, push, and open a PR with:
93-
- Title: conventional format (type: subject)
94-
- Body containing "Closes #${{ needs.validate.outputs.issue }}"
95-
5. Do NOT self-merge.
88+
Step 3 — Verify your work passes all checks listed in the issue.
9689
97-
If you need human input, comment on the issue with a
98-
"## Needs Human Input" section, add the needs-human label, and stop.
90+
Step 4 — YOU MUST create the PR yourself. This is non-negotiable.
91+
Run this command:
92+
gh pr create \
93+
--title "<type>: <description>" \
94+
--body "Closes #${{ needs.validate.outputs.issue }}" \
95+
--head "<your-branch-name>"
9996
100-
- name: Apply org PR conventions
97+
Rules:
98+
- Follow "## Task" and "## Acceptance criteria" sections exactly.
99+
- Do not expand scope beyond what the issue asks.
100+
- PR title must use conventional format (feat/fix/chore/docs/test/refactor: description).
101+
- PR body MUST contain "Closes #${{ needs.validate.outputs.issue }}".
102+
- Do NOT self-merge. Do NOT assume infrastructure creates the PR for you.
103+
- If you need human input, comment on the issue with a
104+
"## Needs Human Input" section, add the needs-human label, and stop.
105+
106+
- name: Verify PR was created
107+
id: verify-pr
101108
env:
102109
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103110
ISSUE: ${{ needs.validate.outputs.issue }}
104111
REPO: ${{ github.repository }}
105112
run: |
106113
set -euo pipefail
107-
pr=$(gh pr list --repo "$REPO" --state open --json number,createdAt \
108-
--jq "sort_by(.createdAt) | last | .number" 2>/dev/null)
114+
pr=$(gh pr list --repo "$REPO" --state open --json number,body \
115+
--jq "[.[] | select(.body | test(\"(?i)(close[sd]?|fix(e[sd])?|resolve[sd]?) #$ISSUE\"))] | first | .number" 2>/dev/null)
109116
if [ -z "$pr" ] || [ "$pr" = "null" ]; then
110-
echo "No open PR found — agent may have commented instead of creating PR"
111-
exit 0
117+
echo "::error::Agent did not create a PR for issue #$ISSUE"
118+
gh issue comment "$ISSUE" --repo "$REPO" \
119+
--body "Agent completed but did not create a PR. Marking for retry." || true
120+
exit 1
112121
fi
122+
echo "pr=$pr" >> "$GITHUB_OUTPUT"
123+
echo "Agent created PR #$pr for issue #$ISSUE"
113124
114-
gh pr edit "$pr" --repo "$REPO" \
125+
- name: Apply org PR conventions
126+
if: steps.verify-pr.outputs.pr != ''
127+
env:
128+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
ISSUE: ${{ needs.validate.outputs.issue }}
130+
REPO: ${{ github.repository }}
131+
PR: ${{ steps.verify-pr.outputs.pr }}
132+
run: |
133+
set -euo pipefail
134+
gh pr edit "$PR" --repo "$REPO" \
115135
--add-label "agent-work" --add-label "risk:low" --add-label "ready-to-merge" || true
116136
117137
title=$(gh issue view "$ISSUE" --repo "$REPO" --json title --jq '.title')
118-
current=$(gh pr view "$pr" --repo "$REPO" --json title --jq '.title')
138+
current=$(gh pr view "$PR" --repo "$REPO" --json title --jq '.title')
119139
if ! echo "$current" | grep -qE '^(feat|fix|chore|docs|test|refactor|ci|style|perf|build|revert):'; then
120140
if echo "$title" | grep -qE '^(feat|fix|chore|docs|test|refactor|ci|style|perf|build|revert):'; then
121-
gh pr edit "$pr" --repo "$REPO" --title "$title" || true
141+
gh pr edit "$PR" --repo "$REPO" --title "$title" || true
122142
else
123-
gh pr edit "$pr" --repo "$REPO" --title "feat: $title" || true
143+
gh pr edit "$PR" --repo "$REPO" --title "feat: $title" || true
124144
fi
125145
fi

0 commit comments

Comments
 (0)