Skip to content

[Bug]: Pi adapter publishes empty assistant messages, shown as "(empty response)" between tool calls #43433

Done

Description

@harshit97

Before submitting

Why a new issue

#42689 was closed as not planned with a no-repro note, but the triage run on it did reproduce the bug. I can't reopen it myself and my comment there hasn't been picked up, so I'm filing it again with a shorter summary.

Area

apps/server

Actual behavior

With Pi on google/gemini-4-neon, a tool-use turn shows an (empty response) row before almost every tool call on web and desktop.

Pi forwards Gemini's empty text part as a text_delta with delta: "". In the Pi adapter, scheduleStreamFlush publishes the item after 50ms without checking that it has text. When text_end arrives after that, the empty item is already published, so completeStreamItem finalizes it as an empty assistant_message.

Steps to reproduce

Run the test in the commit above. Or by hand:

  1. Start a Pi turn and emit message_start with role: "assistant".
  2. Emit text_start, then text_delta with delta: "".
  3. Wait more than 50ms, then emit text_end with content: "" and message_end.

Expected behavior

No assistant_message for a text block that never had any text.

Suggested fix

In scheduleStreamFlush, skip emitStreamItem when item.text.length === 0 && !item.published. Leave completeStreamItem as it is, so a published block that restarts empty still clears its old text.

Happy to send a PR with this guard and the test above.

Impact

Minor bug or occasional failure

Version or commit

T3 Code 0.1.11. Still present on main at 6ac4edef8cd02ec655b999d213f18e149171a867.

Environment

Desktop client connected to a Linux t3 serve host, Pi 1.6.0, google/gemini-4-neon

Screenshots

Repeated "(empty response)" rows between tool calls in a Pi turn on Gemini 4 Neon

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions