Skip to content

Recheck waiting provider requests with the server after a daemon reconnect - #6252

Closed
timsuchanek wants to merge 2 commits into
get-bb:mainfrom
timsuchanek:fix/interrupted-interaction-stuck-turn
Closed

timsuchanek wants to merge 2 commits into
get-bb:mainfrom
timsuchanek:fix/interrupted-interaction-stuck-turn

Conversation

@timsuchanek

Copy link
Copy Markdown

Human comments

What was wrong

A same-instance daemon reconnect never checked its open provider waits against the server. If the server settled an interaction while the daemon was away, the daemon's InteractiveRequestRegistry kept the provider blocked forever. The turn stayed active and accepted steers it could never read (#6251). On 0.43.4 the 5 s disconnect timer did the settling. On main it happens when the live interactive.resolve command fails, for example with host_unavailable when the socket closes mid-send: settleInteractiveResolveCommandResultInTransaction interrupts the interaction, and the daemon is never told.

What changed

  • apps/host-daemon/src/interactive-request-registry.ts: new revalidateRegisteredRequests(). It re-posts every acknowledged provider wait to the existing /internal/session/interactive-request route, which is idempotent for open requests and returns rejected for settled ones.
    • rejected, or a settled status: the wait is rejected with the server's reason. The provider gets a JSON-RPC error, which the Claude bridge turns into a deny so the turn continues.
    • Still open: keeps waiting.
    • Recreated by the server: adopts the new interaction id.
    • Failed request: keeps waiting and reports through onRevalidationFailure.
    • A wait whose first registration is still in flight is rechecked as soon as that registration returns.
    • The response handling is shared with registerAndWait (applyRegistrationResponse). It now ignores a response for an entry that the registry no longer holds.
  • apps/host-daemon/src/app.ts: onSessionOpened runs the recheck next to flushPendingInteractiveInterrupts(), and failed rechecks are logged.
  • No wire change and no HOST_DAEMON_PROTOCOL_VERSION bump: the change reuses an existing route without changing its fields or meaning. Servers on older versions benefit too.

How you verified

  • New registry tests: a settled wait is rejected after a reconnect; an open wait keeps waiting; a failed recheck keeps the wait; a recreated interaction is adopted; an in-flight first registration is rechecked once it returns; a wait registered after the reconnect is not rechecked.
  • New app test, "rejects a provider wait after reconnecting when the server settled its interaction while the daemon was away". It drives a real socket reconnect and asserts the second registration carries the new session id. It times out at 15 s without the onSessionOpened call. The in-flight registry test times out on the first commit of this branch.
  • pnpm exec turbo run test --filter=@bb/host-daemon: 75 files, 823 passed, 12 skipped.
  • pnpm exec turbo run typecheck --filter=@bb/host-daemon: passes. oxfmt --check is clean on the changed files.
  • Not done: a live reproduction against a main server. The incident in Provider stays blocked on a question the server interrupted after a same-instance daemon reconnect #6251 was on 0.43.4. It was unstuck with bb thread stop and the messages re-sent.
  • Cross-model review: Codex gpt-6-astra (high, Fast) in a BB child thread, 2 rounds. Round 1 found one major issue: a reconnect skipped waits whose first registration was still in flight. It is fixed in 69724e9. Round 2 found nothing. Nothing was refuted and nothing remains.

Fixes #6251

AGENT GENERATED

…nnect

A daemon that reconnected as the same instance kept every provider wait
open even when the server had settled the interaction while it was away.
The provider stayed blocked on a question nobody could answer, and the
turn accepted steers it could never read.

On every session open the daemon now re-registers each provider request
the server already acknowledged. A rejected or settled answer releases
the provider with the server's reason, an open one keeps waiting, a
recreated one adopts the new interaction id, and a failed request leaves
the wait for the next reconnect.
… a reconnect

A reconnect skipped waits that did not have an interaction id yet. If the
server settled the interaction before the delayed first registration
response arrived, nothing rechecked it. Such a wait is now flagged during
the reconnect and rechecked as soon as its first registration finishes.
@github-actions github-actions Bot added the needs-approval PR author is not on the approved contributor list label Oct 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the pull request, @timsuchanek. It was closed automatically because it does not meet the requirements below yet. This is an automated check, not a review of the change.

Contributor approval. bb reviews pull requests only from approved contributors, and you are not on the list yet. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ), post a link to your pull request, and explain what it changes and why. A maintainer then adds you to the list and reopens the pull request.

See CONTRIBUTING.md for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-approval PR author is not on the approved contributor list

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provider stays blocked on a question the server interrupted after a same-instance daemon reconnect

1 participant