Skip to content

Add bot comment handler workflow - #246

Merged
stranske merged 4 commits into
mainfrom
feat/bot-comment-handler
Dec 28, 2025
Merged

stranske merged 4 commits into
mainfrom
feat/bot-comment-handler

Conversation

@stranske

Copy link
Copy Markdown
Owner

Summary

Adds a new workflow system to automatically address review comments from bots (Copilot, CodeRabbit, etc.) using the configured AI coding agent.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│         reusable-bot-comment-handler.yml (Workflows repo)       │
│  - Collects unresolved bot comments via GitHub API             │
│  - Detects agent from PR labels (agent:codex, agent:claude)    │
│  - Posts @agent command to trigger fix                          │
│  - Creates issue for unaddressable items                        │
└─────────────────────────────────────────────────────────────────┘
                              │
              ┌───────────────┼───────────────┐
              │               │               │
              ▼               ▼               ▼
     Label trigger     Gate completion    Manual dispatch
     (one-off PRs)     (agent PRs)       (testing)

Components

File Purpose
reusable-bot-comment-handler.yml Core reusable workflow
agents-bot-comment-handler.yml Consumer repo thin caller template
fix_bot_comments.md Prompt template for agent
bot-comment-handler.md Documentation

Features

  • Agent-agnostic: Reads PR label (agent:codex, agent:claude) to select agent. Switch agents by changing label, no workflow changes needed.
  • Multiple triggers:
    • autofix:bot-comments label (manual, one-off PRs)
    • Gate completion (automatic for agent PRs)
    • workflow_dispatch (testing)
  • Smart filtering:
    • Skips resolved threads
    • Skips threads where human already replied
    • Only processes known bot authors
  • Concurrency-safe: Uses existing pr-meta dispatch mechanism, same concurrency group as keepalive

Integration

  • Runs in parallel with keepalive for agent PRs
  • After Gate completes, checks for unresolved bot comments
  • If found, posts @codex (or other agent) command
  • Flows through normal keepalive concurrency handling

Bot Authors (Default)

  • copilot[bot] - GitHub Copilot code review
  • github-actions[bot] - GitHub Actions suggestions
  • coderabbitai[bot] - CodeRabbit AI review

Usage

One-off PRs

Add autofix:bot-comments label to any PR with bot review comments.

Agent PRs

Automatic - after Gate completes, handler checks for comments and dispatches agent.

Testing

gh workflow run agents-bot-comment-handler.yml -f pr_number=123 -f dry_run=true

Testing Plan

  • Verify reusable workflow syntax
  • Test label trigger on a PR with Copilot comments
  • Test Gate completion trigger on agent PR
  • Verify agent receives comment context
  • Verify concurrency with keepalive

Documentation

See docs/bot-comment-handler.md for full documentation.

New feature to automatically address review comments from bots (Copilot,
CodeRabbit, etc.) using the configured AI coding agent.

Components:
- reusable-bot-comment-handler.yml: Core logic to collect and dispatch
- agents-bot-comment-handler.yml: Consumer repo thin caller template
- fix_bot_comments.md: Prompt template for agent
- bot-comment-handler.md: Documentation

Features:
- Agent-agnostic: Uses PR label (agent:codex, agent:claude) to select agent
- Multiple triggers: Label, Gate completion, manual dispatch
- Smart filtering: Skips resolved threads, threads with human replies
- Concurrency-safe: Uses existing pr-meta dispatch mechanism

Integration:
- Runs in parallel with keepalive for agent PRs
- Can be used standalone for one-off PRs via label
- Added to sync templates for consumer repos
Copilot AI review requested due to automatic review settings December 28, 2025 04:15
@agents-workflows-bot

Copy link
Copy Markdown
Contributor

⚠️ Action Required: Unable to determine source issue for PR #246. The PR title, branch name, or body must contain the issue number (e.g. #123, branch: issue-123, or the hidden marker ).

@github-actions

github-actions Bot commented Dec 28, 2025

Copy link
Copy Markdown
Contributor

Automated Status Summary

Head SHA: 8b281ce
Latest Runs: ⏳ pending — Gate
Required contexts: Gate / gate, Health 45 Agents Guard / Enforce agents workflow protections
Required: core tests (3.11): ⏳ pending, core tests (3.12): ⏳ pending, docker smoke: ⏳ pending, gate: ⏳ pending

Workflow / Job Result Logs
(no jobs reported) ⏳ pending

Coverage Overview

  • Coverage history entries: 1

Coverage Trend

Metric Value
Current 78.63%
Baseline 0.00%
Delta +78.63%
Minimum 70.00%
Status ✅ Pass

Updated automatically; will refresh on subsequent CI/Docker completions.


Keepalive checklist

Scope

No scope information available

Tasks

  • No tasks defined

Acceptance criteria

  • No acceptance criteria defined

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/reusable-bot-comment-handler.yml
Comment thread .github/workflows/reusable-bot-comment-handler.yml Outdated
@github-actions

github-actions Bot commented Dec 28, 2025

Copy link
Copy Markdown
Contributor

🤖 Keepalive Loop Status

PR #246 | Agent: Codex | Iteration 0/5

Current State

Metric Value
Iteration progress [----------] 0/5
Action wait (missing-agent-label)
Gate success
Tasks 0/0 complete
Keepalive ❌ disabled
Autofix ❌ disabled

🔍 Failure Classification

| Error type | infrastructure |
| Error category | resource |
| Suggested recovery | Confirm the referenced resource exists (repo, PR, branch, workflow, or file). |

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a comprehensive bot comment handler workflow system that automatically addresses review comments from bots (like Copilot, CodeRabbit, etc.) by dispatching configured AI coding agents to fix them.

Key Changes

  • New reusable workflow (reusable-bot-comment-handler.yml) that collects unresolved bot review comments via GitHub API and dispatches agents
  • Agent detection based on PR labels (agent:codex, agent:claude, etc.) with configurable fallback
  • Multiple trigger mechanisms: manual label (autofix:bot-comments), automatic Gate completion for agent PRs, and manual dispatch for testing

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
.github/workflows/reusable-bot-comment-handler.yml Core reusable workflow that collects bot comments, detects agent from labels, and dispatches agent via comment
templates/consumer-repo/.github/workflows/agents-bot-comment-handler.yml Consumer repo template that resolves PR numbers from different triggers and calls the reusable workflow
templates/consumer-repo/.github/codex/prompts/fix_bot_comments.md Prompt template providing instructions to agents for addressing bot review comments
docs/bot-comment-handler.md Comprehensive documentation covering setup, usage, triggers, and troubleshooting
.github/workflows/maint-68-sync-consumer-repos.yml Added new workflow to the sync list for propagation to consumer repos

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread templates/consumer-repo/.github/codex/prompts/fix_bot_comments.md Outdated
Comment thread docs/bot-comment-handler.md Outdated
Comment thread .github/workflows/reusable-bot-comment-handler.yml Outdated
Comment thread .github/workflows/reusable-bot-comment-handler.yml Outdated
Comment thread docs/bot-comment-handler.md Outdated
Comment thread docs/bot-comment-handler.md Outdated
Comment thread .github/workflows/reusable-bot-comment-handler.yml Outdated
Comment thread .github/workflows/reusable-bot-comment-handler.yml
Comment thread templates/consumer-repo/.github/workflows/agents-bot-comment-handler.yml Outdated
Comment thread .github/workflows/reusable-bot-comment-handler.yml Outdated
Addressed:
- JSON escaping: Use env vars + process.env instead of inline template injection
- secrets vs inputs: Changed 'if: inputs.gh_app_id' to 'if: secrets.gh_app_id'
- branches-ignore: Removed unsupported filter, added branch check in job logic
- concurrency fallback: Added github.run_id fallback for empty PR numbers
- shellcheck: Quoted variables, used env vars instead of inline substitution
- API error handling: Added try-catch around PR fetch calls
- Thread detection: Fixed to check entire thread for human replies
- Docs: Removed claims about auto-resolution and issue creation (not implemented)
- Output docs: Fixed comment to match actual outputs

Skipped:
- None - all suggestions were valid
@stranske
stranske temporarily deployed to agent-high-privilege December 28, 2025 04:32 — with GitHub Actions Inactive
GitHub Actions doesn't allow 'secrets' context in step-level if conditions.
The continue-on-error: true handles the case when App credentials aren't provided.
@stranske
stranske temporarily deployed to agent-high-privilege December 28, 2025 04:34 — with GitHub Actions Inactive
- Add to docs/ci/WORKFLOWS.md reusable workflows table
- Add to docs/ci/WORKFLOW_SYSTEM.md primary workflows list
- Add expected name mapping to test_workflow_naming.py
@stranske
stranske temporarily deployed to agent-high-privilege December 28, 2025 04:37 — with GitHub Actions Inactive
@github-actions github-actions Bot added autofix:clean Clean autofix and removed autofix:clean Clean autofix labels Dec 28, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Status | ✅ no new diagnostics
History points | 1
Timestamp | 2025-12-28 04:37:45 UTC
Report artifact | autofix-report-pr-246
Remaining | 0
New | 0
No additional artifacts

@stranske
stranske merged commit 8bffc69 into main Dec 28, 2025
36 checks passed
@stranske
stranske deleted the feat/bot-comment-handler branch December 28, 2025 04:40
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.

2 participants