Skip to content

fix: PR opened by item done uses the agent's own summary, not a placeholder - #419

Merged
getappz merged 2 commits into
masterfrom
fix-pr-summary-uses-agent-reply
Aug 9, 2026
Merged

fix: PR opened by item done uses the agent's own summary, not a placeholder#419
getappz merged 2 commits into
masterfrom
fix-pr-summary-uses-agent-reply

Conversation

@getappz

@getappz getappz commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

push_and_open_pr hardcoded "Auto-opened on \item done` for {id}."as every PR body, regardless of whether real information about the change was available.agentflare work already parses the headless agent's own final reply (parse_claude_reply`) — its prompt explicitly asks the agent to "summarize what you changed and why" — but that text only ever reached the item as a comment, never the PR itself. Reviewers opened these PRs cold, with a generic placeholder as the only description, no matter how good the agent's own summary was.

Noticed on item #43 → PR #417: the item's own comment history had a real summary of the 8-task capacity-governor work, but the PR body was just the placeholder.

Changes

  • types.rs: ItemRequest gains an optional summary field, scoped to done (mirrors the existing push field's scoping), documented in the item tool's own description.
  • worktree.rs: push_and_open_pr takes an optional summary and uses it as the PR body when non-blank, falling back to the old placeholder otherwise. Extracted the body-construction logic into a small pure pr_body() so it's directly unit-testable without needing a real repo remote/gh client (push_and_open_pr itself soft-fails without one).
  • item.rs: item_done threads req.summary through to both push_and_open_pr call sites.
  • work.rs: agentflare work's own item_done call (the common path — a headless run that just replies with text and lets the wrapper handle done) now passes the already-parsed reply_text as the summary. When the agent instead calls done itself mid-session (as item Replace ponytail platform detection with agent-detector process-tree approach #43's PR feat: capacity governor / backoff for work autonomous job runner #417 did), it can pass its own summary directly per the updated tool description.

Test plan

  • New tests pr_body_uses_the_summary_when_given_one, pr_body_trims_the_summary, pr_body_falls_back_to_the_placeholder_when_summary_is_none, pr_body_falls_back_to_the_placeholder_when_summary_is_blank
  • cargo test --bin agentflare -- worktree::tests:: cli::work::tests:: — 25 passed, 0 failed
  • cargo build --workspace clean
  • cargo clippy --bin agentflare --all-targets — no new warnings
  • cargo fmt --check clean

Summary by CodeRabbit

  • New Features

    • Completed work can now include a custom summary in the resulting pull request description.
    • Summaries are trimmed automatically; missing or blank summaries use a standard placeholder.
    • The item tool now documents support for providing summaries when marking work as done.
  • Bug Fixes

    • Ensured supplied completion summaries are consistently used when creating or opening pull requests.

…holder

push_and_open_pr hardcoded "Auto-opened on \`item done\` for {id}." as every
PR body, regardless of whether real information about the change was
available. agentflare work already parses the headless agent's own final
reply (parse_claude_reply) -- its prompt explicitly asks the agent to
"summarize what you changed and why" -- but that text only ever reached the
item as a comment, never the PR itself. Reviewers opened these PRs cold,
with a generic placeholder as the only description, no matter how good the
agent's own summary was.

- types.rs: ItemRequest gains an optional `summary` field, scoped to `done`
  (mirrors the existing `push` field's scoping), documented in the item
  tool's own description.
- worktree.rs: push_and_open_pr takes an optional summary and uses it as
  the PR body when non-blank, falling back to the old placeholder
  otherwise. Extracted the body-construction logic into a small pure
  pr_body() so it's directly unit-testable without needing a real repo
  remote/gh client (push_and_open_pr itself soft-fails without one).
- item.rs: item_done threads req.summary through to both push_and_open_pr
  call sites.
- work.rs: agentflare work's own item_done call (the common path -- a
  headless run that just replies with text and lets the wrapper handle
  `done`) now passes the already-parsed reply_text as the summary. When the
  agent instead calls `done` itself mid-session (as item #43's PR #417 did),
  it can pass its own `summary` directly per the updated tool description.

Agentflare-Agent: claude-code
Agentflare-Branch: fix-pr-summary-uses-agent-reply
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The done workflow now accepts agent-generated or caller-provided summaries. The worktree flow trims nonblank summaries for pull-request bodies and retains the existing placeholder when no usable summary is provided.

Changes

Summary propagation

Layer / File(s) Summary
Done summary contract and wiring
src/mcp_server/types.rs, src/mcp_server.rs, src/mcp_server/item.rs, src/cli/work.rs
The done request accepts an optional summary. CLI and MCP completion paths pass the summary to PR creation.
Pull-request body generation
src/worktree.rs
push_and_open_pr uses a trimmed nonblank summary as the PR body. Missing or blank summaries use the existing placeholder. Tests cover these cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant item_done
  participant push_and_open_pr
  participant pr_body
  participant PR creation
  item_done->>push_and_open_pr: optional summary
  push_and_open_pr->>pr_body: item and summary
  pr_body-->>push_and_open_pr: trimmed summary or placeholder
  push_and_open_pr->>PR creation: pull-request body
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: using the agent's summary instead of a placeholder for PR bodies.
Description check ✅ Passed The description clearly explains the changes and includes a detailed test plan, but it omits the optional reviewer notes section.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-pr-summary-uses-agent-reply

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli/work.rs`:
- Around line 509-519: Update the completion flow around the wrapper’s
mcp.item_done call to reconcile an agent-initiated done before relying on the
second call: ensure reply_text is applied to an existing PR body when the
initial summary was omitted, or apply it before opening the PR. Correct the
nearby comment so it no longer claims the second call is a no-op while the item
remains in_review.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 61f304a3-81c8-489c-ae66-7e2579f573b6

📥 Commits

Reviewing files that changed from the base of the PR and between dfbc8b6 and 56cb965.

📒 Files selected for processing (5)
  • src/cli/work.rs
  • src/mcp_server.rs
  • src/mcp_server/item.rs
  • src/mcp_server/types.rs
  • src/worktree.rs

Comment thread src/cli/work.rs
Comment on lines +509 to +519
// The agent may already have called `done` itself with its own
// `summary` (in which case this second call is a no-op — the
// claim is already released) -- but the common case is a
// headless run that just replies with text and lets this
// wrapper handle `done`, so pass the parsed reply through as
// the PR body rather than leaving it as the generic
// placeholder.
let done_resp = match mcp.item_done(ItemRequest {
action: "done".into(),
id: Some(item_id.into()),
summary: Some(reply_text.clone()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Reconcile agent-initiated done calls before relying on this second call.

If the agent calls done and opens a PR, src/mcp_server/item.rs keeps the claim held while the item is in_review (Lines 627-636). The wrapper therefore calls item_done again instead of treating it as a no-op. src/worktree.rs then returns the existing PR (Lines 146-151) without applying reply_text to its body.

If the first done omitted summary, the generic placeholder remains. Update the existing PR body or change the completion flow so the parsed reply is applied before the PR is opened. Correct the no-op comment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/work.rs` around lines 509 - 519, Update the completion flow around
the wrapper’s mcp.item_done call to reconcile an agent-initiated done before
relying on the second call: ensure reply_text is applied to an existing PR body
when the initial summary was omitted, or apply it before opening the PR. Correct
the nearby comment so it no longer claims the second call is a no-op while the
item remains in_review.

@getappz
getappz merged commit c74861b into master Aug 9, 2026
16 checks passed
@getappz
getappz deleted the fix-pr-summary-uses-agent-reply branch August 9, 2026 15: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.

1 participant