You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix Pi turns staying active after handled extension commands - #4066
Pi acknowledges handled extension commands and intercepted input without starting an agent run. BB nevertheless waited for agent_end, leaving commands such as /ponytail lite permanently Working even though the mode change had already been persisted. Reproduced on upstream main 18960354e462d514c0d6071ba1ed0f8f2acd625c; investigation evidence is in #3792.
What changed
After a successful, non-queued Pi prompt preflight, query Pi's existing get_state RPC. If Pi reports neither streaming nor compaction, finish that specific outstanding settlement. Await already-received event delivery first so an actual agent completion/error retains its outcome. The state probe races the run settlement so a hanging probe cannot delay an already-completed turn. A failed state probe preserves event-based completion instead of treating an accepted prompt as failed. Active runs and queued inputs retain their existing completion path; remove settlements by identity so an asynchronous probe cannot discard another dispatch.
Added a real Pi subprocess regression with an isolated agent directory and an in-process fixture model. It covers repeated handled commands, intercepted input, delayed normal preflight, an active model run with an injected status-probe rejection, a completed run with a deliberately unresolved probe, and queued follow-up input without making model API calls. Added an ACP regression for a plain prompt that returns only stopReason, without activity notifications.
No server/daemon wire fields, public SDK, CLI, or configuration contracts change; no host protocol version bump is required.
How you verified
Before the fix, the real Pi 0.84.0 subprocess regression fails with expected 'pending' to deeply equal {}. It passes with the fix.
Isolated source BB server/daemon with installed Pi 0.87.0: main receives ponytail-mode: lite, remains active, and emits provider_turn_start_timeout. After applying the fix and stopping/retrying the same synthetic thread, the same command produces turn/started, turn/input/accepted, and turn/completed, and the thread returns to idle. A subsequent mode change also completes. Original production threads were not modified.
The probe-failure regression fails before the follow-up fix because settlement completes while Pi is still streaming; after the fix it stays pending until agent_end, without invoking the session failure callback. A separate hanging-probe check fails before the follow-up race fix and now completes before the probe is released; another command then completes normally.
pnpm exec turbo run test typecheck --filter=bb-plugin-provider-pi: 169 tests passed, typecheck passed.
pnpm exec turbo run test typecheck --filter=@bb/provider-bridge-acp: 326 tests passed, typecheck passed, including the new no-activity regression.
pnpm exec turbo run test --filter=bb-plugin-provider-codex --filter=bb-plugin-provider-claude-code -- --run bridge.conformance.test.ts bridge.zero-work-turn.test.ts: Codex 24 tests and Claude Code's canonical protocol suite passed. Claude's suite explicitly exercises result-only completion; Codex exercises zero-work turns.
Checks ran on Node 22.23.2 / macOS 27.0. An initial broad ACP run hit the existing missing-executable test's EACCES versus ENOENT expectation with the inherited PATH; rerunning with a clean executable PATH passed. Other-provider checks use their protocol fixtures, not a claim that every external ACP agent or live Claude/Codex version was exercised. No UI code changed; full-app verification used the source CLI and persisted thread events.
An unresponsive get_state probe now delays an otherwise completed agent turn for the full 30-second default RPC timeout: this callback cannot reach await settlement until the probe finishes, even when agent_end has already resolved the settlement. Race the probe against settlement so event-based completion remains immediate when the status RPC hangs; the existing identity check still makes the late probe safe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Pi acknowledges handled extension commands and intercepted input without starting an agent run. BB nevertheless waited for
agent_end, leaving commands such as/ponytail litepermanently Working even though the mode change had already been persisted. Reproduced on upstream main18960354e462d514c0d6071ba1ed0f8f2acd625c; investigation evidence is in #3792.What changed
After a successful, non-queued Pi prompt preflight, query Pi's existing
get_stateRPC. If Pi reports neither streaming nor compaction, finish that specific outstanding settlement. Await already-received event delivery first so an actual agent completion/error retains its outcome. The state probe races the run settlement so a hanging probe cannot delay an already-completed turn. A failed state probe preserves event-based completion instead of treating an accepted prompt as failed. Active runs and queued inputs retain their existing completion path; remove settlements by identity so an asynchronous probe cannot discard another dispatch.Added a real Pi subprocess regression with an isolated agent directory and an in-process fixture model. It covers repeated handled commands, intercepted input, delayed normal preflight, an active model run with an injected status-probe rejection, a completed run with a deliberately unresolved probe, and queued follow-up input without making model API calls. Added an ACP regression for a plain prompt that returns only
stopReason, without activity notifications.No server/daemon wire fields, public SDK, CLI, or configuration contracts change; no host protocol version bump is required.
How you verified
expected 'pending' to deeply equal {}. It passes with the fix.ponytail-mode: lite, remains active, and emitsprovider_turn_start_timeout. After applying the fix and stopping/retrying the same synthetic thread, the same command producesturn/started,turn/input/accepted, andturn/completed, and the thread returns toidle. A subsequent mode change also completes. Original production threads were not modified.agent_end, without invoking the session failure callback. A separate hanging-probe check fails before the follow-up race fix and now completes before the probe is released; another command then completes normally.pnpm exec turbo run test typecheck --filter=bb-plugin-provider-pi: 169 tests passed, typecheck passed.pnpm exec turbo run test typecheck --filter=@bb/provider-bridge-acp: 326 tests passed, typecheck passed, including the new no-activity regression.pnpm exec turbo run test --filter=bb-plugin-provider-codex --filter=bb-plugin-provider-claude-code -- --run bridge.conformance.test.ts bridge.zero-work-turn.test.ts: Codex 24 tests and Claude Code's canonical protocol suite passed. Claude's suite explicitly exercises result-only completion; Codex exercises zero-work turns.Checks ran on Node 22.23.2 / macOS 27.0. An initial broad ACP run hit the existing missing-executable test's
EACCESversusENOENTexpectation with the inherited PATH; rerunning with a clean executable PATH passed. Other-provider checks use their protocol fixtures, not a claim that every external ACP agent or live Claude/Codex version was exercised. No UI code changed; full-app verification used the source CLI and persisted thread events.Fixes #3792