Learning resourcesReviewed · Pydantic

Pydantic AI: Handle Deferred Tool Calls

This Pydantic AI guide teaches Python developers to handle tool calls waiting for approval or external execution, but they must supply the decision logic. HandleDeferredToolCalls invokes a handler during the agent run so resolved calls can proceed automatically.

Researched 13 Nov 2026

In short.

This Pydantic AI guide helps Python developers keep agent runs moving through pending tool approvals or external execution, but its example approves every call waiting for approval without individual review and does not show external execution. It explains the HandleDeferredToolCalls callback contract, synchronous and asynchronous handlers, partial results and fallback behavior. Installation, complete deferred-tool definitions, costs and runtime reliability are not established.

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

Coverage includes the complete captured page at [https://pydantic.dev/docs/ai/capabilities/handle-deferred-tool-calls/index.md], including its documentation-index and query-parameter notices. Those notices provide no additional evidence of feature behavior. The linked documentation index, API pages, capability overview and deferred-tools guide are excluded. No code was executed; runtime behavior, compatibility, performance, costs and provider availability remain unverified.

The overview

identity

Handle Deferred Tool Calls is a Pydantic AI documentation guide about the HandleDeferredToolCalls capability. The capability resolves deferred tool requests inline during an agent run. The original page is [https://pydantic.dev/docs/ai/capabilities/handle-deferred-tool-calls/index.md].

assessment

The guide provides a useful integration pattern when approval or external execution can be handled during an agent run. Its strongest detail is the handler contract and fallback behavior. The short example does not implement individual approval decisions or execute an external tool, so adapting it requires additional application logic.

users

The guide suits Python developers working with Pydantic AI agents whose tools require permission or execution elsewhere. Beginners receive a small integration example but no installation walkthrough or tool-definition tutorial. Experienced developers can use the documented return types and capability chaining to assess integration fit.

capabilities

HandleDeferredToolCalls intercepts deferred requests, invokes a synchronous or asynchronous handler and continues the run when requests are resolved. A handler can inspect requests.approvals and requests.calls, obtain an operator decision, apply an application policy or perform external execution. It can return results for some or all pending calls, or return None to decline handling.

Using it

requirements

Applying the pattern requires a Pydantic AI agent, tools that defer for approval or external execution, and a handler accepting RunContext and DeferredToolRequests. The handler returns DeferredToolResults or None. Required Python and Pydantic AI versions, installation steps and model-provider configuration are unspecified.

mechanism

Normally, deferred calls pause the agent and surface as DeferredToolRequests output. This capability intercepts them and asks the supplied handler to resolve them during the run. If the handler returns None, the next HandleDeferredToolCalls capability gets a chance. Unhandled requests still surface through the normal DeferredToolRequests output path.

setup

The example imports Agent and RunContext from pydantic_ai, HandleDeferredToolCalls from pydantic_ai.capabilities, and the request and result types from pydantic_ai.tools. It defines a handler and registers HandleDeferredToolCalls(handle_deferred) in the Agent constructor's capabilities list. The page does not show a complete runnable application.

example

The asynchronous handle_deferred example returns requests.build_results(approve_all=True). This approves every call waiting for approval; it does not demonstrate external execution or per-call review. The accompanying explanation suggests inspecting approvals and calls to decide what to do for each request. The example was not executed.

Assessment & evidence

limitations

The page does not demonstrate deferred-tool definitions, individual approval logic, external-result construction, exception handling or timeouts. Returning results for only some calls is documented without a worked example. Compatibility, performance and integration reliability have not been assessed through execution.

reasoning

The documented design separates resolving a pending request from continuing the agent run. This suggests a useful fit when an application can obtain decisions or external results inside its handler. Automatic continuation does not require approving everything: the handler can inspect requests, involve an operator or decline handling.

alternatives

The page describes the normal alternative of allowing the agent to pause and return DeferredToolRequests for handling outside the run. It also supports passing responsibility to another HandleDeferredToolCalls capability by returning None. Other frameworks and their deferred-tool mechanisms are not assessed.

evidence

The evidence consists of the complete captured documentation page, including its Python example and explanatory text. Linked API references and the broader deferred-tools guide were not included, and no code was executed.

Access & freshness

costs

The page provides no prices or usage rates, so operating cost is unknown. Model usage, external execution and operator time could contribute costs, but the evidence supplies no quantities or estimates.

rights

The captured page contains no explicit licence or reuse terms for its documentation or Python example. Permission to redistribute either is unknown from this evidence.

freshness

The page was captured on 13 November 2026 at 17:40:53.654 UTC. It supplies no publication date, last-update date or Pydantic AI release number. Compatibility with a particular package release and changes after capture are unknown.

actions

Before adopting the pattern, confirm the API contract in the Pydantic AI version you use and define which requests your handler should approve, execute or leave unresolved. Replace approve_all=True when calls require individual review. Validate partial results, None fallback and external-execution behavior in your application; the page does not establish those integration outcomes.

Evidence for this report

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