Skip to content

FunctionResponse state_delta not delivered to WebSocket in /run_live #4182

@bashimr

Description

@bashimr

Environment

  • ADK Version: 1.22.1 (also affects 1.20.x)
  • Python: 3.11+
  • Endpoint: /run_live WebSocket
  • Modalities: ["AUDIO"] (voice mode)

Description

When using /run_live for voice interactions, FunctionResponse events containing state_delta are buffered during transcription and never yielded to WebSocket clients. The state is correctly saved to session storage, but clients cannot receive real-time state updates from tools.

Reproduction

  1. Create a tool that sets state_delta:
async def ui_action(action: str, tool_context: ToolContext) -> dict:
    tool_context.state["myAction"] = {"type": action}
    return {"status": "success"}
  1. Connect to /run_live with audio modality
  2. Speak a command that triggers the tool
  3. Observe WebSocket messages

Expected

WebSocket receives FunctionResponse event with state_delta:

{"actions": {"stateDelta": {"myAction": {"type": "..."}}}, ...}

Actual

WebSocket only receives events with empty stateDelta:

{"actions": {"stateDelta": {}}, ...}

Backend logs confirm state_delta was set:

DEBUG: Appending buffered event: Event(..., state_delta={'myAction': {...}})

Root Cause

runners.py lines 753-757:

if is_transcribing and _is_tool_call_or_response(event):
    buffered_events.append(event)
    continue  # Skips yield!

Lines 780-785 append buffered events to session but don't yield them:

for buffered_event in buffered_events:
    await self.session_service.append_event(session, buffered_event)
    # Missing: yield buffered_event

Suggested Fix

Add yield after appending buffered events (after line 784):

for buffered_event in buffered_events:
    await self.session_service.append_event(session, buffered_event)
    yield buffered_event  # Add this line

Workaround

Poll session state via GET /apps/{app}/users/{user}/sessions/{session} on turnComplete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    live[Component] This issue is related to live, voice and video chat

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions