Symptom
A prepare_tools callback that returns None leaves the agent with no tools. The model answers in prose. Nothing is raised, logged, or traced.
Evidence what you'll see
- The report contrasts that with
Agent(prepare_tools=None), which keeps every tool. - The coalesce in
PreparedToolset.get_toolsisNone or [].
Why it happens
Returning None from the callback means no tools for that step. Passing prepare_tools=None to the agent means there is no callback.
Affected versions
Pydantic AI 1.65.0, Python 3.11. The linked issue does not name an operating system.
Fix steps
0 of 2 done
Your check marks stay in this browser only.
How to check it worked
- Run the agent and confirm it can call its tools. A callback that returns
tool_defsdoes not emit theUserWarningaboutNone.
If it still fails
- On
v1.103.0a callback that still returnsNonestill removes every tool, and the warning names that callback. The linked issue does not describe a silent removal on that version.
Sources and credit
Summarized in our own words from these public reports. Credit goes to their authors.
Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change
Hit an error we don't cover? Submit it