-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
As we discussed in the pydantic-ai slack channel (message: Andreas Simmeth / Friday, 29.08.2025), there is currently an issue when a Groq model (e.g. "openai/gpt-oss-120b") calls a tool with wrong parameters. As far as we found out in the chat, Groq's API is returning a tool_use_failed error that their SDK turns into a groq.APIError. This leads to the problem, that the message iteration using agent.iter(...) is breaking and not doing a retry using "ToolRetryError" as on other models (e.g. "us.anthropic.claude-sonnet-4-20250514-v1:0").
The first idea in the chat was that one could add an exception handler and read the error code from https://github.com/groq/groq-python/blob/aa6d8b1805e74673880ee5a6e1d56b96b7587738/src/groq/_exceptions.py#L29, but the problem that was mentioned is that there is currently no handling for such a request exception by sending a "try again" message to the model. It also technically wouldn't be "try again", as one wouldn't have gotten an invalid model response in the message history at all... This'll require a bit more thinking on how to handle in the best way, that's why I created the issue here.
I add some screenshots of the chat + the files I shared there directly here, so you have everything in one place. Thanks in advance for investigating on the error.



groq_http_request.json
groq_api_error_with_traceback.json
Example Code
Python, Pydantic AI & LLM client version
Python: 3.12.8
PydanticAI: 0.8.0
LLM: GroqProvider with "openai/gpt-oss-120b"


