Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 17, 2025

Implements automated issue triage using GitHub Models API to provide contextual follow-up comments on newly opened issues.

Technical

Workflow Structure (.github/workflows/issue_pm_ai.yml):

  • Triggers on issue creation, repository-scoped
  • Loads instructions from .github/prompts/issue_pm_instructions.md
  • Calls GitHub Models API (gpt-4o-mini) with issue context
  • Posts AI-generated comment with relevant guidance

Security: All JSON payloads constructed via jq with --arg flags to prevent injection:

PAYLOAD=$(jq -n \
  --arg model "gpt-4o-mini" \
  --arg system "$INSTRUCTIONS" \
  --arg user "$USER_MESSAGE" \
  '{model: $model, messages: [{role: "system", content: $system}, {role: "user", content: $user}]}')

AI Instructions (.github/prompts/issue_pm_instructions.md):

  • Suggests relevant files/code locations (when unambiguous)
  • Links to documentation (setup, testing, architecture, APIs)
  • References related PRs/issues
  • Recommends labels (Needs: Staff, Good First Issue)
  • Provides next steps (priority requirements, approach clarification)

Error Handling: HTTP status validation for both GitHub Models and GitHub API calls with detailed error output.

Testing

  1. Create a test issue in the repository
  2. Check Actions tab for workflow execution
  3. Verify AI comment appears on issue with contextual guidance

Stakeholders

@mekarpeles

Original prompt

This section details on the original issue you should resolve

<issue_title>Create Github Workflow to Auto-Followup on Issue Creation</issue_title>
<issue_description>### Feature Request

Right now our Issue template tries to predict many different use cases and to be overly-comprehensive.

This issue calls for leveraging our github open source credits to create a workflow that runs when an issue is created (by staff + leads) to provide context and focused next steps based on the original issue.

Possible workflow

name: Issue PM AI

on:
  issues:
    types: [opened]

permissions:
  contents: read
  issues: write
  models: read

jobs:
  respond:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Load PM AI Instructions
        id: pm
        run: |
          echo "INSTRUCTIONS<<EOF" >> $GITHUB_OUTPUT
          cat .github/prompts/issue_pm_instructions.md >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Generate issue response (GitHub Models)
        id: generate
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ISSUE_TITLE: ${{ github.event.issue.title }}
          ISSUE_BODY: ${{ github.event.issue.body }}
          INSTRUCTIONS: ${{ steps.pm.outputs.INSTRUCTIONS }}
        run: |
          CONTENT=$(curl -s https://models.github.ai/inference/chat/completions \
            -H "Authorization: Bearer $GITHUB_TOKEN" \
            -H "Content-Type: application/json" \
            -d "{
              \"model\": \"gpt-4.1-mini\",
              \"messages\": [
                {\"role\": \"system\", \"content\": \"$INSTRUCTIONS\"},
                {\"role\": \"user\", \"content\": \"Issue title: $ISSUE_TITLE\n\nIssue body:\n$ISSUE_BODY\"}
              ]
            }" | jq -r '.choices[0].message.content')

          # Expose as step output
          echo "CONTENT<<EOF" >> $GITHUB_OUTPUT
          echo "$CONTENT" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Post response to issue
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          REPO: ${{ github.repository }}
          ISSUE_NUMBER: ${{ github.event.issue.number }}
          BODY: ${{ steps.generate.outputs.CONTENT }}
        run: |
          curl -s -X POST \
            -H "Authorization: Bearer $GITHUB_TOKEN" \
            -H "Accept: application/vnd.github+json" \
            https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/comments \
            -d "$(jq -n --arg body "$BODY" '{body: $body}')"

Instructions

This PR requires the creation of a new file issue_pmai_instructions.md probably in the .github directory, maybe under a directory called prompts, that requests the following:

  1. Relevant Files -- only if there's enough context to unambiguously suggest relevant files, show the files and snippets that are relevant
  2. Relevant Documentation -- only if there's enough context (the mapping of of docs to topics should be specified in the template) then refer contributor to relevant docs.
  3. Reference PRs -- if there's been a related pull request, reference + link it
  4. Similar Issues -- If there are related or duplicate Issues, try to reference them by #number for context
  5. Labels -- If the issue touches a file that can only be tested by staff (e.g. authentication, borrowing, account deactivation, affiliate server) then tag as Needs: Staff. If an issue is clearly a good first issue, mark it as such but do so judiciously.
  6. Next Steps -- relevant instructions and steps before assignment. e.g. remove the "rebase" tips and only include this in the response if it's relevant to the issue. State it's not ready yet if it doesn't have a priority and lead label. If no approach is specified, ask the contributor to clarify the approach or ask questions before requesting assignment.
    </issue_description>

<agent_instructions>Can you create a working example that we can test based on the issue description? If the direction we're proposing simply won't work, please abort.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 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.

Copilot AI changed the title [WIP] Create GitHub workflow for auto-followup on issue creation Add GitHub Actions workflow for AI-powered issue triage Dec 17, 2025
Copilot AI requested a review from mekarpeles December 17, 2025 20:24
@mekarpeles
Copy link
Member

@copilot, now that Native GitHub Copilot Agents and skills are available, can we switch this PR to use a version or context of copilot that has access to query our issues, pull requests, and has context of the files and structure of our code base?

Copy link
Contributor Author

Copilot AI commented Jan 28, 2026

@copilot, now that Native GitHub Copilot Agents and skills are available, can we switch this PR to use a version or context of copilot that has access to query our issues, pull requests, and has conte...

I'd like to help migrate this to use GitHub Copilot's native capabilities. Could you clarify which specific Copilot integration you'd like to use?

Options I'm aware of:

  1. GitHub Copilot Extensions API - requires a Copilot extension app
  2. GitHub Apps with Copilot integration - custom app with Copilot features
  3. Specific GitHub Action from marketplace - if there's a published action

Could you share:

  • A link to documentation or example workflow for the Copilot integration you're referring to?
  • Or the name of a specific GitHub Action/extension to use?

This will help me implement exactly what you need.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/search/code
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Github Workflow to Auto-Followup on Issue Creation

2 participants