Skip to content

fix(side-chat): deliver reply anchor on first turn - #2403

Merged
ymichael merged 4 commits into
get-bb:mainfrom
kongenpei:bb/fix-side-chat-reply-anchor-delivery-thr_zgfrdn7zhs
Aug 25, 2026
Merged

fix(side-chat): deliver reply anchor on first turn#2403
ymichael merged 4 commits into
get-bb:mainfrom
kongenpei:bb/fix-side-chat-reply-anchor-delivery-thr_zgfrdn7zhs

Conversation

@kongenpei

@kongenpei kongenpei commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What was wrong

Side-chat forks persisted the selected-message reply anchor as agent-only input, but deliberately started the native provider fork with empty input so it remained idle. The first real send built its provider command only from the new message, leaving the anchor out of the first provider turn. This affected Codex, Claude Code, and Pi before provider-specific translation. See #2316.

What changed

  • Resolve deferred agent-only thread-start context before the first real provider-bound turn.
  • Prepend that context to flat provider input and the first grouped input for direct and queued sends.
  • Revalidate eligibility inside the send transaction so concurrent sends cannot deliver the anchor twice.
  • Keep context deferred across a dispatch failure until a provider turn/started exists; later turns never receive it again.
  • Exclude agent-only context from user-editable prompt history while retaining it on the accepted turn request.
  • Always create reply context for a non-empty side-chat anchor, including the latest source message, and remove the unnecessary source-timeline lookup.
  • Keep the initial native fork idle with an empty thread.start.input.
  • Increment HOST_DAEMON_PROTOCOL_VERSION to 168 because turn.submit.input semantics change. The wire shape and database schema are unchanged.

How you verified

The deterministic first-turn assertion failed on main before the fix: expected [seed, firstReply], received only [firstReply].

  • pnpm exec turbo run test --filter=@bb/server -- test/public/public-thread-fork.test.ts test/services/prompt-history.test.ts — 29 tests passed.
  • pnpm exec turbo run test --filter=bb-plugin-side-chat — 25 tests passed.
  • pnpm exec turbo run test --filter=@bb/host-daemon-contract -- test/contract.test.ts — 37 tests passed.
  • pnpm exec turbo run typecheck --filter=@bb/server --filter=bb-plugin-side-chat --filter=@bb/db --filter=@bb/host-daemon-contract — 8 Turbo tasks passed.
  • Browser flow with a side chat anchored to a BANANA instruction: before the fix the provider answered APPLE; after the fix it answered BANANA.

Fixes #2316

AGENT GENERATED

@ymichael ymichael self-assigned this Aug 25, 2026
# Conflicts:
#	apps/server/src/services/prompt-history.ts
#	apps/server/test/public/public-thread-fork.test.ts
#	apps/server/test/services/prompt-history.test.ts
#	packages/host-daemon-contract/src/protocol.ts
#	packages/host-daemon-contract/test/contract.test.ts
@ymichael
ymichael merged commit c65d2ec into get-bb:main Aug 25, 2026
15 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.

Side-chat reply anchor is persisted but omitted from the first provider turn

2 participants