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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Github Workflow to Auto-Followup on Issue Creation

2 participants