Skip to content

Scope thread.idle and thread output to the latest turn's root reply - #6893

Merged
ymichael merged 1 commit into
mainfrom
bb/one-turn-scoped-final-reply-query-thr_n97gzs93hu
Nov 3, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/one-turn-scoped-final-reply-query-thr_n97gzs93hu

Conversation

@ymichael

@ymichael ymichael commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

getLastThreadOutput returned the latest non-empty agent message anywhere in the thread, including subagent messages and legacy system/manager/user_message events. It fed the thread.idle lastAssistantText (push "turn finished" text, Workflows agent() results) and GET /threads/:id/output (bb thread output). After a turn with no top-level reply, these repeated an earlier turn's text or showed a subagent's text. #6821 fixed the same drift for child completion notices only.

What changed

  • apps/server/src/services/threads/thread-data.ts: getLatestTurnFinalOutput returns the final top-level agent message of the latest root turn, through the same getTurnFinalOutput query child notices use. getLastThreadOutput is deleted.
  • thread.idle (plugin-service.ts) and the output route (routes/threads/data.ts) use it, so they still agree as the SDK doc comment says.
  • packages/db: deleted the now-unused getLatestThreadOutputEventRow and its tests.
  • Plugin authoring docs describe lastAssistantText as the latest turn's final reply.

No plugin SDK, host-daemon protocol or RPC contract changes. The legacy system/manager/user_message source is dropped, as #6821 did; nothing writes it any more.

How you verified

  • New test in plugin-thread-events.test.ts runs three turns and checks both thread.idle and the output route: a reply after subagent work, a turn with no reply, and a turn with only subagent output. It failed before the fix (the no-reply turn returned "First result.") and passes after.
  • Existing output-route and slack-bot hero fixtures now record turn/started before their replies, matching real event order.
  • pnpm exec turbo run typecheck lint --filter=@bb/server --filter=@bb/db: passed.
  • pnpm exec turbo run test --filter=@bb/db --filter=@bb/server: all pass except install-machine-script.test.ts "treats launch-agent readiness as authoritative after bootstrap". That test is intermittent locally: it passes on unchanged origin/main and on this branch when run alone, and failed in some runs alongside heroes.test.ts on a loaded machine. This change does not touch the install script or its test.

AGENT GENERATED

getLastThreadOutput returned the latest non-empty agent message of the
whole thread, including subagent messages and legacy
system/manager/user_message events. After a turn with no root reply, the
thread.idle lastAssistantText (push "turn finished" text, Workflows
agent() results) and GET /threads/:id/output (bb thread output) repeated
an earlier turn's text or showed a subagent's text.

Both now read the final root agent message of the latest root turn
through getTurnFinalOutput, the query child completion notices use since
#6821. getLastThreadOutput and getLatestThreadOutputEventRow are deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 4146b26 into main Nov 3, 2026
48 checks passed
@ymichael
ymichael deleted the bb/one-turn-scoped-final-reply-query-thr_n97gzs93hu branch November 3, 2026 18:44
gpambrozio added a commit to gpambrozio/bb-plugins that referenced this pull request Nov 6, 2026
…ion (bb 0.49) (#98)

bb 0.49 (get-bb/bb#6893) gives thread.idle's lastAssistantText and
threads.output only the latest turn's reply, so crew autocompact's
compaction turn yields nothing and the board dropped a blocked,
needs-decision, failed or paused crewmate to Idle. ReportCache now keeps
the report it has on a blank text and, with none cached, reads the last
root agentMessage from the event log (100-row pages).

The charter gets the same fallback for `bb thread output`, words the crew
listing for bb 0.47-0.49 (archived threads left out from 0.49), and uses
`bb git status <environment-id>` for git state, keeping
`bb thread show --work-status` for bb 0.47.

Refs #75.

Co-authored-by: marvin-ambrozio <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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