Skip to content

Automatic PR comment resolution â agents address review feedback #1002

@jrf0110

Description

@jrf0110

Parent

Part of #204 (Phase 4: Hardening)

Problem

When using the pr merge strategy, PRs created by the refinery receive human review comments. Nobody addresses them. The PR sits with unresolved threads until someone manually intervenes. The refinery currently only polls for merge/close status �¢ it doesn't detect or act on review comments.

Solution

Extend the PR polling loop to detect new review comments and dispatch agents to address them in batches. The agent reads all unresolved comments, fixes the code or replies explaining why no change is needed, pushes updates, and resolves each thread.

Flow

  1. TownDO alarm polls open PRs (already exists in pollPendingPRs()). Extend to also fetch review comments via the GitHub/GitLab API.
  2. New unresolved comments detected �¢ create a pr_review bead (or sub-bead of the MR bead) with the comment context.
  3. Agent dispatched �¢ a polecat (or the refinery, since it already has the review context) gets a focused prompt with all pending comments.
  4. Agent processes each comment:
    • If relevant: fix the code, push, reply with how it was fixed, resolve the thread
    • If not relevant: reply explaining why, resolve the thread
    • If architectural/out-of-scope: reply acknowledging, escalate to Mayor
  5. Thread resolution is critical �¢ resolve the full thread, not just reply to the base comment. GitHub's GraphQL resolveReviewThread mutation handles this.

Agent prompt template

You are addressing review feedback on PR #42 for bead "Fix token refresh".

Unresolved review comments:

1. @sarah on src/auth.ts:15-20:
   "This function doesn't handle the case where the token is expired
    but the refresh endpoint is down. We should return a 503 here."

2. @mike on src/auth.ts:47:
   "nit: prefer const over let"

For each comment:
- If it's a valid code fix: make the change, push, reply explaining what you did, resolve the thread
- If it's a question: reply with an explanation, resolve the thread
- If it's not relevant or already addressed: reply explaining why, resolve the thread
- If it's an architectural concern beyond your scope: reply acknowledging it, and escalate

Always resolve the full thread (not just the comment) after addressing it.

Platform API calls

GitHub:

  • GET /repos/{owner}/{repo}/pulls/{number}/comments Ã�¢ list review comments
  • POST /repos/{owner}/{repo}/pulls/{number}/comments/{id}/replies Ã�¢ reply
  • GraphQL resolveReviewThread(input: { threadId }) Ã�¢ resolve thread

GitLab:

  • GET /projects/{id}/merge_requests/{iid}/discussions Ã�¢ list discussions
  • POST /projects/{id}/merge_requests/{iid}/discussions/{discussion_id}/notes Ã�¢ reply
  • PUT /projects/{id}/merge_requests/{iid}/discussions/{discussion_id}?resolved=true Ã�¢ resolve

New tools needed

The agent needs platform-specific tools (or the existing gh / glab CLIs installed in the container):

Tool Purpose
gh pr view --comments / API call Fetch unresolved comments
gh pr comment --reply-to / API call Reply to a thread
GraphQL mutation / API call Resolve thread

Alternatively, add a gt_pr_comment_resolve tool to the plugin that handles the API calls server-side via the TownDO (using the rig's integration token).

Acceptance Criteria

  • PR polling detects new unresolved review comments
  • Agent dispatched to address comment batches
  • Agent fixes code issues, pushes changes, replies to threads
  • Agent resolves full threads (not just base comments) after addressing
  • Non-relevant comments get explanatory replies and are resolved
  • Out-of-scope concerns are escalated to the Mayor
  • Works with both GitHub and GitLab integrations
  • Comment resolution tracked as bead events

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    kilo-duplicateAuto-generated label by Kilokilo-triagedAuto-generated label by Kilo

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions