Add `ToolCallJudge` to assess tool calls before execution

Merged
DO
2mo ago
+1998-3

Why we make these changes

A tool's name alone may not show whether a particular call is risky; its arguments matter. ToolCallJudge uses a second model to assess selected calls before their tool functions run. Closes #9172.

New public surface

  • ToolCallJudge and ToolCallVerdict in pydantic_ai_harness.tool_call_judge

User-visible behavior

Before: a selected tool call runs after argument validation.
After: configure ToolCallJudge with a tool selector and risk question; a yes blocks the call, a no lets it run, and uncertainty blocks by default.

Verification

What changes for existing users

Nothing unless they add ToolCallJudge; calls outside its selector run unchanged.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
  • PR title is fit for the release changelog.