-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Describe the bug
When using LiteLLM with other models (even when using Gemini models), structured output doesn't seem to be correctly output. The output is "almost correct" but not valid. I'm currently just using the default implementation of structured output with ADK, but have seen other issues reference modifying the args of the LiteLLM instance, this isn't obvious nor documented though.
To Reproduce
Using implementation like this
structured_output_agent = Agent(
name="structured_output_agent",
model=LiteLlm(model="gemini-2.5-flash"),
description="Converts structured data into a user-friendly UI format.",
instruction="""
You are an assistant that takes structured input and generates a clear, concise UI response.
""",
output_schema=UIOutput,
disallow_transfer_to_parent=True,
disallow_transfer_to_peers=True,
)
The output isn't matching what is specified in UIOutput
e.g.
What is specified is like the following
class SelectorComponent(BaseModel):
component_type: Literal["selector"] = Field(
"selector", description="The type identifier for a selector component."
)
id: conlist(int, min_length=1) = Field(
..., description="List of unique ids. e.g. [12345, 67890]"
)
actions: conlist(str, min_length=1, max_length=2) = Field(
...,
description="List of possible user actions. Keep this text short.",
)
UIComponent = Union[
SelectorComponent,
]
class UIOutput(BaseModel):
components: List[UIComponent] = Field(
...,
description="A list of UI components to be enriched on the backend and then rendered in the application.",
)
But the output is missing key fields like actions
{
"components": [
{
"component_type": "selector",
"ids": [
3584831,
3970968,
8453870,
20884876,
3094994,
8932363,
19704840,
20941330,
3404925,
3404956
]
}
]
}
Expected behavior
Ensure all fields are returned including actions
{
"components": [
{
"component_type": "selector",
"ids": [
3584831,
3970968,
8453870,
20884876,
3094994,
8932363,
19704840,
20941330,
3404925,
3404956
],
"actions": ["Yes", "No"]
}
]
}
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
-
OS: [e.g. iOS]
-
Python version(python -V):
-
ADK version(pip show google-adk):
-
Mac
-
Python 3.13.5
-
Google ADK 1.5.0
Model Information:
For example, which model is being used.
Using gemini-2.5-flash
via LiteLLM being sourced from AI studio