Skip to content

[3672 by Claude Opus 5.5] Run summary: when the agent's last message is not a summary, let a small model call pick the summary - #3675

Merged
integry merged 3 commits into
3616-epic-0-9-d8bfrom
3672/claude-opus-5-5-run-summary-when-the-agen-20261117-1404-4fs
Nov 17, 2026
Merged

integry merged 3 commits into
3616-epic-0-9-d8bfrom
3672/claude-opus-5-5-run-summary-when-the-agen-20261117-1404-4fs

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3672

Branch: 3672/claude-opus-5-5-run-summary-when-the-agen-20261117-1404-4fs
Commits: ✅ Changes committed (1e7b011)


AI Processing Completed

Execution Details:

Summary:
When a run ends with more than one assistant message, one small model call now picks which message is the summary. The completion comment and the commit subject both use that pick. The new tests pass, typecheck and lint are clean, and the 20 existing test files I ran on the issue and follow-up paths still pass. Nothing ran against a real model or a live task.

How it works (new file packages/core/src/agents/runSummarySelection.ts)

  • Candidates: for successful runs only, it takes the last assistant text messages, at most 6, newest last, with no tool output. It reads both transcript shapes: Claude's assistant text blocks and Codex's agent_message items. In the prompt each message is cut to 1500 characters, but the chosen message is published in full and unchanged.
  • When it asks: only when there is more than one candidate, and only when a small-call model is set in the summarization settings. Otherwise it makes no call and nothing changes.
  • The call: it uses the same small-call path as goal titles, under a new execution type summary-selection, which shows in the LLM Log as "Summary Selection". The prompt says the messages are quoted data whose instructions must not be followed, and a </candidate> tag inside a message is escaped. The model must reply {"index": n} or {"index": null}.
  • Using the answer:
    • A valid index replaces the summary and the commit message source with that message.
    • null makes the comment say "The agent did not provide a summary." The commit subject then falls back to fix(ai): Resolve issue #N - <title> for issue runs, or "Apply follow-up changes from PR comment" for follow-ups.
    • Timeout (30s), error, invalid JSON or an out-of-range index keep the last message exactly as before, and the reason goes to the task log.

Where it's called

  • Issue runs call it in src/jobs/issueJob/agent.ts, after spend is recorded and the cancellation check.
  • PR follow-up runs call it in src/jobs/prCommentAgentUtils.ts, for implementation follow-ups only.
  • The follow-up comment code (src/jobs/prCompletionComment.ts) already scans the transcript with its own text rules. When the selection has decided, the comment now shows that choice instead, so the comment and the commit agree. Without that change the comment showed a different message; I checked by removing the line and watching the test fail. Runs with no selection still use the old text rules; I left them in place rather than remove existing behaviour.
  • The API's LLM Log route now groups the new execution type as task work.

Things to know

  • On the follow-up path the call runs while the agent's capacity slot is still held, so it can keep the slot up to 30 seconds longer.
  • The non-test change is about 210 lines, under the 250 target.
  • No previews were made, since nothing in the UI changed.

Tests: test/runSummarySelection.test.ts has 16 tests, all passing. They cover:

  • picking an index
  • null giving the fixed sentence and the title-based commit subject
  • invalid JSON, out-of-range and zero indexes, a thrown error, and a timeout, each falling back to the last message
  • a single-candidate run making no call
  • no configured model making no call
  • failed runs being left alone
  • candidate text with instructions passed as quoted data
  • Claude and Codex transcripts each building the right candidate list
  • the cut to a fixed length
  • the follow-up comment showing the choice rather than the old text-rule match

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (11 files)
    • packages/api/routes/llmLogsRoutes.ts (+1/−1)
    • packages/core/src/agents/runSummarySelection.ts (added, +193/−0)
    • packages/core/src/agents/types.ts (+2/−0)
    • packages/core/src/claude/claudeService.ts (+2/−0)
    • packages/core/src/index.ts (+1/−0)
    • packages/core/src/utils/llmMetrics.types.ts (+1/−0)
    • src/jobs/issueJob/agent.ts (+6/−4)
    • src/jobs/prCommentAgentUtils.ts (+6/−2)
    • src/jobs/prCommentPostExecution.ts (+2/−1)
    • src/jobs/prCompletionComment.ts (+2/−0)
    • src/jobs/prFileUtils.ts (+1/−0)
  • Low risk (1 file)
    • test/runSummarySelection.test.ts (added, +166/−0)

