Skip to content

Pi extension-triggered turn stays working after agent_end #1633

Closed

Description

@ryanbbrown

Versions

  • bb 0.37.0
  • Pi 0.84.0
  • pi-processes 0.10.9

Reproduction

  1. Start a process through the pi-processes extension.
  2. Configure its completion notification with onSuccess: "turn".
  3. Let the process finish while the agent is idle.
  4. Pi starts an extension-triggered turn and the assistant returns a final response.

bb continues to show the thread as working until the user stops the turn.

Cause

The Pi adapter validates each agent_end.messages[] item with a schema that accepts only content-block arrays. Pi 0.84.0 also permits string content for user and custom messages. pi-processes sends a custom message with string content through pi.sendMessage({ triggerTurn: true, deliverAs: "steer" }).

The invalid schema rejects the complete agent_end event. bb reports sdk/agent_end as provider/unhandled and does not emit turn/completed. Client-started turns have a separate prompt settlement path. Extension-triggered turns do not.

Expected behavior

The adapter must accept every valid Pi AgentMessage.content form. A valid extension-triggered agent_end must emit turn/completed and must not be classified as unhandled.

The required onSuccess: "turn" pi-processes behavior must remain unchanged.

Tested implementation

Implementation: ryanbbrown@bee15e5

The regression test fails before the fix because only provider/unhandled is emitted. After the fix, it emits turn/completed and no unhandled event.

Validation:

  • 954 agent-runtime tests passed.
  • The agent-runtime Turbo typecheck passed.
  • One independent review-panel cycle passed with no required changes.
  • No agent_settled fallback was needed.

AGENT GENERATED: by GPT-5

Activity

  1. added theissue type on Aug 17, 2026
  2. added
    providers
    provider-pi
    on Aug 18, 2026
  3. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1633.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): piConversationMessageSchema in packages/agent-runtime/src/pi/event-translation.ts accepts only array content, so a string-content extension custom message in agent_end.messages makes the whole agent_end parse fail -> provider/unhandled instead of turn/completed; extension-triggered turns have no pi/prompt/settled fallback, so the turn never closes.
    • Linked PR review: Fix Pi extension-triggered turn completion #1663 → MERGE — One-line zod union fix is correct and verified live (thread completes, item/completed + turn/completed emitted); non-blocking nits: still an allowlist of content shapes for messages bb never reads, no defensive 'agent_end always closes turn' net, custom message_start/message_end still render as Unha
    • Proposed fix: (1) Loosen piAgentEndEventSchema.messages to role-only passthrough records and keep strict assistant narrowing in findLastAssistantMessage (PR Fix Pi extension-triggered turn completion #1663's string|array union is an acceptable narrower variant). (2) In the agent_end case, when detailed parse fails but type==='agent_end' and willRetry!==true, still emit provider/unhandled AND turn/completed + finishTurn so a terminal event can never wedge a turn. (3) Add 'custom' (and other non-model roles) to toPiMessageBoundaryRole in visibility.ts so extension messages stop rendering as 'Unhandled Pi event'. All in packages/agent-runtime; no wire …
    • Caveats: Did not install pi-processes itself; used a minimal user-scope Pi extension calling the same pi.sendMessage({content:string},{triggerTurn:true,deliverAs:'steer'}) API. Live repro required PI_CODING_AGENT_DIR pointing at a scratch agent dir (copy of ~/.pi/agent auth/models/settings, deleted afterwards) because project-scope .pi/extensions are untrusted in the bridge and silently not loaded. Worktre…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  4. added
    confirmed-repro
    on Aug 18, 2026
  5. added a commit that references this issue on Aug 18, 2026
    be223fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproprovider-piproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions