Apply `FunctionToolset(requires_approval=True)` to `Tool` instances passed to the toolset
This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.
FunctionToolset(requires_approval=True) applied requires_approval to tools added as functions, but not to Tool instances passed to the constructor or to add_tool(), although its docstring says it applies to all tools. Those tools ran without a deferred approval request. add_tool() now applies the toolset's requires_approval=True to the tool, as it already applies max_retries and metadata.
[!WARNING]
Compatibility impact: Existing code that gives Tool instances to a FunctionToolset(requires_approval=True) and relies on them running without approval now gets an approval request in DeferredToolRequests for each call. This includes a Tool built with requires_approval=False, and the same Tool instance used in another toolset: the value is set on the instance, as add_tool() already does for max_retries and metadata.
Why this can ship in a minor release: It's a bug fix. The requires_approval docstring says it applies to all tools in the toolset; skipping Tool instances was undocumented behavior.
Migration: Handle the approval request as described in Human-in-the-Loop Tool Approval, or remove requires_approval from the toolset and set it on each tool that needs it.
New public surface
None.
User-visible behavior
toolset = FunctionToolset([Tool(my_tool)], requires_approval=True)
agent = Agent(model, toolsets=[toolset], output_type=[str, DeferredToolRequests])
result = agent.run_sync('Run the tool')
# before: my_tool runs, result.output is the model's text
# after: my_tool doesn't run, result.output == DeferredToolRequests(approvals=[ToolCallPart('my_tool', ...)])
A function added with add_function(..., requires_approval=False) or @toolset.tool(requires_approval=False) still opts out, and still goes through add_tool(), so a subclass that overrides add_tool() sees every tool.
Verification
test_toolset_requires_approval_applies_to_tool_instancesfails onmainand passes here, for both the constructor andadd_tool().test_function_requires_approval_false_overrides_the_toolset_defaultpins therequires_approval=Falseopt-out and thatadd_functionand the decorators go throughadd_tool().
What changes for existing users
Tool instances in a FunctionToolset(requires_approval=True) now need approval, like the toolset's functions already did.
PR decisions
2026-11-03 · add_function() keeps going through add_tool()
- Decision:
add_tool()setsrequires_approval=Truewhen the toolset's isTrue.add_function()and the decorators still callself.add_tool(), then write back their resolvedrequires_approval, so an explicitFalseholds. - Why: routing
add_function()through a private method instead would hide its tools from a subclass that overridesadd_tool(); wideningTool.requires_approvaltobool | Nonewould change a public attribute type. - Session: 4152248f-72b2-47ea-acf7-2c8034a2fd1f
2026-11-03 · Tool.requires_approval stays bool
- Decision: a
Toolbuilt withrequires_approval=Falseand given to arequires_approval=Truetoolset now requires approval. - Why: a
boolattribute can't tell the default from an explicitFalse; per-tool opt-out stays withadd_function()and the decorators. - Session: 4152248f-72b2-47ea-acf7-2c8034a2fd1f
2026-11-03 · Set the value on the passed Tool
- Decision:
add_tool()writesrequires_approvalonto theToolit's given, as it already does formax_retriesandmetadata. - Why: keeps the
Toolthatadd_function()returns identical to the one intoolset.tools. - Session: 4152248f-72b2-47ea-acf7-2c8034a2fd1f
2026-11-03 · Keep resolving requires_approval in add_tool(), not at listing time
- Decision: keep writing the value onto the
Tool, instead of resolving it inget_tools()from a set of opted-out names. - Why: the ACP adapter reads
Tool.requires_approvalfromtoolset.tools, so listing-time resolution would leave it reporting these tools as not needing approval. - Source: https://github.com/pydantic/pydantic-ai/pull/12378#discussion_r4460768226
- Session: 4152248f-72b2-47ea-acf7-2c8034a2fd1f
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.