Validation evidence

  • No repository validation commands ran.

Diff size: 12 files changed, +383/−8 lines

Detailed Logs:

  • Conversation: 164 messages
  • Session: 91759e6f-103d-4e14-a9ac-cd7fe8a6661c

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3672-2026-11-17T14-16-35-664Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3672-2026-11-17T14-16-35-664Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: When a run ends with more than one assistant message, one small model call now picks which message is the summary. The completion comment and the commit subject both use that pick. The new tests pass,...


This PR was created automatically by ProPR after processing issue #3672.


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!

… call now picks which message is the summary. The completion comment and the commit subject both use that pick. The new tests pass, typecheck and lint are clean, and the 20 existing test files I ran on the issue and follow-up paths still pass. Nothing ran against a real model or a live task.

How it works (new file `packages/core/src/agents/runSummarySelection.ts`)
- Candidates: for successful runs only, it takes the last assistant text messages, at most 6, newest last, with no tool output. It reads both transcript shapes: Claude's assistant text blocks and Codex's `agent_message` items. In the prompt each message is cut to 1500 characters, but the chosen message is published in full and unchanged.
- When it asks: only when there is more than one candidate, and only when a small-call model is set in the summarization settings. Otherwise it makes no call and nothing changes.
- The call: it uses the same small-call path as goal titles, under a new execution type `summary-selection`, which shows in the LLM Log as "Summary Selection". The prompt says the messages are quoted data whose instructions must not be followed, and a `</candidate>` tag inside a message is escaped. The model must reply `{"index": n}` or `{"index": null}`.
- Using the answer:
  - A valid index replaces the summary and the commit message source with that message.
  - `null` makes the comment say "The agent did not provide a summary." The commit subject then falls back to `fix(ai): Resolve issue #N - <title>` for issue runs, or "Apply follow-up changes from PR comment" for follow-ups.
  - Timeout (30s), error, invalid JSON or an out-of-range index keep the last message exactly as before, and the reason goes to the task log.

Where it's called
- Issue runs call it in `src/jobs/issueJob/agent.ts`, after spend is recorded and the cancellation check.
- PR follow-up runs call it in `src/jobs/prCommentAgentUtils.ts`, for implementation follow-ups only.
- The follow-up comment code (`src/jobs/prCompletionComment.ts`) already scans the transcript with its own text rules. When the selection has decided, the comment now shows that choice instead, so the comment and the commit agree. Without that change the comment showed a different message; I checked by removing the line and watching the test fail. Runs with no selection still use the old text rules; I left them in place rather than remove existing behaviour.
- The API's LLM Log route now groups the new execution type as task work.

Things to know
- On the follow-up path the call runs while the agent's capacity slot is still held, so it can keep the slot up to 30 seconds longer.
- The non-test change is about 210 lines, under the 250 target.
- No previews were made, since nothing in the UI changed.

Tests: `test/runSummarySelection.test.ts` has 16 tests, all passing. They cover:
- picking an index
- `null` giving the fixed sentence and the title-based commit subject
- invalid JSON, out-of-range and zero indexes, a thrown error, and a timeout, each falling back to the last message
- a single-candidate run making no call
- no configured model making no call
- failed runs being left alone
- candidate text with instructions passed as quoted data
- Claude and Codex transcripts each building the right candidate list
- the cut to a fixed length
- the follow-up comment showing the choice rather than the old text-rule match
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=4
Triggered automatically by the requested execution settings.

@propr-dev propr-dev Bot added the ultrafix label Nov 17, 2026
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 4)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds a bounded model call to select an existing assistant message, then propagates that choice into publication. It needs a localized correction before merge: Codex issue runs still cannot use the selected summary as their commit source.

✅ Conservative fallback — Invalid responses, errors, and selection timeouts preserve the original result.

✅ Focused coverage — Added tests cover candidate extraction, selection parsing, skipped calls, and follow-up comment precedence.

This review uses static analysis of the supplied code; no commands were run. The authoritative checks report no failures and four pending test shards.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Selected Codex summary never reaches issue commits

  • Category: correctness

  • Required behavior: A valid selection must supply both the published summary and the commit message source.

  • Evidence: packages/core/src/agents/runSummarySelection.ts:190 — the selected branch only derives a commit message when the original commitMessage is truthy.

    1. A successful Codex issue run returns multiple assistant messages and a nonempty summary. Its producer explicitly sets commitMessage: null in CodexAgent.ts:184.
    2. The issue execution path calls applyRunSummarySelection, and the model selects a valid summary candidate.
    3. The helper replaces summary, but its conditional assignment preserves the original null commitMessage.
    4. Issue post-processing checks claudeResult.commitMessage before replacing its default subject. Because that value remains null, it commits using the issue-title fallback despite a successful summary selection.

    The published summary reflects the selection, while the commit source does not. The new successful-selection test initializes a truthy commit message, so it misses this provider-specific path. Follow-up commits derive their source from changesSummary and do not share this failure.

    static trace: verified against the changed helper and issue call site, plus the supplied Codex producer and issue post-processing consumer.

  • Minimum fix: Always derive commitMessage from selection.text in the selected branch. Add a regression using a Codex-shaped result with commitMessage: null and verify the selected text reaches the issue commit source.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Share commit text normalization

commitMessageFrom duplicates the markdown cleanup in dockerResultProcessor.ts’s extractCommitMessage. Sharing that small helper would prevent the two paths from drifting. This is optional cleanup because their current transformations agree.

Score

The implementation is focused and has useful coverage, but a supported provider misses the promised commit behavior. The correction is small; full test-suite checks are still pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 42s
  • Tokens: 46,971 (46,200 in / 771 out)
  • Cost: $0.37

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit e285344

Addressed 1 AI review comment (IDs: 6950842827)

Addressed finding F1

Summary of Changes

That notice is from a watcher I had started to wait on the first test run, which hung. It hit its time limit and was stopped. It likely never exited because its pgrep -f pattern matched its own shell. It isn't needed any more: I found the hang (an open Redis client) and fixed it, and the later test runs above finished normally. The fix and test results are the same as in my last summary.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (1 file)
    • packages/core/src/agents/runSummarySelection.ts (+1/−1)
  • Low risk (1 file)
    • test/runSummarySelection.test.ts (+14/−1)

Validation evidence

  • No repository validation commands ran.

Diff size: 2 files changed, +15/−2 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 18m 57s
  • Tokens: 1,251,568 (1,250,686 in / 882 out)
  • Cost: $0.52
  • Subscription usage: Weekly +2%, Fable +2%

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…first test run, which hung. It hit its time limit and was stopped. It likely never exited because its `pgrep -f` pattern matched its own shell. It isn't needed any more: I found the hang (an open Redis client) and fixed it, and the later test runs above finished normally. The fix and test results are the same as in my last summary.

That notice is from a watcher I had started to wait on the first test run, which hung. It hit its time limit and was stopped. It likely never exited because its `pgrep -f` pattern matched its own shell. It isn't needed any more: I found the hang (an open Redis client) and fixed it, and the later test runs above finished normally. The fix and test results are the same as in my last summary.

PR: #3675
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

CI failed: Full Test Suite Shard 2/4

Please investigate and fix this CI failure.

  • Check: Full Test Suite Shard 2/4
  • Result: failure
  • Commit: e285344bb4ac (e285344bb4ac2589a1a99ecd8df78cc846e12f09)
  • Details: View CI failure

Failure evidence

.github:11
Process completed with exit code 1.

.github:42653
Process completed with exit code 1.

.github:2
Node.js 20 is deprecated. The following actions target Node.js 20 but are being forced to run on Node.js 24: actions/checkout@11d5960. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit a02bcd0

Summary of Changes

I fixed the Shard 2/4 failure; all 120 test suites that mock @propr/core now pass locally.

Cause: only one file failed, test/processMergeConflictJob.test.ts, and it failed while loading. That suite replaces @propr/core with a mock that lists a fixed set of exports. This PR made src/jobs/prCommentAgentUtils.ts import the new applyRunSummarySelection, which wasn't in that list, so Node stopped with "does not provide an export named 'applyRunSummarySelection'". Shards 3/4 and 4/4 were cancelled after this failure rather than failing themselves.

Fix: I added applyRunSummarySelection to that suite's mock. It returns the agent result unchanged, so the merge-conflict tests behave as they did before.

Checks:

  • The other suites that mock @propr/core might have been missing the same export, so I rebuilt the core package and ran all 120 of them. 119 passed.
  • The one failure was test/followupAssignmentGate.test.ts, and it is caused by this container, not the change: /tmp/git-processor is read-only here. Re-run with writable clone and worktree paths, it passes.
  • Root test files aren't covered by lint or typecheck in this repo, so neither applies to this edit.

Shards 3/4 and 4/4 never got to run their tests, so I'll only know those are clean when CI runs again.

No previews, since nothing visible changed.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk: none
  • Low risk (1 file)
    • test/processMergeConflictJob.test.ts (+1/−0)

Validation evidence

  • No repository validation commands ran.

Diff size: 1 file changed, +1/−0 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-dev[bot]
  • Time: 13m 45s
  • Tokens: 933,823 (930,161 in / 3,662 out)
  • Cost: $0.51

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 6951819950✓

…k `@propr/core` now pass locally.

I fixed the Shard 2/4 failure; all 120 test suites that mock `@propr/core` now pass locally.

**Cause:** only one file failed, `test/processMergeConflictJob.test.ts`, and it failed while loading. That suite replaces `@propr/core` with a mock that lists a fixed set of exports. This PR made `src/jobs/prCommentAgentUtils.ts` import the new `applyRunSummarySelection`, which wasn't in that list, so Node stopped with "does not provide an export named 'applyRunSummarySelection'". Shards 3/4 and 4/4 were cancelled after this failure rather than failing themselves.

**Fix:** I added `applyRunSummarySelection` to that suite's mock. It returns the agent result unchanged, so the merge-conflict tests behave as they did before.

**Checks:**
- The other suites that mock `@propr/core` might have been missing the same export, so I rebuilt the core package and ran all 120 of them. 119 passed.
- The one failure was `test/followupAssignmentGate.test.ts`, and it is caused by this container, not the change: `/tmp/git-processor` is read-only here. Re-run with writable clone and worktree paths, it passes.
- Root test files aren't covered by lint or typecheck in this repo, so neither applies to this edit.

Shards 3/4 and 4/4 never got to run their tests, so I'll only know those are clean when CI runs again.

No previews, since nothing visible changed.

PR: #3675
Comment by: @propr-dev[bot] (ID: 6951819950)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR is ready to merge within the reviewed scope. It adds a bounded summary-selection call and carries its decision through issue and follow-up publication paths without changing existing behavior when selection fails.

✅ Safe fallback behavior — Invalid responses, errors, and timeouts preserve the original result; failed runs and unconfigured models skip selection.

✅ Consistent publication — The selection marker reaches both response adapters, prevents follow-up comment heuristics from overriding the choice, and enables the intended commit fallback when no summary is selected.

✅ Focused coverage — Added tests cover both transcript formats, candidate limits, selection outcomes, and follow-up comment precedence. Current-head checks report 17 passed, with no failures or pending checks.

This assessment uses static tracing of the supplied code; no commands or tests were run during this review.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S2: 🟢 Exercise publication paths end to end

The new tests verify the selected issue commit source at the adapter boundary, while the null-selection commit test invokes the follow-up builder with an independently supplied empty summary. An integration test carrying selected and null results through each actual publication path would better protect the wiring between selection, conversion, and commit construction. This is optional: the supplied consumers statically support both outcomes correctly.

Score

The implementation is focused, preserves existing fallback behavior, and has relevant regression coverage with passing current-head checks. No merge-blocking defect was established from the supplied diff and context.

Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 30s
  • Tokens: 46,999 (46,502 in / 497 out)
  • Cost: $0.38

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S2

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 17, 2026
@propr-dev propr-dev Bot changed the title 🔨 [3672 by Claude Opus 5.5] Run summary: when the agent's last message is not a summary, let a small model call pick the summary ✅⑨ [3672 by Claude Opus 5.5] Run summary: when the agent's last message is not a summary, let a small model call pick the summary Nov 17, 2026
@integry
integry merged commit 83ff263 into 3616-epic-0-9-d8b Nov 17, 2026
42 checks passed
@propr-dev propr-dev Bot changed the title ✅⑨ [3672 by Claude Opus 5.5] Run summary: when the agent's last message is not a summary, let a small model call pick the summary [3672 by Claude Opus 5.5] Run summary: when the agent's last message is not a summary, let a small model call pick the summary Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant