-
Notifications
You must be signed in to change notification settings - Fork 46
Skip agent failure issues when PR checkout fails #13397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pelikhan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot do not use actions APIs. Instead of actions and job outputs to carry a successful checkout PR value.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done! Changed the implementation to use job outputs instead of the Actions API. Changes made (commit
The solution now uses native GitHub Actions job outputs instead of API calls, as requested. |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰 |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
Agent Container Tool Check
Result: 10/12 tools available ❌ FAIL Missing Tools:
|
|
PR titles: Remove .vscode/tasks.json; Add noop tool call to changeset generator for skipped PRs
|
|
🤖 Beep boop! The smoke test agent was here testing discussion interactions! All systems nominal! 🚀✨ Automated testing in progress for run §21615547949
|
Smoke Test Results
Overall Status: FAIL (8/9) @pelikhan - Run: https://github.com/github/gh-aw/actions/runs/21615547949
|
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
Smoke Test ResultsLast 2 Merged PRs:
Test Results:
Overall Status: PASS
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes spurious agent failure issues that are created when a PR is merged and its branch is deleted, causing the "Checkout PR branch" step to fail. The solution uses GitHub Actions job outputs to communicate the checkout status from the agent job to the conclusion job, which then skips issue creation when the failure is only due to PR checkout.
Changes:
- Added
checkout_pr_successoutput to track PR checkout status, defaulting to "true" when the step is skipped or succeeds, and "false" when it fails - Modified failure handling logic to skip issue creation when checkout fails
- Added comprehensive test coverage for the new behavior
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/pr.go |
Added step ID checkout-pr to enable output reference |
pkg/workflow/compiler_activation_jobs.go |
Added checkout_pr_success job output with fallback to 'true' |
pkg/workflow/notify_comment.go |
Passes checkout status to conclusion job via GH_AW_CHECKOUT_PR_SUCCESS environment variable |
actions/setup/js/checkout_pr_branch.cjs |
Sets output to "true" on success/skip, "false" on failure |
actions/setup/js/handle_agent_failure.cjs |
Skips issue creation when agent fails due to PR checkout |
actions/setup/js/checkout_pr_branch.test.cjs |
Tests verify output is set correctly in all scenarios |
actions/setup/js/handle_agent_failure.test.cjs |
Tests verify issue creation is skipped when checkout fails |
.github/workflows/security-guard.lock.yml |
Compiled workflow reflects all changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // If checkout_pr_success is "false", skip creating an issue as this is expected behavior | ||
| if (agentConclusion === "failure" && checkoutPRSuccess === "false") { | ||
| core.info("Skipping failure handling - failure was due to PR checkout (likely PR merged)"); |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition should also check that there are no assignment errors or missing safe outputs before skipping issue creation. If a PR checkout fails but there are also assignment errors or missing safe outputs, an issue should still be created to report those problems. The condition should be: if (agentConclusion === "failure" && checkoutPRSuccess === "false" && !hasAssignmentErrors && !hasMissingSafeOutputs)
| // If checkout_pr_success is "false", skip creating an issue as this is expected behavior | |
| if (agentConclusion === "failure" && checkoutPRSuccess === "false") { | |
| core.info("Skipping failure handling - failure was due to PR checkout (likely PR merged)"); | |
| // If checkout_pr_success is "false" and there are no assignment errors or missing safe outputs, | |
| // skip creating an issue as this is expected behavior | |
| if (agentConclusion === "failure" && checkoutPRSuccess === "false" && !hasAssignmentErrors && !hasMissingSafeOutputs) { | |
| core.info("Skipping failure handling - failure was due to PR checkout (likely PR merged) and no additional issues were detected"); |
| describe("checkout PR failure via output", () => { | ||
| it("should skip issue creation when checkout_pr_success is false", async () => { | ||
| // Set the checkout PR failure environment variable | ||
| process.env.GH_AW_CHECKOUT_PR_SUCCESS = "false"; | ||
|
|
||
| await main(); | ||
|
|
||
| // Verify that no issue was created | ||
| expect(mockGithub.rest.issues.create).not.toHaveBeenCalled(); | ||
| expect(mockGithub.rest.issues.createComment).not.toHaveBeenCalled(); | ||
| expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Skipping failure handling - failure was due to PR checkout")); | ||
| }); | ||
|
|
||
| it("should create issue when checkout_pr_success is true", async () => { | ||
| // Set the checkout PR success environment variable | ||
| process.env.GH_AW_CHECKOUT_PR_SUCCESS = "true"; | ||
|
|
||
| mockGithub.rest.search.issuesAndPullRequests | ||
| .mockResolvedValueOnce({ | ||
| // First search: PR search (no PR found) | ||
| data: { total_count: 0, items: [] }, | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| // Second search: parent issue | ||
| data: { total_count: 0, items: [] }, | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| // Third search: failure issue | ||
| data: { total_count: 0, items: [] }, | ||
| }); | ||
|
|
||
| mockGithub.rest.issues.create | ||
| .mockResolvedValueOnce({ | ||
| data: { number: 1, html_url: "https://example.com/1", node_id: "I_1" }, | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| data: { number: 2, html_url: "https://example.com/2", node_id: "I_2" }, | ||
| }); | ||
|
|
||
| mockGithub.graphql = vi.fn().mockResolvedValue({ | ||
| addSubIssue: { | ||
| issue: { id: "I_1", number: 1 }, | ||
| subIssue: { id: "I_2", number: 2 }, | ||
| }, | ||
| }); | ||
|
|
||
| await main(); | ||
|
|
||
| // Verify issue was created | ||
| expect(mockGithub.rest.issues.create).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("should create issue when checkout_pr_success is not set", async () => { | ||
| // Don't set GH_AW_CHECKOUT_PR_SUCCESS (workflow without PR checkout) | ||
| delete process.env.GH_AW_CHECKOUT_PR_SUCCESS; | ||
|
|
||
| mockGithub.rest.search.issuesAndPullRequests | ||
| .mockResolvedValueOnce({ | ||
| // First search: PR search (no PR found) | ||
| data: { total_count: 0, items: [] }, | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| // Second search: parent issue | ||
| data: { total_count: 0, items: [] }, | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| // Third search: failure issue | ||
| data: { total_count: 0, items: [] }, | ||
| }); | ||
|
|
||
| mockGithub.rest.issues.create | ||
| .mockResolvedValueOnce({ | ||
| data: { number: 1, html_url: "https://example.com/1", node_id: "I_1" }, | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| data: { number: 2, html_url: "https://example.com/2", node_id: "I_2" }, | ||
| }); | ||
|
|
||
| mockGithub.graphql = vi.fn().mockResolvedValue({ | ||
| addSubIssue: { | ||
| issue: { id: "I_1", number: 1 }, | ||
| subIssue: { id: "I_2", number: 2 }, | ||
| }, | ||
| }); | ||
|
|
||
| await main(); | ||
|
|
||
| // Verify issue was created (normal failure handling) | ||
| expect(mockGithub.rest.issues.create).toHaveBeenCalled(); | ||
| }); | ||
| }); |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage for the edge case where both checkout fails (checkout_pr_success is false) AND there are assignment errors or missing safe outputs. In this scenario, an issue should still be created to report the assignment errors/missing outputs, but there's no test verifying this behavior.
When a PR is merged and its branch deleted, the "Checkout PR branch" step fails, triggering spurious failure issues. The conclusion job now detects this scenario via job outputs and skips issue creation.
Changes
actions/setup/js/checkout_pr_branch.cjscore.setOutput("checkout_pr_success", "true"/"false")to indicate checkout resultactions/setup/js/handle_agent_failure.cjsGH_AW_CHECKOUT_PR_SUCCESSenvironment variable from agent job outputGo Compiler Changes
pkg/workflow/pr.go: Addedid: checkout-prto the checkout steppkg/workflow/compiler_activation_jobs.go: Addedcheckout_pr_successto agent job outputspkg/workflow/notify_comment.go: Passes checkout status to conclusion job via environment variableTests
checkout_pr_branch.test.cjsfor output behaviorhandle_agent_failure.test.cjsfor failure detection via job outputsArchitecture
The solution uses native GitHub Actions job outputs to communicate checkout status from the agent job to the conclusion job, eliminating the need for Actions API calls.
Behavior
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.