Skip to content

fix(gemini): response.done lists the output items of the live turn - #47168

Closed
tech-carrement wants to merge 1 commit into
BerriAI:mainfrom
tech-carrement:fix-gemini-live-one-response-done-per-turn
Closed

tech-carrement wants to merge 1 commit into
BerriAI:mainfrom
tech-carrement:fix-gemini-live-one-response-done-per-turn

Conversation

@tech-carrement

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • OpenAI's response.done lists the items the response produced (output); the Gemini Live bridge always sent output: []
  • Clients that read the function calls or the message items off response.done, instead of collecting every response.output_item.done, saw an empty turn

How it solves it:

  • The bridge remembers the response.output_item.done events it emitted since the previous response.done, across frames, and lists their items in the next response.done
  • The suppressed trailing response.done after a tool call (an existing special case) is untouched: items that follow it are carried to the next real response.done

User Flow

Before: a developer runs a tool-calling turn on ws://localhost:4000/v1/realtime?model=gemini-live

  1. The function call arrives as response.output_item.done, then the spoken answer
  2. Both response.done events carry output: []

After: the same turn

  1. The first response.done lists the function_call item, the second lists the message item

Pre-Submission checklist

  • I have Added testing in the tests/unit directory, Adding at least 1 test is a hard requirement
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Proof of Fix

Live LiteLLM proxy, vertex_ai/gemini-3.8-live in eu, real calls. Client: a set_username tool, one user text item ("Je m'appelle Laurent, enregistre mon prénom s'il te plaît.") then response.create; on the function call it answers with function_call_output and response.create.

Before, merge base 46ae68021e:

t+538ms >> user item + response.create
t+785ms response.created resp_2f593591
t+785ms output_item.done function_call set_username
t+785ms >> function_call_output + response.create
t+786ms response.done resp_2f593591 output=['function_call'] usage_out=0
t+1295ms response.created resp_3587cc69
t+3949ms output_item.done message
t+3955ms response.done resp_3587cc69 output=[] usage_out=153

After, PR tip 63c03de617:

t+840ms >> user item + response.create
t+1160ms response.created resp_03d19557
t+1160ms output_item.done function_call set_username
t+1160ms >> function_call_output + response.create
t+1160ms response.done resp_03d19557 output=['function_call'] usage_out=0
t+1595ms response.created resp_b1a44f7e
t+4683ms output_item.done message
t+4688ms response.done resp_b1a44f7e output=['message'] usage_out=160

The function-call response.done already listed its item (built in the tool-call path); the spoken answer's response.done now lists its message item instead of []. Unit test: tests/unit/llms/gemini/realtime/test_gemini_realtime_transformation.py::test_gemini_response_done_lists_the_output_items_of_the_turn

Type

🐛 Bug Fix

Caveats

  • Low: items are remembered per bridge instance, so a session that closes with items pending simply drops them

Final Attestation

  • I attest that this PR is ready for review and merge

OpenAI's response.done carries the items the response produced; the Gemini
Live bridge always sent output: []. Clients that read the function calls or
the message items off response.done (instead of collecting every
response.output_item.done) saw an empty turn. The bridge now remembers the
output_item.done events it emitted since the previous response.done, across
frames, and lists them in the next response.done.
@codspeed

codspeed Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 32 untouched benchmarks


Comparing tech-carrement:fix-gemini-live-one-response-done-per-turn (63c03de) with main (4273996)

Open in CodSpeed

@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tech-carrement

Copy link
Copy Markdown
Contributor Author

Folding this into one consolidated Gemini Live bridge PR (six commits, one per fix, this one included unchanged) to stay under this account's open-PR cap; link in the next comment. Closing.

@tech-carrement

Copy link
Copy Markdown
Contributor Author

Consolidated in #47172.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant