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
I confirm that I'm using the latest version of Pydantic AI
Description
When my structured result is a single result everything works fine.
But when my system prompt returns a list of results - like "Ensure the output are 5 search queries matching the user input." the framework throws an exception:
│ /home/erik/miniconda3/envs/llm/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py:81 in │
│ increment_retries │
│ │
│ 78 │ def increment_retries(self, max_result_retries: int) -> None: │
│ 79 │ │ self.retries += 1 │
│ 80 │ │ if self.retries > max_result_retries: │
│ ❱ 81 │ │ │ raise exceptions.UnexpectedModelBehavior( │
│ 82 │ │ │ │ f'Exceeded maximum retries ({max_result_retries}) for result validation' │
│ 83 │ │ │ ) │
│ 84 │
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
UnexpectedModelBehavior: Exceeded maximum retries (1) for result validation
It does not matter how I define the list for example:
result_type=list[Person]
or @DataClass
Answer:
persons: List[Person]
result_type=Answer
Example Code
@dataclassclassPerson :
name: strage: intagent=Agent(
model=llm,
result_type=list(Person),
system_prompt='Extract name and age of all persons from the following text. \n\n###TEXT####\n',
)
result=agent.run_sync("John Doe, 36 years old, is an carpenter. Jane Austin,46 years old, is an author.")
Initial Checks
Description
When my structured result is a single result everything works fine.
But when my system prompt returns a list of results - like "Ensure the output are 5 search queries matching the user input." the framework throws an exception:
│ /home/erik/miniconda3/envs/llm/lib/python3.12/site-packages/pydantic_ai/_agent_graph.py:81 in │
│ increment_retries │
│ │
│ 78 │ def increment_retries(self, max_result_retries: int) -> None: │
│ 79 │ │ self.retries += 1 │
│ 80 │ │ if self.retries > max_result_retries: │
│ ❱ 81 │ │ │ raise exceptions.UnexpectedModelBehavior( │
│ 82 │ │ │ │ f'Exceeded maximum retries ({max_result_retries}) for result validation' │
│ 83 │ │ │ ) │
│ 84 │
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
UnexpectedModelBehavior: Exceeded maximum retries (1) for result validation
It does not matter how I define the list for example:
result_type=list[Person]
or
@DataClass
Answer:
persons: List[Person]
result_type=Answer
Example Code
Python, Pydantic AI & LLM client version
The text was updated successfully, but these errors were encountered: