Feature design: PR-comment-driven agent revisions (/agent revise) #173

Closed
opened 2026-04-30 09:59:33 -07:00 by romaine-life-app[bot] · 1 comment
romaine-life-app[bot] commented 2026-04-30 09:59:33 -07:00 (Migrated from github.com)

Goal

Reviewers can post a comment on an agent-opened PR to send the PR back through the agentic flow with their feedback as additional context. Closes the loop between PR review and the next iteration without requiring a new issue or a manual re-trigger.

This issue is a design doc, not an implementation. Phasing at the bottom calls out an MVP slice that's useful on its own.

What the user does

  • On an agent-opened PR, leaves a comment containing /agent revise <feedback> — same slash-command idiom GitHub already conditions everyone to.
  • Optional follow-on commands: /agent retry verification, /agent rerun, /agent abort, /agent revert revision N — same dispatch path, different intent flag.
  • Also accepts @romaine-life-app revise: <feedback> for people who type mentions.

Why slash command vs. label vs. any-comment: labels are per-PR (clutters the label space, hard to attach feedback text); any-comment fires on every benign drive-by remark; slash command is explicit and conventional.

Trigger / dispatch (glimmung-side)

New webhook subscription: issue_comment (created) on PRs, plus pull_request_review for review-comment-as-trigger.

Glimmung handler:

  1. Match body against the slash regex; ignore otherwise.
  2. Confirm the commenter has write access (/repos/{owner}/{repo}/collaborators/{login}/permission). Otherwise post a permission-denied reply and stop.
  3. Confirm the PR was opened by romaine-life-app[bot] (don't accidentally hijack human PRs).
  4. Confirm the PR is open, not merged, and the head ref still exists.
  5. Loop guard: count prior /agent revise runs for this PR. Cap at 5 by default; configurable per-issue label agent-max-revisions:N.
  6. Cooldown guard: reject if last revise dispatched <5 min ago.
  7. Allocate a lease (same surface as today).
  8. Dispatch a workflow with inputs: lease_id, host, pr_number, pr_head_sha, issue_number, comment_id, comment_body, comment_author, revision_index, mode: revise.

Workflow architecture (revise vs from-scratch)

Two real options:

  • Option A — separate issue-agent-revise.yaml. Clean separation, original issue-agent.yaml stays simple, but prompt logic duplicates across files.
  • Option B — issue-agent.yaml with mode: initial|revise input. One entry point, branches on mode. Recommended: phases stay co-located, easier to keep prompts in sync.

Recommend B with a mode input and per-phase mode-aware behavior. The phases are doing fundamentally the same job (plan, implement, verify) — just with different priors.

New phase: Triage (revise mode only)

Before re-doing any of the three real phases, a small ~30s phase classifies the comment.

Reads: the issue, the PR diff, the comment body, prior verification artifacts.

Writes issue-agent-triage.json:

{
  "intent": "fix_bug|expand_scope|tighten_test|reject_feedback|clarify",
  "scope_change": false,
  "test_plan_delta_required": false,
  "implementation_delta_required": true,
  "verification_rerun_required": true,
  "reasoning": "<two sentences>",
  "abort_reason": null
}

Wrapper reads this and skips the phases that aren't required. So a "tighten this assertion" comment doesn't have to redo implementation; a "you missed this case" comment skips to plan-delta.

If intent: reject_feedback, the agent posts a reply explaining why (e.g. "the comment asks for behavior outside the original issue's scope; please file a new issue") and stops without modifying anything.

Phase deltas (vs from-scratch)

Each existing phase grows a "revise" branch:

  • Test plan (delta mode): Reads the prior issue-agent-test-plan.json, modifies only what triage says is impacted (typically: add an evidence item, tighten an expected_text). Most revisions don't need this phase at all.
  • Implementation (delta mode): Checks out the existing PR branch (NOT main + new branch), applies changes addressing the comment, commits as a new commit (so review history stays intact), pushes to the same head ref. The wrapper handles the push, not the LLM.
  • Verification (no special mode): Re-runs against the updated branch. Same evidence contract unless test-plan-delta added items.

A revise run that modifies implementation produces ONE additional commit on the existing PR branch. Reviewer sees the diff incrementally.

Wrapper additions

  • Reply step: After phases finish, post a threaded reply to the triggering comment. Includes: triage classification, what was changed (diff stats + commit SHA), what was rejected with reason, verification status, link to the run, updated PR cost total. Use the GitHub Reactions API to also slap a 👀 → ✅/❌ on the original comment.
  • Loop prevention: Bot comments tagged with a metadata HTML comment (<!-- romaine-life-app:revise-reply -->) so the webhook handler can ignore them.
  • Budget cap: Per-PR cumulative cost ceiling (default $10). Each revise pulls the prior runs' costs from artifact metadata, sums, and aborts if the next phase budget would exceed cap. Reply names the cap: "PR has spent $7.20 of $10.00 ceiling; this revision used $1.40."
  • Iteration ledger in PR description: Wrapper appends a one-line entry to a fenced block at the bottom of the PR body for each revision: revision N — comment URL — verification status — cost. Survives rebases.

Cross-cutting

  • Auth: rely on the comment-author permission check (write access required). Glimmung also enforces it server-side.
  • Telemetry: artifact name suffix -revN so historical runs don't collide. Original issue gets cross-posted: "Revision N applied to PR #170, status: pass" — only on revisions that materially change the PR (suppress for clarify/reject_feedback).
  • Rollback: /agent revert revision N resets the PR branch to the commit just before revision N and force-pushes (with a reply explaining what was undone). Branch protection on main means this only affects the agent's own branch.
  • Conflict between two pending comments: queue, FIFO. Glimmung's lease semantics already give us per-host serialization; just don't dispatch a new revise while one is in progress on the same PR.
  • PR closed mid-revise: phases check head ref existence at start; if gone, abort cleanly with "PR was closed/merged after dispatch".

Risks

Implementation-delta vs from-scratch-overwrite. If the agent re-implements from scratch on revise it might delete other reviewer-friendly aspects of the existing diff. Forcing it to read the existing PR and produce a patch on top is harder for the LLM than "do the issue from scratch" — needs deliberate prompt design and possibly a wrapper-side check that the new commit is genuinely additive (file-line overlap with the existing commit) rather than a wholesale rewrite.

Webhook race conditions. Two reviewers comment within seconds; both pass the cooldown check before either lease is allocated. Glimmung needs to serialize lease allocation per-PR, not just per-host.

Slash-command spoofing. A non-collaborator could post /agent revise in a fork-PR comment. The author-permission check covers this, but the failure mode (denied reply) needs to be polite and not noisy.

Phasing / effort estimate

Slice What's in it Est. (collab pace)
MVP Slash command + dispatch + single revise phase that re-runs the existing 3-phase pipeline on the PR's branch with the comment as context + basic reply ~2 days
Triage + deltas Triage phase + delta-mode in plan/impl + bot-comment loop prevention + iteration ledger +2 days
Budget + history Per-PR budget cap + issue cross-posting + revert command + threaded reactions + author-permission gate +2 days
Polish Error paths, edge cases (closed PRs, concurrent comments, branch-protection interactions), docs, Pester coverage of the new wrapper logic +2 days
Total full feature ~8 days

The MVP is useful on its own — most "tighten this assertion" / "you missed case X" feedback is well-handled by a from-scratch re-run on the existing branch. The polish layers (triage, delta-mode, budget caps) earn their cost only when revisions become routine.

Decisions to make before starting

  • Workflow Option A vs B (recommend B).
  • Slash command syntax: stick with /agent revise or use /romaine revise to match the App name?
  • Default per-PR cost ceiling.
  • Default max-revisions-per-PR.
  • Where the triage phase prompt lives (same run-issue-agent-phases.ps1 or split out).
  • Whether to also accept pull_request_review events or only issue_comment.
  • Cross-post to original issue: which intents qualify?
## Goal Reviewers can post a comment on an agent-opened PR to send the PR back through the agentic flow with their feedback as additional context. Closes the loop between PR review and the next iteration without requiring a new issue or a manual re-trigger. This issue is a design doc, not an implementation. Phasing at the bottom calls out an MVP slice that's useful on its own. ## What the user does - On an agent-opened PR, leaves a comment containing `/agent revise <feedback>` — same slash-command idiom GitHub already conditions everyone to. - Optional follow-on commands: `/agent retry verification`, `/agent rerun`, `/agent abort`, `/agent revert revision N` — same dispatch path, different intent flag. - Also accepts `@romaine-life-app revise: <feedback>` for people who type mentions. Why slash command vs. label vs. any-comment: labels are per-PR (clutters the label space, hard to attach feedback text); any-comment fires on every benign drive-by remark; slash command is explicit and conventional. ## Trigger / dispatch (glimmung-side) New webhook subscription: `issue_comment` (created) on PRs, plus `pull_request_review` for review-comment-as-trigger. Glimmung handler: 1. Match body against the slash regex; ignore otherwise. 2. Confirm the commenter has write access (`/repos/{owner}/{repo}/collaborators/{login}/permission`). Otherwise post a permission-denied reply and stop. 3. Confirm the PR was opened by `romaine-life-app[bot]` (don't accidentally hijack human PRs). 4. Confirm the PR is open, not merged, and the head ref still exists. 5. Loop guard: count prior `/agent revise` runs for this PR. Cap at 5 by default; configurable per-issue label `agent-max-revisions:N`. 6. Cooldown guard: reject if last revise dispatched <5 min ago. 7. Allocate a lease (same surface as today). 8. Dispatch a workflow with inputs: `lease_id`, `host`, `pr_number`, `pr_head_sha`, `issue_number`, `comment_id`, `comment_body`, `comment_author`, `revision_index`, `mode: revise`. ## Workflow architecture (revise vs from-scratch) Two real options: - **Option A — separate `issue-agent-revise.yaml`.** Clean separation, original `issue-agent.yaml` stays simple, but prompt logic duplicates across files. - **Option B — `issue-agent.yaml` with `mode: initial|revise` input.** One entry point, branches on mode. Recommended: phases stay co-located, easier to keep prompts in sync. Recommend **B** with a `mode` input and per-phase mode-aware behavior. The phases are doing fundamentally the same job (plan, implement, verify) — just with different priors. ## New phase: Triage (revise mode only) Before re-doing any of the three real phases, a small ~30s phase classifies the comment. Reads: the issue, the PR diff, the comment body, prior verification artifacts. Writes `issue-agent-triage.json`: ```json { "intent": "fix_bug|expand_scope|tighten_test|reject_feedback|clarify", "scope_change": false, "test_plan_delta_required": false, "implementation_delta_required": true, "verification_rerun_required": true, "reasoning": "<two sentences>", "abort_reason": null } ``` Wrapper reads this and skips the phases that aren't required. So a "tighten this assertion" comment doesn't have to redo implementation; a "you missed this case" comment skips to plan-delta. If `intent: reject_feedback`, the agent posts a reply explaining why (e.g. "the comment asks for behavior outside the original issue's scope; please file a new issue") and stops without modifying anything. ## Phase deltas (vs from-scratch) Each existing phase grows a "revise" branch: - **Test plan (delta mode):** Reads the prior `issue-agent-test-plan.json`, modifies only what triage says is impacted (typically: add an evidence item, tighten an `expected_text`). Most revisions don't need this phase at all. - **Implementation (delta mode):** Checks out the existing PR branch (NOT main + new branch), applies changes addressing the comment, commits as a new commit (so review history stays intact), pushes to the same head ref. The wrapper handles the push, not the LLM. - **Verification (no special mode):** Re-runs against the updated branch. Same evidence contract unless test-plan-delta added items. A revise run that modifies implementation produces ONE additional commit on the existing PR branch. Reviewer sees the diff incrementally. ## Wrapper additions - **Reply step:** After phases finish, post a threaded reply to the triggering comment. Includes: triage classification, what was changed (diff stats + commit SHA), what was rejected with reason, verification status, link to the run, updated PR cost total. Use the GitHub Reactions API to also slap a 👀 → ✅/❌ on the original comment. - **Loop prevention:** Bot comments tagged with a metadata HTML comment (`<!-- romaine-life-app:revise-reply -->`) so the webhook handler can ignore them. - **Budget cap:** Per-PR cumulative cost ceiling (default $10). Each revise pulls the prior runs' costs from artifact metadata, sums, and aborts if the next phase budget would exceed cap. Reply names the cap: "PR has spent $7.20 of $10.00 ceiling; this revision used $1.40." - **Iteration ledger in PR description:** Wrapper appends a one-line entry to a fenced block at the bottom of the PR body for each revision: revision N — comment URL — verification status — cost. Survives rebases. ## Cross-cutting - **Auth:** rely on the comment-author permission check (write access required). Glimmung also enforces it server-side. - **Telemetry:** artifact name suffix `-revN` so historical runs don't collide. Original issue gets cross-posted: "Revision N applied to PR #170, status: pass" — only on revisions that materially change the PR (suppress for `clarify`/`reject_feedback`). - **Rollback:** `/agent revert revision N` resets the PR branch to the commit just before revision N and force-pushes (with a reply explaining what was undone). Branch protection on main means this only affects the agent's own branch. - **Conflict between two pending comments:** queue, FIFO. Glimmung's lease semantics already give us per-host serialization; just don't dispatch a new revise while one is in progress on the same PR. - **PR closed mid-revise:** phases check head ref existence at start; if gone, abort cleanly with "PR was closed/merged after dispatch". ## Risks **Implementation-delta vs from-scratch-overwrite.** If the agent re-implements from scratch on revise it might delete other reviewer-friendly aspects of the existing diff. Forcing it to read the existing PR and produce a *patch on top* is harder for the LLM than "do the issue from scratch" — needs deliberate prompt design and possibly a wrapper-side check that the new commit is genuinely additive (file-line overlap with the existing commit) rather than a wholesale rewrite. **Webhook race conditions.** Two reviewers comment within seconds; both pass the cooldown check before either lease is allocated. Glimmung needs to serialize lease allocation per-PR, not just per-host. **Slash-command spoofing.** A non-collaborator could post `/agent revise` in a fork-PR comment. The author-permission check covers this, but the failure mode (denied reply) needs to be polite and not noisy. ## Phasing / effort estimate | Slice | What's in it | Est. (collab pace) | |---|---|---| | **MVP** | Slash command + dispatch + single revise phase that re-runs the existing 3-phase pipeline on the PR's branch with the comment as context + basic reply | ~2 days | | **Triage + deltas** | Triage phase + delta-mode in plan/impl + bot-comment loop prevention + iteration ledger | +2 days | | **Budget + history** | Per-PR budget cap + issue cross-posting + revert command + threaded reactions + author-permission gate | +2 days | | **Polish** | Error paths, edge cases (closed PRs, concurrent comments, branch-protection interactions), docs, Pester coverage of the new wrapper logic | +2 days | | **Total full feature** | | **~8 days** | The MVP is useful on its own — most "tighten this assertion" / "you missed case X" feedback is well-handled by a from-scratch re-run on the existing branch. The polish layers (triage, delta-mode, budget caps) earn their cost only when revisions become routine. ## Decisions to make before starting - Workflow Option A vs B (recommend B). - Slash command syntax: stick with `/agent revise` or use `/romaine revise` to match the App name? - Default per-PR cost ceiling. - Default max-revisions-per-PR. - Where the triage phase prompt lives (same `run-issue-agent-phases.ps1` or split out). - Whether to also accept `pull_request_review` events or only `issue_comment`. - Cross-post to original issue: which intents qualify?
nelsong6 commented 2026-07-05 15:45:23 -07:00 (Migrated from github.com)

Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.

Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens#173
No description provided.