Skip to content

Add agent failure tracking in conclusion job with templated footer messages#9541

Merged
pelikhan merged 8 commits into
mainfrom
copilot/add-conclusion-job-support
Jan 10, 2026
Merged

Add agent failure tracking in conclusion job with templated footer messages#9541
pelikhan merged 8 commits into
mainfrom
copilot/add-conclusion-job-support

Conversation

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

Implementation Plan for Agent Failure Handling

  • Create new JavaScript file handle_agent_failure.cjs in actions/setup/js
    • Search for existing issue with title "[aw] failed"
    • Create issue if not found with 7-day expiration
    • Add comment if issue exists
    • Include AI header in comments
    • Sanitize all text sent to GitHub APIs
  • Add corresponding test file handle_agent_failure.test.cjs
  • Update conclusion job step in workflow compilation to call handler when agent job failed
  • Recompile workflows
  • Format and lint JavaScript files
  • Run agent-finish for complete validation
  • Add support for templated footer messages in frontmatter "messages" section
  • Move templates to .md files in actions/setup/md
  • Remove bash CLI commands from templates
  • Remove "Common Causes" section
  • Propagate check_mcp_servers.sh exit code in Start MCP gateway step
  • Simplify comment template - remove timestamp and make much shorter

Summary

Successfully implemented agent failure handling in the conclusion job with support for custom templated footer messages, template-based issue/comment generation, proper error propagation for MCP gateway checks, and a simplified comment template.

Changes Made (Latest)

Simplified Comment Template: Removed timestamp and made the comment much shorter (commit latest).

  • Changed comment template from verbose multi-line format to single line: Agent job failed: {run_url}
  • Removed timestamp ({timestamp}) placeholder from comment template
  • Removed "How to investigate" section and debug instructions from comment body
  • Updated fallback template in JavaScript handler to match
  • Updated test expectations to verify new shorter format
  • All 10 tests pass

Before:

## Agent Job Failed (2026-01-10T20:00:00.000Z)

The agent job failed during [workflow run](https://...).

### How to investigate

Use the **debug-agentic-workflow** agent to investigate this failure.

In GitHub Copilot Chat, type `/agent` and select **debug-agentic-workflow**.

Provide the workflow run URL: https://...

After:

Agent job failed: https://...

The footer message with workflow name and run URL is still appended via the templated message system.

Original prompt

Reference: https://github.com/githubnext/gh-aw/actions/runs/20883240322/job/60002663295#step:25:1

Add support in the conclusion job to the agent job failed. This typically means a configuration or runtime error that requires an intervention from the user.

If the action failed, search for an open issue titled "[aw] failed" with label "agentic-workflows". If not found create a new issue with this title and a 7 day expiration.

The body of the issue should be an explanation of why the issue was created, where to find the run that failed and how to use the debug-agentic-workflow to investigate it.

If the issue exists already, add a comment with standard AI header with a description of the current reason.

Sanitize all text sent to GitHub APIs.

Implement as a JavaScript script stored in actions/setup. conclusion must haveel issues: write access.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Changeset

  • Type: patch
  • Description: Add automated issue tracking for failed agent jobs in the conclusion job. Adds handle_agent_failure.cjs to create/update tracking issues and updates the conclusion job to invoke it when an agent job fails.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator

Copilot AI and others added 2 commits January 10, 2026 19:49
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot add support for templating the footer messages of the issue description and issue comment in the fronatter "messages" section.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for conclusion job in agent failure Add agent failure tracking in conclusion job Jan 10, 2026
Copilot AI requested a review from pelikhan January 10, 2026 20:03
@pelikhan pelikhan added the smoke label Jan 10, 2026
@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot do not suggest a bash cli command.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot move the template of the email in a .md file in actions/setup/md and use the interpolation function to render it.

Remove Common Causes

Check url to workflow .md file

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add support for templating the footer messages of the issue description and issue comment in the fronatter "messages" section.

Added support for templating agent failure footer messages in the frontmatter "messages" section (commit 9f500df).

Users can now customize the footer messages for agent failure tracking issues and comments:

safe-outputs:
  messages:
    agent-failure-issue: "> 🚨 Alert! [{workflow_name}]({run_url}) needs attention!"
    agent-failure-comment: "> ⚠️ Another failure detected by [{workflow_name}]({run_url})"

The implementation includes:

  • New agent-failure-issue and agent-failure-comment fields in SafeOutputMessagesConfig
  • Helper functions getFooterAgentFailureIssueMessage() and getFooterAgentFailureCommentMessage() in messages_footer.cjs
  • Messages config is passed to the handler via GH_AW_SAFE_OUTPUT_MESSAGES environment variable
  • Supports all standard placeholders: {workflow_name}, {run_url}, {workflow_source}, {workflow_source_url}

Copilot AI changed the title Add agent failure tracking in conclusion job Add agent failure tracking in conclusion job with templated footer messages Jan 10, 2026
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot do not suggest a bash cli command.

Removed bash CLI command suggestions (commit 510c070). The templates now only mention using GitHub Copilot Chat with /agent to select debug-agentic-workflow.

@copilot move the template of the email in a .md file in actions/setup/md and use the interpolation function to render it.

Remove Common Causes...

Moved templates to markdown files and removed Common Causes section (commit 510c070).

Changes made:

  • Created actions/setup/md/agent_failure_issue.md for issue template
  • Created actions/setup/md/agent_failure_comment.md for comment template
  • Templates use {placeholder} syntax for interpolation via renderTemplate()
  • Removed "## Common Causes" section from issue template
  • Workflow source URL is checked and uses # fallback if empty
  • Handler loads templates from /opt/gh-aw/prompts/ directory with fallback support

The templates support placeholders: {workflow_name}, {run_url}, {workflow_source}, {workflow_source_url}, {timestamp}

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot the exit code of the check mcp gateway needs to be propagated and fail the step

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the exit code of the check mcp gateway needs to be propagated and fail the step

Fixed exit code propagation for check_mcp_servers.sh (commit e18df95).

Added set -eo pipefail to the Start MCP gateway step's run: block. This ensures that:

  • When start_mcp_gateway.sh calls check_mcp_servers.sh and it fails (returns non-zero), the script exits with that code
  • The pipe operation (cat << EOF | bash script.sh) properly propagates failures
  • The GitHub Actions step fails when MCP server connectivity checks fail

Without set -eo pipefail, bash would continue after failures and the step would succeed despite errors.

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot copilot don't show date in comment template, make it much shorter.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot copilot don't show date in comment template, make it much shorter.

Simplified comment template and removed timestamp (commit da47794).

Changed from verbose multi-line format to single line: Agent job failed: {run_url}

  • Removed {timestamp} placeholder
  • Removed "How to investigate" section and debug instructions
  • Comment now just shows the failure with the run URL
  • Footer with workflow name is still appended via templated messages

@pelikhan pelikhan marked this pull request as ready for review January 10, 2026 21:02
@pelikhan pelikhan merged commit 05235c4 into main Jan 10, 2026
@pelikhan pelikhan deleted the copilot/add-conclusion-job-support branch January 10, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants