From c0ca312c85d2f1f15c46bd0f837759f3c525abdc Mon Sep 17 00:00:00 2001 From: "sergi.fuster" Date: Wed, 3 Dec 2025 17:02:44 +0100 Subject: [PATCH 1/3] fix: Tool.from_schema requires_approval argument --- pydantic_ai_slim/pydantic_ai/tools.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pydantic_ai_slim/pydantic_ai/tools.py b/pydantic_ai_slim/pydantic_ai/tools.py index e54b829bfb..d95a75ac57 100644 --- a/pydantic_ai_slim/pydantic_ai/tools.py +++ b/pydantic_ai_slim/pydantic_ai/tools.py @@ -372,6 +372,7 @@ def from_schema( json_schema: JsonSchemaValue, takes_ctx: bool = False, sequential: bool = False, + requires_approval: bool = False, ) -> Self: """Creates a Pydantic tool from a function and a JSON schema. @@ -406,6 +407,7 @@ def from_schema( description=description, function_schema=function_schema, sequential=sequential, + requires_approval=requires_approval, ) @property From c07c0665fb4485ab45ffb791c9a34c0cb0192d33 Mon Sep 17 00:00:00 2001 From: "sergi.fuster" Date: Wed, 3 Dec 2025 17:41:39 +0100 Subject: [PATCH 2/3] fix: linting errors fixed to pass ci required workflows --- pydantic_ai_slim/pydantic_ai/tools.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pydantic_ai_slim/pydantic_ai/tools.py b/pydantic_ai_slim/pydantic_ai/tools.py index d95a75ac57..a6aa1f04d3 100644 --- a/pydantic_ai_slim/pydantic_ai/tools.py +++ b/pydantic_ai_slim/pydantic_ai/tools.py @@ -143,11 +143,11 @@ class DeferredToolRequests: See [deferred tools docs](../deferred-tools.md#deferred-tools) for more information. """ - calls: list[ToolCallPart] = field(default_factory=list) + calls: list[ToolCallPart] = field(default_factory=lambda: list[ToolCallPart]()) """Tool calls that require external execution.""" - approvals: list[ToolCallPart] = field(default_factory=list) + approvals: list[ToolCallPart] = field(default_factory=lambda: list[ToolCallPart]()) """Tool calls that require human-in-the-loop approval.""" - metadata: dict[str, dict[str, Any]] = field(default_factory=dict) + metadata: dict[str, dict[str, Any]] = field(default_factory=lambda: dict[str, dict[str, Any]]()) """Metadata for deferred tool calls, keyed by `tool_call_id`.""" @@ -209,9 +209,9 @@ class DeferredToolResults: See [deferred tools docs](../deferred-tools.md#deferred-tools) for more information. """ - calls: dict[str, DeferredToolCallResult | Any] = field(default_factory=dict) + calls: dict[str, DeferredToolCallResult | Any] = field(default_factory=lambda: dict[str, DeferredToolCallResult | Any]()) """Map of tool call IDs to results for tool calls that required external execution.""" - approvals: dict[str, bool | DeferredToolApprovalResult] = field(default_factory=dict) + approvals: dict[str, bool | DeferredToolApprovalResult] = field(default_factory=lambda: dict[str, bool | DeferredToolApprovalResult]()) """Map of tool call IDs to results for tool calls that required human-in-the-loop approval.""" From 273a5dc12f24884962c7627dc98019e48f8b3d25 Mon Sep 17 00:00:00 2001 From: "sergi.fuster" Date: Wed, 3 Dec 2025 17:43:04 +0100 Subject: [PATCH 3/3] docs: Tool.from_schema docstring updated with new required_approval argument --- pydantic_ai_slim/pydantic_ai/tools.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pydantic_ai_slim/pydantic_ai/tools.py b/pydantic_ai_slim/pydantic_ai/tools.py index a6aa1f04d3..6e8408a8c5 100644 --- a/pydantic_ai_slim/pydantic_ai/tools.py +++ b/pydantic_ai_slim/pydantic_ai/tools.py @@ -387,6 +387,7 @@ def from_schema( takes_ctx: An optional boolean parameter indicating whether the function accepts the context object as an argument. sequential: Whether the function requires a sequential/serial execution environment. Defaults to False. + requires_approval: Whether this tool requires human-in-the-loop approval. Defaults to False. Returns: A Pydantic tool that calls the function