Skip to content

feat(gastown): skip review queue for mayor-dispatched PR fixup polecats #1982

@jrf0110

Description

@jrf0110

Problem

When the mayor dispatches a polecat to fix a PR (e.g., addressing PR comments or fixing CI checks), the polecat calls gt_done which submits the work to the review queue, creating a new MR bead and triggering a full refinery review cycle. This is unnecessary — the work is already associated with an existing PR and doesn't need a separate review.

Proposed Solution

Introduce a gt:pr-fixup label (mirroring the existing gt:rework skip pattern) and bake PR-comment-addressing instructions into the polecat prompt.

Implementation Plan

  1. Add gt:pr-fixup label skip in review-queue.ts agentDone() — beads with this label close directly without submitting to the review queue, same as gt:rework does today (line ~571).

  2. Add labels parameter to gt_sling tool — thread it through the full chain: mayor-tools.tsclient.tsmayor-tools.handler.ts (MayorSlingBody) → Town.do.ts (slingBead()) → beadOps.createBead() (which already accepts labels). This lets the mayor tag beads as gt:pr-fixup at creation time.

  3. Add PR-fixup context injection in agents.ts buildPrimeContext — similar to how rework_context is built for gt:rework beads, build a pr_fixup_context for gt:pr-fixup beads containing the PR URL, branch, and relevant metadata.

  4. Bake PR-comment-addressing prompt into polecat system prompt — for gt:pr-fixup beads, inject instructions like:

    Take a look at all of the comments on the PR and address them. If they're not relevant comments, then reply on why they're not relevant and then resolve them. If they are relevant, then fix the issue, push up the change, and reply with how you fixed it and then resolve the thread. It's important to resolve the thread rather than just the base comment.

  5. Update mayor system prompt — add instructions for when/how to use the gt:pr-fixup label when dispatching polecats for PR comment or CI fix work.

Why Not Prompt-Only?

Considered instructing the polecat to call gt_bead_close instead of gt_done, but:

  • gt_done records branch name and summary (useful for audit)
  • LLMs don't reliably follow negative instructions
  • The label-based skip pattern is already battle-tested with gt:rework

Existing Pattern

The gt:rework label already implements this exact skip mechanism in review-queue.ts:

if (hookedBead?.labels.includes('gt:rework')) {
  closeBead(sql, agent.current_hook_bead_id, agentId);
  unhookBead(sql, agentId);
  return; // Skip review queue
}

The gt:pr-fixup implementation follows the same pattern.

Files to Change

  • cloudflare-gastown/src/dos/town/review-queue.ts — add label check in agentDone()
  • cloudflare-gastown/container/plugin/mayor-tools.ts — add labels param to gt_sling
  • cloudflare-gastown/container/plugin/client.ts — thread labels through sling client
  • cloudflare-gastown/src/handlers/mayor-tools.handler.ts — add labels to MayorSlingBody schema
  • cloudflare-gastown/src/dos/Town.do.ts — pass labels through slingBead()
  • cloudflare-gastown/src/dos/town/agents.ts — add pr_fixup_context in buildPrimeContext
  • cloudflare-gastown/src/prompts/polecat-system.prompt.ts — add PR-fixup workflow section
  • cloudflare-gastown/src/prompts/mayor-system.prompt.ts — add PR-fixup sling instructions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions