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
What happens
Running a multi-step tool-use turn with Pi on google/gemini-4-neon shows repeated (empty response) rows between almost every tool call on web and desktop.
Root cause
In Pi's Google stream parser (google-generative-ai.ts#L124-L182), part.text !== undefined matches empty text parts on tool-use turns, so Pi emits text_start, text_delta with delta: "", and later text_end with content: "". Pi's google-vertex.ts has the same check, and Pi cannot drop all empty text parts unconditionally because Gemini can attach a required thoughtSignature to an empty text part (google-shared.ts#L290-L294).
In T3 Code's Pi adapter, there is a 50ms flush race:
message_updatefortext_delta(packages/provider-pi/src/server/adapter.ts#L2382-L2390) callsstreamItemForandscheduleStreamFlusheven whendeltaanditem.textare empty.scheduleStreamFlush(adapter.ts#L1320-L1333) waitsSTREAM_FLUSH_MS = 50(adapter.ts#L92) and callsemitStreamItem(turn, item, true)without checking whether the item is still empty and unpublished.- If
text_endarrives before the 50ms flush fires,completeStreamItem(adapter.ts#L1360-L1369) seesitem.text.length === 0 && !item.publishedand drops it. - If the flush fires first,
emitStreamItempublishes an emptyassistant_messageand setsitem.published = true, socompleteStreamItemthen finalizes it as a completed empty message. In one real 18-step tool-use turn, 16 of the 18 steps took 52ms to 475ms and turned into emptyassistant_messagerows. - Web and desktop then render each completed empty
assistant_messageas(empty response)inTimelineAssistantRows.tsx#L38.
Steps to reproduce
Deterministic repro for packages/provider-pi/src/server/adapter.test.ts:
- Start a Pi turn and emit
message_startwithrole: "assistant". - Emit
message_updatewithtext_start, thentext_deltawithdelta: "". - Wait longer than
STREAM_FLUSH_MS(50ms), then emittext_endwithcontent: ""andmessage_end. - An empty
assistant_messageturn item and message are emitted.
Live repro:
- Run a multi-step tool-use prompt in T3 Code using Pi with
google/gemini-4-neon. - Watch
(empty response)rows appear between tool calls.
Expected behavior
An unpublished stream item with empty text should not be flushed or finalized as an assistant_message, matching how ProviderTextDeltaCoalescer in the Claude and Codex adapters ignores empty appends.
Fix notes
- Keep
completeStreamItem'sitem.publishedcheck so an already-published block that restarts empty still clears stale text (see [Bug]: Pi reasoning shows an abandoned attempt in front of its replacement when the provider starts the block again #38335 andadapter.test.ts#L6389-L6449). - Guarding inside
scheduleStreamFlushto skipemitStreamItemwhenitem.completed || (item.text.length === 0 && !item.published)(using exact zero length, nottrim()) covers both emptytext_deltaevents and the case where a non-empty delta schedules a flush and a reconnecttext_startresetsrestarted.text = ""(adapter.ts#L2376-L2380) before the timer fires.
Impact
Minor bug or occasional failure
Version or commit
T3 Code 0.1.11, still present on main @ 20a3bed880
Environment
macOS desktop client connected to Linux t3 serve host, Pi 1.6.0, google/gemini-4-neon
Activity
test(pi): empty text block outliving the stream flush is not shown (#…
juliusmarminge commentedon Nov 25, 2026
I tried to reproduce this on the current build and could not.
Commit: origin/main @ 2fbb071. Deterministic: added a test to packages/provider-pi/src/server/adapter.test.ts (branch factory/repro-42689, 53d876c) that drives the real Pi adapter with a fake Pi RPC process: message_start(assistant), text_start + text_delta with delta "" on contentIndex 0, a tool_execution_start as the milestone that shows the delta was handled, TestClock.adjust(120ms) (past STREAM_FLUSH_MS = 50), text_end with content "", message_end, then a second assistant message whose text_end content is "Answer", then agent_settled. On main the emitted message.updated texts are ['', '', 'Answer'] (an empty running message from the flush timer, then a completed empty message); expected ['Answer']. With the reporter's guard added temporarily to scheduleStreamFlush (skip emit when item.completed || (item.text.length === 0 && !item.published)), the new test and all 187 tests in the file pass, including the #38335 restart test; the guard was reverted and only the test is on the branch. Live attempt: Pi 1.6.0 in json/print mode with a scratch PI_CODING_AGENT_DIR pointing the google provider at the hub, models google/gemini-4-neon, gemini-4-hydrogen and gemini-3.8-flash, on a multi-step read-tool prompt. Every attempt failed with hub 429 'Individual quota reached' (model_cooldown; Neon resets in about 116h), so Gemini's real stream was never observed and the app was not run end to end with Pi+Gemini.
Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.
harshit97 commentedon Nov 25, 2026
Hey @juliusmarminge, I think this one got closed by mistake. The triage run did reproduce it.
The test added in 53d876cb5dc81edb14182855e93a27a2cf3523e6 fails on
main. It emits['', '', 'Answer']where['Answer']is expected, which is the bug. The same comment says that with thescheduleStreamFlushguard applied, all 187 tests in the file pass.The only thing that didn't work was the live Gemini run. It hit a 429 quota error before any stream came back, so it never got far enough to tell us anything.
Could you reopen this? Happy to send a PR with the guard and that test if that's useful.