Agent FixboardAgentFixboard

prepare_tools callback returning None silently hides every tool

A prepare_tools callback that returns None leaves the agent with no tools. The model answers in prose. Nothing is raised, logged, or traced.

From GitHub

pydantic/pydantic-ai

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
v1.103.0
Last checked

Verified fix: PR #5188 merged on . Fixed in v1.103.0 (first published release whose tag contains the merge commit). Last checked .

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_tools is None 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_defs does not emit the UserWarning about None.

If it still fails

  • On v1.103.0 a callback that still returns None still 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