Skip to content

investigation(run): the exec output handed to createPR was not exec's final message — PR #1310 got the placeholder body although exec ended with a full ## Summary #1311

Closed

Description

@admarble

Found: the #1302 run on 2026-10-04 (run fef277c6-c16e-4b75-a087-6bf0984436fd, MCP server sequant 2.19.0). PR #1310 opened, and was updated after QA, with the placeholder body "Automated PR for issue #1302." Exec's final message did contain the content the body is built from.

Evidence

  • In the exec session transcript (~/.claude/projects/<1302 worktree>/58eef226-….jsonl), the last assistant turn is text. It begins ## Summary, runs about 3,660 characters, and holds the AC table and two SEQUANT_MUTATION markers. No tool call follows it.
  • 2.19.0's own extractExecSummary (from the npx cache dist/), run on that text, returns a 3,634-character summary, and buildAutomatedPRBody renders it.
  • The PR was created at 22:31:19Z, the same minute the transcript was last written.

So the output passed to createPR (latestPhaseResult(phaseResults, "exec")?.output, i.e. the driver's agentResult.output) was not exec's final message. It may have been empty or a different turn. Exec ran for 1,148 s and said it ran "the one full run" of the test suite. A background task finishing after the final message could have produced a later result. That is unverified.

Why it matters: #1297's fix composes the body from execOutput. If the driver hands over the wrong text, no extractor change helps, and QA §6i reads no markers. #1245's run (2.19.0) and #1246's run (2.19.0) did carry exec's Summary, so this is intermittent.

AC

  • AC-1: Find what output the claude-agent-sdk driver returned for this exec, and why it differs from the final assistant text. Evidence: the cause recorded on this issue, with the driver code path (src/lib/workflow/drivers/)
  • AC-2: If the driver can return a non-final turn, or nothing, it returns the final assistant text instead. A fixture reproduces the case. Evidence: a driver test with the fixture
  • AC-3: When the body falls back to the placeholder although exec produced output, the run log records the length of the output it used. Evidence: a batch-executor test

Refs #1297, #1302

Activity

  1. added
    bug
    on Oct 4, 2026
  2. admarble commented on Oct 5, 2026

    @admarble
    ContributorAuthor

    Cause found (reproduced on the #1309 run, 2026-10-05)

    The driver joins assistant text blocks with no separator. ClaudeCodeDriver (src/lib/workflow/drivers/claude-code.ts, the message.type === "assistant" branch) does capturedOutput += textContent, across every assistant message in the session. When an earlier text block does not end in a newline, exec's final ## Summary is glued onto it mid-line. extractExecSummary's heading regex is /^(#{2,3})\s+Summary\s*$/gim, so it cannot match, and the body falls back to the placeholder.

    Reproduction. Run b197fad8 (#1309 exec, PR #1317, sequant 2.19.0) had two assistant text blocks: "Now the edits." and a final message starting ## Summary. No background task and no later turn. The captured output begins Now the edits.## Summary. On the real extractor (src/lib/workflow/worktree-manager.ts) with the session's text blocks:

    • joined with "" (what the driver does): extractExecSummary returns null
    • joined with "\n": it returns 2,446 chars

    PR #1317 got the placeholder body.

    Why it is intermittent. It depends only on whether the text block before the Summary happens to end in \n. The background-task hypothesis above is not needed. This run had none.

    Fix direction for AC-2. Join text blocks with "\n" (or "\n\n") in the driver, or return the final assistant text separately and build the body from that. A fixture made from two blocks, "Now the edits." and "## Summary\n…", reproduces it. Check the other drivers (codex.ts, opencode.ts, aider.ts) for the same concatenation.

  3. admarble commented on Oct 5, 2026

    @admarble
    ContributorAuthor

    Execution Verification

    Command: npx tsx verify-1311.mts <worktree> (runner scratch script; it replays each exec session's assistant text messages through the old "" join and the fixed joinAgentTexts, then through the real extractExecSummary)
    Result: Verified by human review

    Execution Output (click to expand)

    Exit code: 0
    Duration: 1s

    #1309: 2 text messages  | old join -> NO SUMMARY (placeholder) | fixed join -> 2446 chars
    #1312: 11 text messages | old join -> NO SUMMARY (placeholder) | fixed join -> 2562 chars
    #1313: 4 text messages  | old join -> NO SUMMARY (placeholder) | fixed join -> 4000 chars
    #1315: 4 text messages  | old join -> NO SUMMARY (placeholder) | fixed join -> 2876 chars
    

    The four are the 2026-10-05 exec sessions whose PRs (#1317, #1319, #1318, #1320) opened with the placeholder body. 4000 is extractExecSummary's existing cap. A first replay picked each worktree's QA transcript, not exec's, and showed no summary either way. That was a script bug, fixed by selecting the session whose first prompt is "Implement the feature".

    Human Confirmation:

    Yes, looks correct


    Verified by /verify command

  4. added a commit that references this issue on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions