Learning resourcesReviewed · Pydantic

Pydantic AI Harness Tool Call Judge guide

This guide is for Python developers who want a second AI model to check an agent's tool calls, but that check cannot replace the tool's own security controls. It explains Pydantic AI Harness tool selection, uncertainty handling, human approval, tracing and durable execution.

Researched 25 Nov 2026

In short.

This guide is for Python developers adding Tool Call Judge to screen agent tool calls with a second AI model, but its decisions can be wrong and full tool arguments reach the judging provider even when a call is blocked. The capability checks validated arguments before the tool function runs. A risk answer of yes blocks execution; no allows it; uncertainty can block, allow or request human approval. The page explains configuration, approval interactions, shared usage limits and durable replay. Provider-hosted native tools fall outside its coverage. Costs, measured effectiveness and runtime behavior were not assessed; no code was executed.

Researched and written by an AI model and checked by a second AI model. How it works

The evidence covers the complete selected documentation page at [https://pydantic.dev/docs/ai/harness/tool-call-judge/index.md], including examples and API reference. Linked pages and implementation files are excluded. Relevant notices include possible API changes during 0.x releases, exclusion of provider-hosted native tools and the warning that the judge is not a security boundary. No installation or execution occurred; runtime behavior, effectiveness, costs, licensing and model availability were not verified.

The overview

identity

The resource is the Tool Call Judge documentation page for Pydantic AI Harness at [https://pydantic.dev/docs/ai/harness/tool-call-judge/index.md]. It combines a practical guide with API documentation for ToolCallJudge and ToolCallVerdict.

ToolCallJudge is a Python agent capability that asks another model a risk question before selected tool functions execute. The page links its implementation at [https://github.com/pydantic/pydantic-ai/tree/main/src/pydantic_ai_harness/pydantic_ai_harness/tool_call_judge/], but that repository was not examined.

assessment

The guide is useful when a tool call's acceptability depends on its arguments: which path would be deleted, for example, rather than whether deletion tools are available at all. It explains how to add a model check without requiring a person to review every call.

Its strongest practical detail is the treatment of failure and approval interactions. The default blocks uncertain calls, including provider failures and exhausted usage budgets, which can also interrupt legitimate work. The page provides no measured detection accuracy, false-block rate or security evaluation.

users

The primary audience is Python developers building Pydantic AI agents with client-executed function tools. Scheduled agents, long-running tasks and applications combining automation with occasional human approval are directly relevant use cases.

Beginners get installation instructions and a small example, but applying the guide requires understanding agents, tool arguments and provider credentials. Experienced developers get details about execution hooks, concurrent usage accounting, serializable configurations and durable workflows.

capabilities

A judge can cover every function tool, named tools, tools matching metadata or tools chosen by a predicate. Multiple judges can use different questions, models and uncertainty policies. They evaluate in capability order; the first block stops execution and prevents later judges from running.

Observability includes a judge tool call tracing span, application callbacks and verdict metadata on blocked tool results. Confidence is available only when the provider supplies it in response metadata; the judging model returns yes, no or unsure without a free-text explanation.

In documented durable workflows using Temporal, DBOS or Prefect, the judgment is checkpointed and replay reuses its verdict. Agent specifications support serializable configuration, while live model objects, predicate selectors and callbacks require code.

Using it

requirements

The integration requires a Pydantic AI agent, the pydantic-ai-harness package and access to a judging model through its provider integration. The illustrated Anthropic setup additionally installs pydantic-ai-slim[anthropic] and uses ANTHROPIC_API_KEY.

Human escalation through on_uncertain='ask' requires DeferredToolRequests in the agent's output type. A judge attached to a durable-capable agent needs an explicit id, distinct from other judges. The page does not establish a minimum Python version or pin a package release.

mechanism

ToolCallJudge runs through before_tool_execute after argument validation and before the tool function executes. By default, its internal agent receives fixed instructions containing the risk question, plus the tool name and full validated arguments. It receives none of the outer conversation, instructions or earlier tool results.

A yes answer blocks the call; no allows it. An unsure answer, exception, invalid response or exceeded usage limit follows on_uncertain: block by default, allow or ask a person. Blocking substitutes denial_message for the tool result so the outer agent can continue.

Human approval happens before this execution hook. A denied call never reaches the judge; an approved call can still be blocked by a yes answer. For a call already approved by a person, on_uncertain='ask' allows an uncertain result instead of requesting approval again.

setup

The page's Anthropic example uses pip install pydantic-ai-harness "pydantic-ai-slim[anthropic]", with a corresponding uv add option, followed by setting ANTHROPIC_API_KEY. These are documented instructions; installation and model availability were not verified.

Import ToolCallJudge from pydantic_ai_harness.tool_call_judge, configure the judging model, tools and risk question, then pass the instance in the Agent capabilities list. Phrase the question so yes means the call should be blocked.

Set include_conversation=True only when the question needs conversational context. Its default conversation_window is 4000 estimated tokens. For durable execution, assign a unique id; callbacks that write externally should deduplicate using ToolCallVerdict.tool_call_id because callbacks run again on replay.

example

The main example applies a judge to delete_file and asks whether the call would destroy data, spend money or leak secrets. Its sample delete_file function only returns a message saying deletion was requested; it does not delete a file.

The agent is asked to delete ./old-report.txt, but the displayed output is an ellipsis. The snippet therefore establishes neither a particular verdict nor a successful run. The documented behavior is that yes prevents the function from executing, while no lets it proceed.

Assessment & evidence

limitations

This is a model filter, not a security boundary. Sensitive tools still need authentication, authorization, argument validation, least privilege and recovery controls. Tools outside the selector and provider-hosted native tools are not judged. The capability does not inspect the agent's final output.

Full validated arguments go to the judging provider even when the call is subsequently blocked. With conversation enabled, the judge also receives user and assistant messages, tool calls and tool results, truncated to a recent window estimated at roughly four characters per token. System prompts and thinking parts are excluded; tool arguments remain complete.

Conversation context increases exposure to prompt injection. The documented instructions and tag escaping reduce that risk without eliminating it. Arguments can also appear in tracing when trace_include_content is enabled, although the internal judge agent's prompt is not instrumented.

There is no calibrated severity scale or per-tool numerical threshold. An allow policy permits calls when judgment fails, and an ask policy permits uncertain calls after human approval.

reasoning

A useful risk question must be answerable from what the judge receives. The default input may support checking a path or amount, but cannot establish whether a deletion matches the user's earlier request. Adding conversation can supply that context while increasing disclosure and prompt-injection exposure.

The uncertainty policy is an operational choice: block stops unclear calls, allow continues despite uncertainty, and ask introduces human availability as a dependency. Separate judges express different policies for different tools without relying on uncalibrated severity scores.

alternatives

Human approval through requires_approval=True is relevant when a person should decide before execution. ApprovalReviewer serves a different role: it can approve calls already awaiting approval before they reach a person. ToolCallJudge instead operates at execution and can block a call even after a person approves it.

OutputGuardrail addresses final output rather than tool execution. Allowlists and argument validation provide deterministic controls for anticipated cases and remain complementary. These distinctions are described on the supplied page; the linked guides were not assessed.

evidence

The evidence is the complete documentation page at [https://pydantic.dev/docs/ai/harness/tool-call-judge/index.md], including its explanatory text, examples and API reference. Linked implementation code, related documentation and provider information were not examined.

The findings describe documented behavior. No code was executed, and runtime compatibility, safety effectiveness, performance and example outputs were not independently verified.

Access & freshness

costs

Each judgment adds a model request before the selected tool executes. Its request and token usage count toward the outer agent run's totals and limits. Concurrent judgments share request accounting; when the budget cannot fit a judgment, on_uncertain determines what happens.

Unmatched calls incur no judging cost. Multiple judges can add requests until one blocks. Durable replay reuses the recorded judgment without another judging charge, according to the page. Provider prices, total deployment cost and measured latency are unknown.

rights

The supplied page contains no license text or explicit redistribution grant for its documentation or implementation. A link to source code does not establish those permissions. Licensing, commercial-use terms and redistribution rights remain unknown from this evidence.

The page also does not establish the judging provider's data-retention, reuse or regional-processing terms.

freshness

The supplied page was captured on 25 November 2026 at 19:51:35 UTC. The evidence does not establish its publication date, an exact package release or the implementation revision corresponding to the documentation.

The page warns that Pydantic AI Harness APIs may change between minor releases while on 0.x, with deprecation warnings and release-note migration guidance. Current model availability and subsequent changes are unknown.

actions

Before adoption, identify the function tools worth judging, write a risk question answerable from their inputs and choose how uncertainty should affect execution. Confirm that the judging provider may receive every selected tool's arguments, and add conversation only where needed.

Use non-destructive examples to evaluate allowed, blocked, uncertain, provider-failure and usage-limit cases. If using approval, check the documented behavior after a person approves an uncertain call. For durable workflows, check replay and callback deduplication. These are recommended evaluations; none were performed.

Keep enforceable permissions and validation within or below the tools, and confirm package compatibility, provider costs and licensing before deployment.

Evidence for this report

selected-page.txtselected · checked 2026-11-25