-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
🔴 Required Information
Describe the Bug:
RunConfig.response_modalities is typed as Optional[list[str]], but ADK assigns it directly to LiveConnectConfig.response_modalities, which is typed as Optional[list[Modality]] (an enum) by google-genai. Pydantic coerces the enum to a string at the RunConfig level, then warns when serializing the string into a field that expects an enum. This warning fires on every live streaming session and pollutes production logs.
Steps to Reproduce:
- Set up a live streaming agent using
RunConfigwithresponse_modalities=[types.Modality.AUDIO] - Start a live streaming session (the warning is triggered inside ADK's internal flow when
LiveConnectConfigis built fromRunConfig, not at construction time) - Observe the warning in logs
Expected Behavior:
No Pydantic serialization warning. RunConfig.response_modalities should be typed as list[Modality]
Observed Behavior:
/path/to/.venv/lib/python3.13/site-packages/pydantic/main.py:464: UserWarning: Pydantic serializer warnings:
PydanticSerializationUnexpectedValue(Expected `enum` - serialized value may not be as expected [field_name='response_modalities', input_value='AUDIO', input_type=str])
return self.__pydantic_serializer__.to_python(
Environment Details:
- ADK Library Version: 1.26.0
- Desktop OS: macOS
- Python Version: 3.13.7
Model Information:
- Are you using LiteLLM: No
- Which model is being used:
gemini-live-2.5-flash-native-audio
🟡 Optional Information
Regression:
Unknown — this has been present as long as we've used live streaming.
Logs:
/path/to/.venv/lib/python3.13/site-packages/pydantic/main.py:464: UserWarning: Pydantic serializer warnings:
PydanticSerializationUnexpectedValue(Expected `enum` - serialized value may not be as expected [field_name='response_modalities', input_value='AUDIO', input_type=str])
return self.__pydantic_serializer__.to_python(
Additional Context:
The type mismatch is in google/adk/agents/run_config.py:
response_modalities: Optional[list[str]] = Nonevs google/genai/types.py (LiveConnectConfig):
response_modalities: Optional[list[Modality]] = NoneThe fix (LLM generated, just in case) would be changing RunConfig.response_modalities from list[str] to list[Modality].
Minimal Reproduction Code:
A minimal standalone repro requires a full live session. The code path that triggers it is in flows/llm_flows/basic.py:
llm_request.live_connect_config.response_modalities = (
invocation_context.run_config.response_modalities
)How often has this issue occurred?:
- Always (100%)