Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Run a Pi thread on a provider that can reconnect in the middle of a reasoning block and stream that block again from its start. The xAI WebSocket extension
@mwolson-org/pi-xai-wsdoes this from 1.5.0 after a socket drop that interrupts reasoning. - Let the connection drop while the reasoning block is streaming. I forced it with a loopback proxy that cut the WebSocket after 25 reasoning deltas.
- Watch the reasoning in the T3 Code thread while the block streams again.
The same thing as Pi RPC events, which is what the adapter receives:
{"type":"message_start","message":{"role":"assistant"}}
{"type":"message_update","assistantMessageEvent":{"type":"thinking_start","contentIndex":0}}
{"type":"message_update","assistantMessageEvent":{"type":"thinking_delta","contentIndex":0,"delta":"Abandoned attempt"}}
{"type":"message_update","assistantMessageEvent":{"type":"thinking_start","contentIndex":0}}
{"type":"message_update","assistantMessageEvent":{"type":"thinking_delta","contentIndex":0,"delta":"Replacement attempt"}}I found this by reading the adapter, then reproduced it in a live turn on main at 13ecf5b: Pi sent thinking_start twice for content index 0, twelve seconds apart.
Expected behavior
The reasoning shows only the new attempt, as Pi's own TUI does. Pi renders from the partial message it sends with every update, and the provider cleared that message before starting again.
Actual behavior
The reasoning shows the abandoned attempt followed by the new one, run together as one block. In the live turn, the first update after the second thinking_start held the abandoned attempt's 525 characters and then the new attempt, joined in the middle of a sentence: "... modulo 2^31 − 1, checking whetherI will check whether 2147483647 is prime ...". It stayed that way for about a minute, until thinking_end replaced the text with Pi's final content.
Root cause
packages/provider-pi/src/server/adapter.ts keys a stream item by message and content index and appends every thinking_delta or text_delta to it. It ignores thinking_start and text_start, so a second start for an index that is still streaming does not clear what the first attempt collected.
Impact
Cosmetic issue
Version or commit
main @ 13ecf5b
Environment
Linux, Pi 1.5.2 over RPC, xai/grok-4.7 through @mwolson-org/pi-xai-ws 1.5.0
Workaround
None needed for the final message. The live reasoning is wrong until the block ends.
Fix
#38334: a start event for a block that is still streaming clears its collected text.
Sent by Mike's agent (Claude Fable 5.2 in T3 Code, Claude Code harness)
Activity
juliusmarminge commentedon Nov 17, 2026
Fixed by #38334, now on main: When Pi restarts a reasoning block after reconnecting, the next streaming update now shows only the replacement attempt, and an empty replacement clears previously displayed reasoning.