Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/workflows/gh-agent-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Each workflow directory contains an `example.yml` starter and a README for trigg
| Workflow | Trigger | Description |
| --- | --- | --- |
| Issue Triage | New issues | Investigate and provide implementation plans |
| Issue Triage (with PR) | New issues | Triage plus automatic draft PR for straightforward fixes |
| Mention in Issue | `/ai` in issues | Answer questions, debug, create PRs |
| Mention in PR | `/ai` in PRs | Review, fix code, push changes |
| PR CI Detective | Failed PR checks | Diagnose failures and recommend fixes |
Expand Down
31 changes: 31 additions & 0 deletions gh-agent-workflows/issue-triage-pr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Issue Triage (with PR)

Investigate new issues and provide actionable triage analysis. For straightforward fixes, implement and open a draft PR.

## Quick Install

```bash
mkdir -p .github/workflows && curl -sL \
https://raw.githubusercontent.com/elastic/ai-github-actions/v0/gh-agent-workflows/issue-triage-pr/example.yml \
-o .github/workflows/issue-triage-pr.yml
```

See [example.yml](example.yml) for the full workflow file.

## Trigger

| Event | Types |
| --- | --- |
| `issues` | `opened` |

## Inputs

| Input | Description | Required | Default |
| --- | --- | --- | --- |
| `additional-instructions` | Repo-specific instructions appended to the agent prompt | No | `""` |
| `setup-commands` | Shell commands run before the agent starts | No | `""` |

## Safe Outputs

- `add-comment` — post triage analysis on the issue
- `create-pull-request` — open a draft PR when a verified fix is implemented
16 changes: 16 additions & 0 deletions gh-agent-workflows/issue-triage-pr/example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Issue Triage (with PR)
on:
issues:
types: [opened]

permissions:
contents: read
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example.yml file has contents: read permission, but workflows that create pull requests need contents: write permission to create branches. All other workflows that use create_pull_request (mention-in-issue, bug-exterminator, small-problem-fixer, etc.) have contents: write. This permission is needed when automatic-prs is enabled.

Suggested change
contents: read
contents: write

Copilot uses AI. Check for mistakes.
discussions: write
issues: write
pull-requests: write # required by gh-aw compiler for add-comment (github/gh-aw#16673)

jobs:
run:
uses: elastic/ai-github-actions/.github/workflows/gh-aw-issue-triage-pr.lock.yml@v0
secrets:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
134 changes: 134 additions & 0 deletions github/workflows/gh-aw-issue-triage-pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---
description: "Investigate new issues and provide actionable triage analysis with optional PR creation"
imports:
- gh-aw-fragments/elastic-tools.md
- gh-aw-fragments/runtime-setup.md
- gh-aw-fragments/formatting.md
- gh-aw-fragments/rigor.md
- gh-aw-fragments/mcp-pagination.md
- gh-aw-fragments/workflow-edit-guardrails.md
- gh-aw-fragments/messages-footer.md
- gh-aw-fragments/safe-output-add-comment.md
- gh-aw-fragments/safe-output-create-pr.md
engine:
id: copilot
model: gpt-5.3-codex
concurrency:
group: "gh-aw-copilot-issue-triage-pr-${{ github.event.issue.number }}"
on:
workflow_call:
inputs:
additional-instructions:
description: "Repo-specific instructions appended to the agent prompt"
type: string
required: false
default: ""
setup-commands:
description: "Shell commands to run before the agent starts (dependency install, build, etc.)"
type: string
required: false
default: ""
messages-footer:
description: "Footer appended to all agent comments and reviews"
type: string
required: false
default: ""
secrets:
COPILOT_GITHUB_TOKEN:
required: true
reaction: "eyes"
concurrency:
group: issue-triage-pr-${{ github.event.issue.number }}
cancel-in-progress: true
permissions:
contents: read
issues: read
pull-requests: read
tools:
github:
toolsets: [repos, issues, pull_requests, search]
bash: true
web-fetch:
network:
allowed:
- defaults
- github
- go
- node
- python
- ruby
strict: false
roles: [admin, maintainer, write]
bots:
- "github-actions[bot]"
timeout-minutes: 30
steps:
- name: Repo-specific setup
if: ${{ inputs.setup-commands != '' }}
env:
SETUP_COMMANDS: ${{ inputs.setup-commands }}
run: eval "$SETUP_COMMANDS"
---

# Issue Triage Agent (with PR)

Triage new issues in ${{ github.repository }} and provide actionable analysis with implementation plans. For straightforward fixes, implement and open a draft PR.

## Context

- **Repository**: ${{ github.repository }}
- **Issue**: #${{ github.event.issue.number }} — ${{ github.event.issue.title }}

## Constraints

- **CAN**: Read files, search code, run tests and commands, comment on the issue, and open a draft PR for straightforward fixes.
- This workflow is primarily for investigation and planning. Local file changes are for verification only unless you implement a fix.

## Triage Process

Follow these steps in order.

### Step 1: Gather Context

1. Call `generate_agents_md` to get the repository's coding guidelines and conventions. If this fails, continue without it.
2. Read key repository files (README, CONTRIBUTING, etc.) to understand the project.
3. Search for related issues and PRs (open and closed) that may be relevant. Call `issue_read` with method `get` on the most relevant issues to understand prior discussion, decisions, and whether this is a duplicate.

### Step 2: Investigate the Codebase

1. Read the issue description carefully to understand the request or problem.
2. Explore the relevant parts of the codebase using `grep` and file reading.
3. Run tests or commands in the workspace to verify reported bugs when possible:
- Run existing tests to confirm reported behavior
- Execute scripts to understand current behavior
- Run linters or static analysis if relevant
- Write small test files to validate findings
- Always explain what you're testing and why, and include command output in your response
4. If the required change is small, clear, and verifiable, implement it directly and run relevant validation.

### Step 3: Formulate Response

Provide a response with the following sections. Be concise and actionable — no filler or praise.

**Always lead with a tl;dr** — your first sentence should be the most important takeaway.

**Sections:**

1. **Recommendation** — A clear, specific recommendation for how to address the issue. If you cannot recommend a course of action, say so with a reason. "I don't know" is better than a wrong answer.

2. **Findings** — Key facts from your investigation (related code, existing implementations, relevant issues/PRs). Use `<details>` tags for longer content.

3. **Verification** — If you ran tests or commands, include the output. Use `<details>` tags.

4. **Detailed Action Plan** — Step-by-step plan a developer could follow to implement the recommendation (or summary of implemented changes if you completed them). Reference specific files, functions, and line numbers. Use `<details>` tags.

5. **Related Items** — Table of related issues, PRs, files, and web resources.

Use `<details>` and `<summary>` tags for sections that would otherwise make the response too long. Short responses don't need collapsible sections. Your performance is judged by how accurate your findings are — do the investigation required to have high confidence. "I don't know" or "I'm unable to recommend a course of action" is better than a wrong answer.

### Step 4: Post Response

1. Call `add_comment` with your triage response.
2. If you implemented a valid fix with verification, call `create_pull_request` to open a draft PR.

${{ inputs.additional-instructions }}
Loading