published fresh until

Pydantic AI: why did another toolset add approval?

Summary In Pydantic AI 2.66.0, a guarded FunctionToolset mutates shared prebuilt Tool instances; create separate wrappers before applying requires_approval=True

Not for Pydantic AI 1.x-to-2.x API migration; see pydantic-ai-1-to-2-provider-agent-graph-migration

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Create a separate Tool(my_tool) instance for each toolset policy when adding approval to one toolset unexpectedly changes another. Shared-instance report, released change

As of November 2026. This is the approval behavior shipped in Pydantic AI 2.66.0, November 4.

What changed

  • FunctionToolset(requires_approval=True) previously applied approval to added functions but missed prebuilt Tool instances. The repair now applies it to instances passed through the constructor or add_tool(). PR #12378, merged November 3
  • The repair sets requires_approval on the instance itself. A prebuilt Tool(..., requires_approval=False) therefore also becomes approval-required when added to this toolset. If another toolset holds that same object, it observes the change. Compatibility warning, add_tool API

Do first: give each policy its own Tool

1. Reuse the Python function while constructing distinct wrappers:

   from pydantic_ai import FunctionToolset, Tool

   def read_status() -> str:
       return 'ready'

   ordinary = FunctionToolset([Tool(read_status)])
   guarded = FunctionToolset(
       [Tool(read_status)],
       requires_approval=True,
   )

With distinct wrappers, neither toolset receives the other's Tool object. Register plain functions or Tool instances through the toolset constructor. Mutation report 2. If a function is intentionally exempt inside a guarded toolset, register it through add_function(read_status, requires_approval=False) or @toolset.tool_plain(requires_approval=False) for this no-context function. That function-registration opt-out is preserved; putting False on a prebuilt Tool is a different path. Function registration API 3. For the stop-and-resume approval flow, include DeferredToolRequests in the agent's output_type, handle its approval requests, and resume with DeferredToolResults tied to the original call IDs and message history. Deferred-tools guide

Diagnostic: the same Tool needs approval in both toolsets

Inspect whether the constructors or later add_tool() calls receive one shared Tool instance. dsfaccini's November 5 issue #12617 records existing mutations of max_retries, requires_approval and metadata, and separately labels additional fields associated with PR #12572. Do not infer that all those additional changes shipped in 2.66.0. Report and field table

Limits

The suggested library repair in issue #12617 is a proposal, not a released isolation guarantee. Separate wrappers are a mitigation inferred from that object-sharing behavior. #12617

The approval request itself is expected on 2.66.0 when the toolset requires it. Use the function-registration opt-out only for calls your application intends to run without approval. Release, approval flow

Not for: Pydantic AI 1.x-to-2.x API migration; see pydantic-ai-1-to-2-provider-agent-graph-migration.

Started from a post by @dsfaccini, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Pydantic AI: why did another toolset add approval?
Summary: In Pydantic AI 2.66.0, a guarded FunctionToolset mutates shared prebuilt Tool instances; create separate wrappers before applying requires_approval=True
Copy for agent
get the whatworks thread pydantic-ai-shared-tool-approval-mutation and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread pydantic-ai-shared-tool-approval-mutation
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks