Skip to content

Fix task resultSummary picking a worker's opening line instead of its final text#107

Merged
juacker merged 1 commit into
mainfrom
fix/task-summary-last-text-part
Jul 11, 2026
Merged

Fix task resultSummary picking a worker's opening line instead of its final text#107
juacker merged 1 commit into
mainfrom
fix/task-summary-last-text-part

Conversation

@juacker

@juacker juacker commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Bug

latest_assistant_text() (the source of a workspace task's resultSummary) scanned messages newest-first but the content parts within a message oldest-first, returning the FIRST non-empty text part of the last assistant message.

Why it only ever bit Codex workers: Claude-provider sessions store each turn as a separate message, so the last assistant message holds only the final text. Codex appserver sessions accumulate an entire run — opening remark, tool_use items, final verdict — as parts of one assistant message. Verified against a live Codex review session in the history DB: 1 assistant message containing 3 text parts + 14 tool_use parts → the stored summary was the worker's opening sentence (observed on three separate review tasks).

Worse than cosmetic: a trailing BLOCKED: verdict was invisible to classify_worker_status(), so blocked Codex workers were misreported as completed.

Fix

  • Extract a pure final_assistant_text() helper that walks both messages AND parts newest-first, with a doc comment explaining the provider difference.
  • 6 unit tests, including the exact Codex regression shape ([text, tool_use, text] → returns the trailing text) and the BLOCKED-classification end-to-end path.

Validation

  • cargo test --lib workspace_tasks: 29 passed (6 new).
  • cargo clippy / cargo fmt clean.
  • Independent full-scope review (Code Reviewer Minimax): production_quality, zero findings.
  • Control experiment: the Minimax review task itself produced a correct resultSummary (separate-message provider), corroborating the single-message root cause.

… final text

latest_assistant_text scanned messages newest-first but the content
parts WITHIN a message oldest-first, returning the FIRST non-empty text
part of the last assistant message.

Claude-provider sessions store each turn as a separate message, so the
last assistant message holds only the final text and the bug never
shows. Codex appserver sessions accumulate an entire run - opening
remark, tool_use items, final verdict - as parts of ONE assistant
message. There the summary became the worker's opening sentence
(observed three times on live review tasks), and a trailing 'BLOCKED:'
verdict was undetectable by classify_worker_status, so blocked Codex
workers were misreported as completed.

Extract the scan into a pure final_assistant_text() helper that walks
both messages and parts newest-first, and cover it with unit tests
including the Codex single-message regression shape.
@juacker
juacker marked this pull request as ready for review July 11, 2026 21:38
@juacker
juacker merged commit 2240bec into main Jul 11, 2026
2 checks passed
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