You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Gemini models, agent is unable to convert the output into the correct structured output type. For example, from the agent run below, the expected output should be a NewsArticle object, but string output is returned instead. This only happens to Gemini models.
Code to reproduce the issue
fromtypingimportOptionalfrompydanticimportBaseModel, Fieldfromagno.agentimportAgentfromagno.models.googleimportGeminifromagno.tools.duckduckgoimportDuckDuckGoToolsclassNewsArticle(BaseModel):
title: str=Field(..., description="Title of the article.")
url: str=Field(..., description="Link to the article.")
summary: Optional[str] =Field(..., description="Summary of the article if available.")
classSearchResults(BaseModel):
articles: list[NewsArticle]
agent=Agent(
# model=Gemini(id='gemini-2.0-flash'),model=Gemini(id='gemini-2.0-flash-lite-preview-02-05'),
tools=[DuckDuckGoTools()],
instructions=['Given a topic, search for the top 5 articles.'],
add_datetime_to_instructions=True, # add the current dateresponse_model=SearchResults,
structured_outputs=True,
debug_mode=True,
show_tool_calls=True,
)
response=agent.run('Search for today\'s top news')
Log
DEBUG *********** Agent Run End:
20d98dba-126b-4129-ada8-7cec33cf246b ***********
WARNING Failed to convert response to response_model
The text was updated successfully, but these errors were encountered:
When using Gemini models, agent is unable to convert the output into the correct structured output type. For example, from the agent run below, the expected output should be a NewsArticle object, but string output is returned instead. This only happens to Gemini models.
Code to reproduce the issue
Log
The text was updated successfully, but these errors were encountered: