-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
ADK Bug Report: Input Transcription Events Have Incorrect Author Field
Summary
In ADK's run_live mode, input transcription events (user voice) are saved with author set to the agent name instead of 'user'. This contradicts the function's docstring and can cause issues with event filtering and debugging.
Environment
- ADK Version: Latest (as of January 2025)
- Model:
gemini-2.5-flash-native-audio-preview-12-2025 - Mode:
run_live(WebSocket voice conversation)
Bug Location
File: src/google/adk/flows/llm_flows/base_llm_flow.py
Function: get_author_for_event() (lines ~342-357)
def get_author_for_event(llm_response):
"""Get the author of the event.
When the model returns transcription, the author is "user". Otherwise, the
author is the agent name(not 'model').
"""
if (
llm_response
and llm_response.content
and llm_response.content.role == 'user'
):
return 'user'
else:
return invocation_context.agent.nameProblem
The docstring explicitly states: "When the model returns transcription, the author is 'user'"
However, for input transcription events:
llm_response.contentisNonellm_response.input_transcriptioncontains the user's speech text
The condition llm_response.content evaluates to False, so the function always returns invocation_context.agent.name for transcription events.
Evidence
Database query on a live session shows all events have the agent name as author, even input transcriptions:
SELECT
json_extract(event_data, '$.author') as author,
json_extract(event_data, '$.input_transcription.text') as user_speech
FROM events
WHERE session_id = 'f8fa4acb-5cae-4522-9609-b0386983bb9b';Results:
| author | user_speech |
|---|---|
| lidia_agent | " Hello." |
| lidia_agent | " All right, show me my pants." |
| lidia_agent | " Hi what was the last question I asked you?" |
All three user utterances have author='lidia_agent' instead of author='user'.
Impact
- Event filtering issues: Code that filters by
event.author == 'user'won't find user transcription events _get_current_turn_contents()incontents.pyusesevent.author == 'user'to find turn boundaries- Debugging/tracing: Makes it difficult to distinguish user vs model events in logs
- Potential context issues: While
_get_contents()usesinput_transcriptionvsoutput_transcriptionto build LLM context (which works correctly), other code paths may rely on the author field
Suggested Fix
def get_author_for_event(llm_response):
"""Get the author of the event.
When the model returns transcription, the author is "user". Otherwise, the
author is the agent name(not 'model').
"""
if (
llm_response
and llm_response.content
and llm_response.content.role == 'user'
):
return 'user'
# Fix: Also check for input transcription (user's voice)
if llm_response and llm_response.input_transcription:
return 'user'
return invocation_context.agent.nameReproduction Steps
- Create an ADK agent with
run_liveenabled - Connect via WebSocket and speak to the agent
- Query the
eventstable inadk_sessions.db - Observe that input transcription events have
authorset to agent name instead of'user'
Related Code
base_llm_flow.py:_receive_from_model()- callsget_author_for_event()contents.py:_get_current_turn_contents()- usesevent.author == 'user'for turn detectionrunners.py:_exec_with_plugin()- saves events to session