Skip to content

Upgrade Guide

In September 2025, Pydantic AI reached V1 and committed to API stability: no changes that break your code until V2. V2 is now available, collecting the breaking and behavior changes that stability guarantee didn’t allow. This guide is the canonical place to learn what’s in V2, how to install it, and how to upgrade; for the guarantees behind these version numbers, see the Version Policy.

Deprecations

Functionality deprecated in a V2 release keeps working until V3, and using it raises a PydanticAIDeprecationWarning naming its replacement. Resolving these as they appear is the smooth path to the next major, the same way resolving V1’s warnings was the smooth path to this one.

Deprecated in V2, to be removed in V3

  • Calling a RunUsage, as in V1’s result.usage(), returns that same usage and warns. usage became a property in V2, and the call used to raise TypeError: 'RunUsage' object is not callable, which code that wraps usage accounting in except Exception turned into silently zero usage. Drop the parentheses: result.usage.
  • RetryPromptPart is deprecated in favor of the two parts it conflated: a retry that answers a tool call is that call’s own ToolReturnPart with outcome='retried', and one that answers no tool call is a RetryFeedbackPart. The old part reached the model as bare user text in the second case, which the model couldn’t tell from something a person wrote (#6404, #7799). Pydantic AI no longer emits it, and constructing one warns.
    • What keeps working: a 'retry-prompt' part in a serialized history loads as whichever of the two it always meant, and an instance your own code holds, including one handed back through DeferredToolResults, is translated the same way before it reaches a model. The direct helpers send it in that new shape too. Calling Model.request() or Model.count_tokens() yourself skips that translation but still works: a tool-bound one goes out as that call’s retried result, and a tool-less one as the user text it always rendered as. sanitize_messages keeps client-returned retry feedback: it translates a tool-less one into the RetryFeedbackPart it always meant, keeps a 'validation_error' or 'model_retry' part as sent (it reaches the model fenced, in the user voice), and demotes a 'no_output' part, the one cause rendered in the system voice, to that same fenced, attributed user text, since a client can forge it; pass strip_system_prompts=False to keep a 'no_output' part as sent.
    • What you need to change: isinstance(part, RetryPromptPart) no longer matches, in new runs or in loaded histories, so code that finds tool errors that way silently finds none (v2.60.0). Use is_retry(part) instead, which matches both parts above (on a release that predates it, check isinstance(part, RetryFeedbackPart) or (isinstance(part, ToolReturnPart) and part.outcome == 'retried')), as in Finding tool errors in history. Each records why the retry happened, and which attempt it is against which limit, in a RetryInfo on its retry field, which tool spans also carry as pydantic_ai.tool.retry.* attributes. ToolRetryError.tool_retry holds one of those two parts, so read tool_name off it only after checking for a ToolReturnPart.
    • What the model now sees: a tool retry carries the serialized validation errors or the ModelRetry message, with no N validation errors: header and no Fix the errors and try again. suffix. One that answers no call arrives in the voice its cause calls for: validation errors and a ModelRetry message in the user voice, inside a <pyai:validation_errors> or <pyai:retry_feedback> fence behind one line saying the application, not the user, is speaking, and the framework’s fixed request for usable output in the system voice. v2.68.0 renamed those fences from <validation_errors> and <retry_feedback> (#11813), so code that matches them in stored or logged prompts has to match the new names, and made such feedback count as something the framing announcement explains: by default, a conversation that didn’t have the announcement yet gets it from its first fenced retry on, as a system message on models with a mid-conversation system role and at the start of the system prompt, when there is one, on the rest. On providers without a native tool error channel, a retried tool call’s validation errors go in the {"error": ...} wrapper as a JSON array rather than as a string holding one, and Anthropic and Bedrock get them as one text block. Client-returned retry feedback is kept by sanitize_messages and the UI adapters rather than stripped, and a 'no_output' part among it goes out as fenced user text rather than in the system voice. Retries in a history stored before upgrading are rendered the new way too, since rendering happens when each request goes out, so a conversation’s first request after upgrading misses the provider’s prompt cache from its first retry onward, once. A decision model judges a retried tool call as that call’s tool_return, where it had a retry entry. On ag-ui-protocol below 0.1.11, AGUIAdapter.dump_messages now also warns on a run that retried its own output. See Retries.
    • Vercel AI dumps keep a request’s part order: VercelAIAdapter.dump_messages now writes a ModelRequest as one UIMessage per run of same-role parts, in the order they were authored, instead of putting every system part first. This applies with no retries at all: a request holding an enqueued SystemPromptPart after its UserPromptPart now dumps as a user message followed by a system message, and positional message ids shift with it. The request’s metadata rides on its last user message, or its last message when it has none.
  • Reading pydantic_ai.models.anthropic.DEPRECATED_ANTHROPIC_MODELS returns the same model ids and warns. Pydantic AI no longer uses it: AnthropicModelName is a curated list, and the Anthropic SDK no longer lists the retired ids it excluded. Keep your own list of retired model ids, from Anthropic’s model deprecations page.

Catching up across V2 minor releases

If you’re upgrading across several V2 minor releases at once, these are the changes since v2.0.0 that can make existing code behave differently. Each one is listed under the release that shipped it, newest first, with a link to its pull request. They come from the “Compatibility Notes” section of each release’s notes on GitHub Releases, which also lists the bug fixes and features of each release.

Release notes have had a Compatibility Notes section since v2.33.0, so for v2.1.0 through v2.32.2, read each release’s notes on GitHub Releases. Later releases not listed below have no compatibility notes.

  • Keep workspace files below 'operator' authority out of the instructions in RepoContext, Skills and Memory, and add lowest_authority_under. Text from a workspace file below 'operator' authority no longer reaches the instructions: RepoContext names the working directory’s file for the model to read with its file tools and sends an ancestor’s file as framed data, Skills offers such skills through list_skills and load_skill tools instead of load_capability, and Memory attributes such a snapshot to its MEMORY.md. Files at 'operator', the default, are unchanged. Durable runs now record extra realpath workspace calls at run start, so let in-flight runs finish, or use Temporal worker versioning or a new DBOS app version, before upgrading. RepoContext(autoload_instructions=False) with nested instruction files misses the prompt cache once on the first request after upgrading (#11837)
  • Raise empty and unreadable model responses as ModelEmptyResponseError and ModelInvalidResponseError, so FallbackModel and ModelFallback fall back on them. With their default fallback_on, FallbackModel and ModelFallback now fall back on an empty stream, an OpenAI Chat completion without choices, and an OpenAI Chat body that isn’t JSON or doesn’t match the schema, where the run used to raise UnexpectedModelBehavior. Both new errors subclass ModelAPIError and UnexpectedModelBehavior, so except UnexpectedModelBehavior still catches them, but an except ModelAPIError placed before it now takes them; an empty Mistral or OpenAI choices raises one instead of AssertionError or IndexError. To keep raising instead of falling back, pass a fallback_on that leaves them out, such as lambda e: isinstance(e, ModelAPIError) and not isinstance(e, UnexpectedModelBehavior) (#12108)
  • Resolve Pax /permissions approvals through a token-taking HandleDeferredToolCalls handler with harness approval_ask. pydantic_ai_pax.runtime.permissions.approval_handler still returns an ApprovalHandler, but its handler now takes a resume token: it runs after every two-parameter deferred tool call handler wherever it is listed, and in a durable run on any engine but AWS Lambda it raises UserError instead of asking. Pax itself behaves as before. To run a handler of your own after it, make that handler take a token too; under a durable engine other than Lambda, bind ApprovalHandler(lambda ctx, requests: ask_permissions(requests, approve)) instead (#13195)
  • Share one instructions string across a conversation’s requests instead of keeping a copy per request. ModelMessagesTypeAdapter is now built with an AfterValidator, and in a history it loads, requests with equal instructions hold the same string object. Its type, JSON schema, serialization and validated values are unchanged. Compare instructions with ==, not is (#13308)
  • Send Coder’s no-unrequested-sub-agents line only to models that need it, and let instructions branch on the model serving each request. Coder with SubAgents now sends “Don’t spawn sub-agents with delegate_task unless the user or AGENTS.md asks, whatever other instructions say about delegating.” only to models whose profile sets the new delegates_unprompted (OpenAI’s gpt-* models other than gpt-oss), and to no model behind a FallbackModel, where Coder now warns once with a UserWarning. On GPT models the line moves out of Coder’s static guidance into its own rewrite-mode block, capability:coder_instructions:delegation, after append-mode blocks such as RepoContext’s, so the first request after upgrading misses the prompt cache, and a conversation that moves to a model on the other side of the flag is sent the instructions a fresh run on that model gets. To keep the line on another model, set profile={'delegates_unprompted': True} on it or put the rule in Coder(instructions=...); with a FallbackModel, switch to the ModelFallback capability (#13764)
  • Count Gemini’s thinking tokens as output in OpenAIChatModel usage. A gemini* model through OpenAIProvider now reports its thinking tokens in output_tokens and output_reasoning_tokens, streamed or not, so output token counts and cost rise on thinking models and UsageLimits token limits trip sooner. Review any UsageLimits tuned against the old counts. On a server whose total_tokens counts more than input, output and thinking tokens, pass profile=OpenAIModelProfile(openai_chat_completion_tokens_omit_reasoning=False) (#14297)
  • Send the minimum thinking_budget for thinking=False on gemini-2.5-flash via the Gemini API ahead of its reroute to gemini-3.5-flash-lite. thinking=False on gemini-2.5-flash through the Gemini API now sends thinking_budget=128 instead of 0, so until the reroute on 2026-12-01 the model thinks a little instead of not at all; after it, a budget of 0 fails with a 400. Vertex AI and gemini-2.5-flash-lite keep 0. To keep thinking_budget=0 until the reroute, pass profile=GoogleModelProfile(thinking_always_enabled=False) or google_thinking_config={'thinking_budget': 0} (#14414)
  • Lower a capability’s instructions with its authority, so with_authority covers get_instructions() and MCP server instructions. A capability lowered with its authority class attribute or with_authority(), including an MCP capability and its server instructions, now sends its instructions as framed data on the user channel instead of in the system prompt. Capabilities at 'operator', the default, are unchanged; to keep the old behavior, leave the capability at 'operator'. Runs already lowering an MCP capability with with_authority that are in flight across the upgrade may hit a nondeterminism error on Temporal or DBOS if another MCP server follows it. Under Prefect, a flow retried across the upgrade re-runs a finished model request once (#14457)
  • Add the computer tool contract to core: pydantic_ai.computer_use and ComputerTool. Adds ComputerTool to NATIVE_TOOLS_REQUIRING_CONFIG: it needs a computer tool to run its calls (#11006)
  • Send static instructions as leading input messages on GPT-6.2, which never caches top-level instructions. Continuing a GPT-6.2 response through an explicit openai_previous_response_id='resp_…' without its message_history now inherits that response’s static instructions. Pass the message_history, or profile=OpenAIModelProfile(openai_responses_stable_instructions_as_input=False) (#14095)
  • Stop summing Gemini’s running usage totals when streaming through OpenAIChatModel. Streaming a gemini* model through OpenAIProvider now reports the endpoint’s final usage totals instead of their sum, so cost figures drop and UsageLimits token limits trip later (#14285)
  • Under an enforced egress policy (the default), PlaywrightBrowser pages no longer have RTCPeerConnection, WebTransport, WebSocketStream or FedCM, and browsers it launches start with those Blink features off. If your agent needs one of them, open an issue: a parameter that keeps them can be added (#14363)
  • Warn with DeprecatedModelWarning when a request targets a model Anthropic or OpenAI has deprecated (#14038)
  • Surface OpenAI Responses input_transformations in provider_details and on the model request span. Raises the openai floor from 3.31.0 to 3.50.0 on every extra that installs openai (#14056)
  • Add capabilities to Agent.override and export AgentInstructions and SourcedInstruction. The private Agent._override_root_capability context variable now holds a (capability, injected) tuple. Code that reads it directly needs updating (#12551)
  • Add RealtimeSession.append_voice_instructions for GPT-Live’s voice model, and a Twilio Media Streams bridge example (#14191)
  • Leave init=False evaluator fields out of Dataset files and schemas, and stop ClassVar annotations breaking to_file() (#13355)
  • Ship nested tool-argument models to Render and Azure Durable Task workers by alias, so aliased fields survive revalidation (#13929)
  • Rename $refs under every JSON schema keyword in merge_json_schema_defs, and keep TestModel arguments valid for their schemas (#13993)
  • Downscale images Coder reads to at most 1024 pixels on the longest side, with opt-in FileSystem(max_image_side=...). The coder extra now installs pillow>=12.3.0 (#14196)
  • Drop the unified settings Claude, Gemini and Grok models reject instead of sending them. A FallbackModel that relied on the 400 to reach a later model now stays on the first model without the setting. To keep the setting, list a model that supports it first (#12426)
  • Raise the boxd extra to 0.3 and swap the /sandbox boxd GitHub token into request headers only. pydantic-ai-harness[boxd] now requires boxd>=0.3.3,<0.4. Code that calls 0.2-only boxd APIs directly needs updating (#14225)
  • Note text that looks like an application frame in user and tool content instead of escaping it (#11813)
  • Add OutputTokenLimitExceeded, and fall back to the next model in ModelFallback when a response is cut off at max_tokens (#12407)
  • Ask for approvals and answers inside the run with RequestInput, put AskUser on the deferred pipeline, and mark deferred calls with kind and answered_by (#12757)
  • Add DelegationTasks.discover() and stop one damaged saved task from blocking DelegationTasks.opened() (#10140)
  • Require workspace backends to leave detached processes running, and check it in WorkspaceBackendSuite (#13070)
  • Run PromptInjectionDefender semantic classification as durable operations so it works on Temporal (#12424)
  • Give sub-agent task-control events the Event suffix and past-participle names, with agent_name and parent_task_id fields, keeping the old names as deprecated aliases (#13074)
  • Spell out abbreviated identifiers in pydantic_ai_harness, renaming num_results to max_results and max_duration_secs to max_duration_seconds (#13075)
  • Rename harness CapabilityEvent fields to *_count, *_name, duration_ms and previous_item, keeping the old names as deprecated aliases (#13068)
  • Rename harness CapabilityEvent outliers to <Subject><PastParticiple>Event and add STEP_PERSISTENCE_EVENTS (#13065)
  • Add the RefineOutput harness capability (#13120)
  • Protect the gh-aw canonical session capture from agent tools (#10606)
  • Add multimodal notes to AskUserAnswer (#11664)
  • Count BrowserUse model calls toward the host run’s usage and UsageLimits (#11860)
  • Name the V2 replacement when code imports a name V2 removed, like OpenAIModel or MCPServerStdio (#12035)
  • Fall back to the next model in ModelFallback when a model refuses, and let ContentFilterError in fallback_on match refusals (#12039)
  • Raise ModelQuotaExceededError instead of ModelRateLimitError for Z.ai balance and plan-limit 429s (#12042)
  • Support the '12h' prompt cache retention on the OpenAI Responses API for GPT-5.6 and later (#12046)
  • Send Google a server deadline of at least 20 minutes instead of the client’s read timeout, and warn about httpx’s 5 s default (#12057)
  • Stop Temporal from retrying model errors that can’t succeed on retry by default, via non_retryable_model_errors (#12107)
  • Default CodeMode to dynamic_catalog=True, so a revealed tool is appended instead of rewriting the cached prompt (#11358)
  • Pass the Gemini Live reconnect replay to GoogleRealtimeConnection’s dial as a keyword-only replay argument (#11515)
  • Give Harness LLMReminder a default interval=10 instead of generating on every request (#11641)
  • Replay signed and encrypted history data to providers with the same canonical_system (#11504)
  • Let a deferred CombinedCapability load as one capability, with members keeping their global ordering (#10321)
  • End a GPT-Live reply that delegated at Live’s next pause instead of mid-sentence when the backend answers (#11250)
  • Say what the <system> tag means and escape it in user and tool text on models without mid-conversation system messages (#11506)
  • Change thinking effort mid-conversation via OpenAI configuration_update and Anthropic per-message output_config, recorded as ModelSettingsDeltaPart (#11111)
  • Add ModelRequestRejectedError, ModelAuthenticationError and ModelNotFoundError model error categories (#11081)
  • State loaded deferred capabilities’ instructions in the system voice, append their changes, and show them to before_model_request (#11103)
  • Prefix hosted MCP capabilities’ tool names with the service by default, configurable with tool_prefix (#10376)
  • Store the SummarizingCompaction summary as a CompactionPart instead of a system prompt, and send provider-less CompactionParts to every model (#10573)
  • Deliver realtime SystemPromptParts on each provider’s operator channel with session.send() (#11379)
  • Preserve run identity when replaying Prefect capability operations (#11196)
  • Append changed MCP server instructions with on_change='append', and give an id-less URL MCPToolset its hostname as id (#10791)
  • Record Harness Memory snapshots in history once per changed run, so requests stay append-only (#10903)
  • Tell the realtime model a tool call failed on every provider, so it answers instead of going silent (#11086)
  • Reserve DBOS handler step positions during tool ctx.emit() (#11157)
  • Record GPT-Live speech as one SpeechPart instead of splitting it at each delegated tool call (#11187)
  • Deliver ctx.emit() events into the realtime session event stream (#11369)
  • Make realtime shared settings warn, raise or ignore like standard ModelSettings: forced tool_choice raises on Gemini Live, parallel_tool_calls=False warns (#11066)
  • Keep the prompt cache when changing thinking effort mid-conversation on OpenRouter, via its configuration_update system message (#11426)
  • Start GraphBuilder broadcast branches in .to() order instead of reversed, which can break replay of durable workflows paused across the upgrade (#11408)
  • Cache on_change='append' instruction blocks behind a second cache point after the static instructions (#11351)
  • Build Harness SystemReminders on request-scoped system prompts and deprecate cache_ttl (#9712)
  • Add CodeMode(monty_sandbox=...), which takes a remote Monty URL or a function that builds the pool, and deprecate monty_sandbox_url (#11141)
  • Warn when a provider-specific thinking setting from a broader scope overrides thinking (#10231)
  • Send the least thinking a model accepts for thinking=False on models that can’t turn thinking off (#11036)
  • Raise NotImplementedError for a file in a CohereModel tool return instead of dropping it (#11114)
  • Keep concurrent workspace runs attached to their own Prefect environments (#11160)
  • Keep bool and int inputs on separate Literal decision branches in pydantic_graph (#9091)
  • Deprecate google_multi_speaker on GoogleRealtimeModel, which no Gemini Live model supports (#11064)
  • Accept async auth functions in the hosted MCP capabilities (#10835)
  • Run the authoring checks in CapabilityStore.load_active and stop overwriting unreadable manifests (#10731)
  • Keep the last valid authored capability on a failed re-author, share the CapabilityStore lock per directory, and let runs cancel authoring (#10767)
  • Reject BrowserUse prohibited lists browser-use would match by exact hostname, and retry when redacted schema keys collide (#10775)
  • Share one LocalStack container inside async with agent:, stop service-list bypasses and aws configure writes to ~/.aws, and cap aws_cli output (#10828)
  • Make InputGuardrail redact the user’s own prompt and close fail-open paths in guardrails (#10841)
  • Keep CodeMode(dynamic_catalog=True) discoveries from rewriting the cached prompt (#10906)
  • Count a resumed 'suspended' response’s usage only in the run that produced it, in RunUsage, UsageLimits and SpendLimits (#10078)
  • Make RealtimeConnection yield lifecycle events through a public pydantic_ai.realtime.lifecycle module (#10353)
  • Let read_file return images and PDFs, and describe other binary files (#9596)
  • Record a realtime reply the user cut off after it finished generating as interrupted, and mark interrupted speech when seeding (#10466)
  • Treat a native tool as unsupported when the model can’t apply its allowed_domains, blocked_domains, max_uses or external_web_access setting (#10451)
  • Add request-scoped SystemPromptPart(scope='request') sent natively as Anthropic clear_at system messages (#9711)
  • Send Harness WarnNearLimits warnings as request-scoped system prompts (#10561)
  • Escape RepoContext <context-file> blocks and send the nested-directory pointer as a SystemPromptPart (#10558)
  • Make the profile’s supports_auto_cache decide anthropic_cache, and use automatic caching on legacy AsyncAnthropicBedrock for Claude Opus 4.7 and later (#10551)
  • Let any module define a ToolKind with typed tool parts, and keep unknown kinds loadable (#9710)
  • Emit Planning status-tool events after their store reads, so DBOS recovery with an event_stream_handler replays in order. Existing DBOS workflows using Planning with an event_stream_handler may not recover after upgrading; let in-flight workflows finish first or deploy a new DBOS application version (#10343)
  • Align RealtimeTurnCompleteEvent with the exchange boundary that wait_for_reply() waits for. To react when a particular response ends, use its PartEndEvents. Caption UIs should keep user parts open until their PartEndEvent, which can arrive after the reply completes (#10517)
  • Attach namespaced origin and tool_call_id metadata to BackgroundTools completions (#10196)
  • Take GPT-Live realtime history, usage, and reply waits from the session core (#10083)
  • Honour disable-model-invocation and user-invocable in Skills, and skip stray skill library paths (#10378)
  • Take Gemini Live realtime history, usage, and reply waits from the session core (#10082)
  • Run BrowserUse on the host model by default and make browser-use telemetry opt-in (#9506)
  • Require Python 3.11 or newer in every package; Python 3.10 installs resolve to 2.54.0 and earlier (#9526)
  • Record the tool requests of ExaSearch, YouSearch, LocalStack and other harness capabilities under durable execution (#9705)
  • Bound retained realtime audio like retained images with retain_audio_max_seconds (#9702)
  • Prefix LogfireMCP tool names with logfire_ (#9868)
  • Serialize FileUrl.media_type as null for extensionless URLs instead of raising (#8405)
  • Take realtime history, usage, and reply waits from the session core on OpenAI, Azure OpenAI, and xAI (#9612)
  • Keep default run_id and conversation_id stable when a durable run is re-executed (#9701)
  • Record each failed FallbackModel attempt with its model, timing, error and usage, and count rejected responses in RunUsage (#8745)
  • Handle draft-7 list-form items in JsonSchemaTransformer, TestModel and Mistral streamed output, and make TestModel accept boolean subschemas and cap prefixItems at maxItems (#9560)
  • Fix ImageGeneration under FallbackModel and dataclasses.replace, and compare Embedder by identity (#9477)
  • Refuse a second durable execution engine on an agent before either binds (#9391)
  • Make wrap_* hooks enclose complete stage lifecycles (#7053)
  • Re-raise model errors from Temporal model activities with their original type in workflow code (#9580)
  • End the run when a BackgroundTools tool raises an unexpected exception, as a sequential tool does (#9434)
  • Drop the SubAgents agent_folders default-change warning: since v2.52.0 (#9023) the agents folder is not loaded by default, so pass agent_folders='agents' to keep loading it (#9424)
  • Add oneOf schema support to TestModel’s generated data (#8783)
  • Deprecate pydantic_ai_harness.step_persistence.naming (#9499)
  • Name a None output route None rather than NoneType (#8590)
  • Raise when UserPromptPart.content is not a str or a sequence, instead of silently sending a dict’s keys (#8595)
  • Make RunContext.enqueue() safe from worker threads (#7758)
  • Require a JSON Content-Type on UI adapter requests (#8396)
  • Dispatch a capability @durable_operation called from a per-request hook, instead of silently running it inline (#8395)
  • Give one-off capabilities a default id and a combine rule for repeats (#7248)
  • Add --mcp-config support and tool-call streaming to clai (#1374)
  • Use httpx2 for Anthropic clients, requiring anthropic>=1.0.0. An http_client you pass to AnthropicProvider must now be an httpx2.AsyncClient (#7657)

Breaking Changes

Here’s a filtered list of the breaking changes for each version to help you upgrade Pydantic AI.

v2.62.0 (2026-10-26)

  • See #11111 - A model request whose thinking effort level differs from the one in effect, like a run’s first request with thinking='low', emits a ModelSettingsDeltaEvent, which a durability event_stream_handler= receives in an event-handler activity or step of its own. This can break replay of durable workflows paused across the upgrade: see Temporal and DBOS for who is affected and how to upgrade.

v2.60.0 (2026-10-22)

Nothing was removed, but code that reads message history behaves differently, and some durable workflows record a different sequence of activities or steps:

  • See #8094 - Pydantic AI no longer records a RetryPromptPart. A tool retry is that call’s ToolReturnPart with outcome='retried', and a retry that answers no tool call is a RetryFeedbackPart. A stored 'retry-prompt' part loads as one of those too, so isinstance(part, RetryPromptPart) matches nothing, and code that counts tool errors that way reports none without an error or warning. Replace that check with is_retry(part), which matches both new parts, or on a release that predates it, with isinstance(part, RetryFeedbackPart) or (isinstance(part, ToolReturnPart) and part.outcome == 'retried'); Finding tool errors in history shows it in use, and how to also find tool calls that failed. The retry text sent to the model changed too, and changed again in v2.68.0: see “What the model now sees” in the deprecation entry, which lists the other changes.
  • See #9405 - A tool that joins the agent’s tools mid-run emits a ToolAvailabilityDeltaEvent, which a durability event_stream_handler= receives in an event-handler activity or step of its own. This can break replay of durable workflows paused across the upgrade: see Temporal and DBOS for who is affected and how to upgrade.

v2.0.0 (2026-06-23)

The stable V2.0 release. There are no new breaking or behavior changes since the betas; the full breaking-change list and recommended upgrade path are in the v2.0.0b1 entry below. Install it with:

Terminal
uv add pydantic-ai

v2.0.0b7 (2026-06-10)

The seventh V2 beta, forked from v1.107.0. There are no new V2 breaking or behavior changes since v2.0.0b6 below — everything in that entry applies unchanged — but this beta picks up the latest V1 release on top, which adds Claude Fable 5 / Mythos 5 model support and OpenRouter prompt caching (CachePoint), plus known_model_names() and Anthropic fixes; see the v1.107.0 release notes for the full list.

Install it the same way, pinning the exact pre-release version:

Terminal
pip install "pydantic-ai==2.0.0b7"

For the full breaking-change list and the recommended upgrade path, see the v2.0.0b1 entry below; the only difference is that the latest V1 to upgrade through first is now v1.107.0.

v2.0.0b6 (2026-06-04)

The sixth V2 beta, forked from v1.106.0. There are no new V2 breaking or behavior changes since v2.0.0b5 below — everything in that entry applies unchanged — but this beta picks up the latest V1 release on top, which adds api_host/timeout configuration and base seed mapping for the xAI provider, plus streaming and data-URI handling fixes; see the v1.106.0 release notes for the full list.

Install it the same way, pinning the exact pre-release version:

Terminal
pip install "pydantic-ai==2.0.0b6"

For the full breaking-change list and the recommended upgrade path, see the v2.0.0b1 entry below; the only difference is that the latest V1 to upgrade through first is now v1.106.0.

v2.0.0b5 (2026-06-02)

The fifth V2 beta, forked from v1.105.0. There are no new V2 breaking or behavior changes since v2.0.0b4 below — everything in that entry (including the prepare-callbacks change) still applies — but this beta picks up the latest V1 release on top, which adds on-demand (deferred-loading) capabilities and Grok 4.3 reasoning_effort support, plus GoogleModelSettings.google_cached_content and Temporal gateway/ fixes; see the v1.105.0 release notes for the full list.

Install it the same way, pinning the exact pre-release version:

Terminal
pip install "pydantic-ai==2.0.0b5"

For the full breaking-change list and the recommended upgrade path, see the v2.0.0b1 entry below; the only difference is that the latest V1 to upgrade through first is now v1.105.0.

v2.0.0b4 (2026-05-28)

The fourth V2 beta, forked from v1.104.0. One new V2 behavior change since v2.0.0b3:

  • Prepare callbacks (prepare_tools= / PrepareTools capability) that return None now raise TypeError instead of silently stripping all tools. V1.103.0 announces this change via PydanticAIDeprecationWarning (see #5188); V2 turns the warning into a hard error (see #5668). Return an empty list ([]) when you mean “no tools for this turn.”

This beta also picks up two V1 releases on top — v1.103.0 and v1.104.0 — together adding Claude Opus 4.8 support, McpServer.list_prompts / get_prompt, message-timestamp roundtripping through VercelAIAdapter’s UIMessage.metadata, OpenRouter eager input streaming, and several Bedrock and UI fixes. See those release notes for the full list.

Install it the same way, pinning the exact pre-release version:

Terminal
pip install "pydantic-ai==2.0.0b4"

For the full breaking-change list and the recommended upgrade path, see the v2.0.0b1 entry below; the only difference is that the latest V1 to upgrade through first is now v1.104.0.

v2.0.0b3 (2026-05-22)

The third V2 beta, forked from v1.102.0. There are no new V2 breaking changes since v2.0.0b1 below — everything in that entry applies unchanged — but this beta picks up the latest V1 release on top, which is a bug-fix release; see the v1.102.0 release notes for the full list.

Install it the same way, pinning the exact pre-release version:

Terminal
pip install "pydantic-ai==2.0.0b3"

For the full breaking-change list and the recommended upgrade path, see the v2.0.0b1 entry below; the only difference is that the latest V1 to upgrade through first is now v1.102.0.

v2.0.0b2 (2026-05-21)

The second V2 beta, forked from v1.101.0. There are no new V2 breaking changes since v2.0.0b1 below — everything in that entry applies unchanged — but this beta picks up the latest V1 release on top, which adds the pending message queue (ctx.enqueue / agent_run.enqueue).

Install it the same way, pinning the exact pre-release version:

Terminal
pip install "pydantic-ai==2.0.0b2"

For the full breaking-change list and the recommended upgrade path, see the v2.0.0b1 entry below; the only difference is that the latest V1 to upgrade through first is now v1.101.0.

v2.0.0b1 (2026-05-20)

The first V2 beta, forked from v1.100.0, which deprecates most of what V2 removes. V2 leans into a harness-first design with capabilities as a core primitive: a single, composable unit that bundles an agent’s tools, hooks, instructions, and model settings, reaching every layer of the agent through one concept. Many of V2’s changes move configuration that used to be spread across Agent arguments onto that primitive, alongside the behavior changes that V1’s stability guarantee didn’t allow. Pydantic AI stays a small core: some capabilities ship with it, more come from the first-party Pydantic AI Harness, and others are third-party or your own.

The breaking changes below are split into two groups:

  • Changes not covered by deprecation warnings — removals and behavior changes that couldn’t be announced via a V1 deprecation warning. Review these even if you’re already on the latest V1 with no warnings.
  • Changes covered by deprecation warnings — if you upgraded to the latest V1 and resolved every deprecation warning, you’ve already made these. They’re listed with full before → after for reference.

Recommended upgrade path. To make the jump as smooth as possible:

  1. Upgrade to the latest V1 release. Most of what V2 removes is deprecated as of v1.100.0 (the release this beta is forked from), so any V1 at or above that version surfaces those warnings.
  2. Resolve every deprecation warning. The changes covered by deprecation warnings were announced in V1 via warnings that name the new API and, where possible, include a migration snippet. Run your test suite (or app) with warnings visible and address each one — by hand or by pointing a coding agent at them — to migrate across the bulk of V2 ahead of time.
  3. Upgrade to V2 and make the changes not covered by deprecation warnings — primarily default-behavior changes and a handful of removals with no V1 deprecation.

You can also upgrade straight to V2 and work through the list below directly — it’s organized so a coding agent can apply the code changes mechanically. Resolving deprecation warnings on the latest V1 first is still the smoother path, since it spreads the work out and leaves you only the behavior changes to reason about consciously at the end.

Message history serialized with V1 (via ModelMessagesTypeAdapter) continues to deserialize in V2.

Changes not covered by deprecation warnings

These removals and behavior changes could not be announced via a V1 deprecation warning, so review them even if you’ve resolved every deprecation warning on the latest V1.

Code changes:

  • Generic type parameter defaults changed from None to object: an un-parameterized Agent(...) now infers Agent[object, str] instead of Agent[None, str], and the pydantic_graph StateT/RunEndT/DepsT defaults changed to match. Update explicit Agent[None, ...], RunContext[None], and Tool[None] annotations that don’t actually require None dependencies to use object. This is a type-checking-only change; runtime behavior is unchanged. See #5307.
  • The pydantic_graph.persistence package and the pydantic_graph.mermaid module are removed, with no V2 equivalent for standalone Mermaid generation (render diagrams with Graph.render()). The builder API deliberately does not snapshot graph state, so there is no pydantic_graph replacement for the persistence package; to save, resume, and fork agent run state, Pydantic AI Harness ships the StepPersistence capability. The move of the GraphBuilder API out of pydantic_graph.beta to the top-level pydantic_graph was deprecation-announced; see below. See #5470.
  • ModelProfile and its subclasses are now TypedDicts instead of dataclasses. Passing profile=OpenAIModelProfile(field=value) into a model still works unchanged; the migration only matters if you read or mutate profile fields, or call .update()/.from_profile(). See ModelProfile is now a TypedDict below. (#5481)

Default behavior changes — same API, different runtime behavior (roughly ordered by how many users they affect):

  • A bare uv add pydantic-ai / pip install pydantic-ai now installs a slimmer set of extras (frontier providers plus minimal integrations); providers like bedrock, groq, and mistral are no longer included by default, so you’ll need to add the extras you use. See Slimmer default extras below. (#5467)
  • The default end_strategy changed from 'early' to 'graceful': when a model calls function tools in the same response as a successful output tool, those function tools now run (and their side effects happen) instead of being skipped, and tool calls run in the order the model emitted them. See Parallel tool-call execution order below. (#5339)
  • The default instrumentation format is now version 5, and agent run spans report token usage under gen_ai.aggregated_usage.*. See Instrumentation defaults below. (#5523)
  • capture_run_messages() now also captures the partial ModelRequest/ModelResponse from an interrupted run, marked with state='interrupted' (a new ModelRequest.state field is added). Code that asserts on exact captured-message counts on error paths may need updating. See #5364.
  • Output tool calls and returns now emit dedicated OutputToolCallEvent/OutputToolResultEvent instead of FunctionToolCallEvent/FunctionToolResultEvent. Separately, native tool calls and returns no longer emit dedicated events at all — the BuiltinToolCallEvent/BuiltinToolResultEvent classes are removed and they surface only via the standard PartStartEvent/PartDeltaEvent. See #5332 and #5476.
ModelProfile is now a TypedDict

See the Model Profile guide for an overview of what a model profile is and how to configure one.

ModelProfile and all its subclasses (OpenAIModelProfile, AnthropicModelProfile, GoogleModelProfile, BedrockModelProfile, etc.) are now TypedDict(total=False) instead of @dataclass. This unifies the mental model with ModelSettings (also a TypedDict) and enables direct dict-spread for cross-class merging.

ModelProfile.update() and ModelProfile.from_profile() are removed; use the module-level merge_profile (later argument wins per key).

Migration recipes:

v1 (dataclass)v2 (TypedDict)
OpenAIModelProfile(field=value)Same syntax; returns a partial dict instead of a fully-defaulted instance.
profile.field (attribute read)profile.get('field', <default>) — non-trivial defaults are exported from pydantic_ai.profiles (e.g. DEFAULT_THINKING_TAGS, DEFAULT_PROMPTED_OUTPUT_TEMPLATE); the fully-merged base is DEFAULT_PROFILE.
profile.field = value (attribute write)profile['field'] = value
dataclasses.replace(profile, field=value){**profile, 'field': value} or merge_profile(profile, ModelProfile(field=value))
profile.update(other)merge_profile(profile, other)
OpenAIModelProfile.from_profile(p)Just p — no upcasting needed
Model(name, profile=full_profile) (full replace)Now merges on top of the provider’s default profile — usually what you want. For a hard replace use Model(name, profile=lambda _default: full_profile).
Model(name, profile=fn) where fn: Callable[[str], ModelProfile | None]Removed — the user-passed callable is now Callable[[ModelProfile], ModelProfile], receiving the resolved default and returning the final profile. The (model_name: str) -> ModelProfile | None shape is still accepted internally by Provider.model_profile.
isinstance(profile, OpenAIModelProfile)Not supported by TypedDict at runtime — raises TypeError. Use isinstance(profile, dict) or check key presence ('openai_chat_supports_web_search' in profile). Pyright still narrows correctly via the TypedDict subclass annotation.

Model.profile is now the single source of truth for the resolved profile. It is composed by merge_profile in this order (later wins):

  1. DEFAULT_PROFILE — base defaults for every documented key.
  2. Provider.model_profile(model_name) — provider/model-specific resolution.
  3. The user’s profile= argument — either a partial dict (merged on top) or a Callable[[ModelProfile], ModelProfile] (full control: receives the resolved default, returns the final profile).
Resolved profiles now carry cross-class fields

In v1, ModelProfile.update() silently filtered out fields not declared on the target class. In v2, dict-spread preserves every key.

This means e.g. a Bedrock-hosted Anthropic model’s resolved profile now carries the upstream anthropic_* fields alongside the bedrock_* fields, where v1 dropped them. No in-tree model class reads cross-class fields, so behavior is unchanged in the standard providers; but custom model classes that do profile.get('anthropic_supports_adaptive_thinking', False) on a non-Anthropic route will now see the value the upstream Anthropic profile set, where v1 always returned the default.

See the Model Profile guide for how to configure a profile, and PR #5481 for the full ModelProfile redesign.

Parallel tool-call execution runs in emission order

The default end_strategy changed from 'early' to 'graceful'. This only affects responses where a model calls function tools in the same response as an output tool (the call that ends the run). When that output tool succeeds, the function tools requested alongside it now run by default instead of being skipped, so their side effects happen and their results reach the model if the run continues; and a function tool’s ModelRetry now suppresses the output result so the model can correct itself on the next round. The case where every output tool fails is unchanged: function tools run and the run continues either way. Most agents don’t need any change. If you relied on the run ending the instant an output tool succeeds — skipping any function tools requested in the same response — set end_strategy='early' explicitly.

The sequential=True flag on a tool is now a per-tool barrier rather than a batch-wide serial switch: a sequential tool runs alone, but other tools in the same response still run in parallel around it. The barrier now also applies to output tools via ToolOutput(sequential=True), not just function tools. To run all of a run’s tools serially, wrap the run in agent.parallel_tool_call_execution_mode('sequential') or set parallel_tool_calls=False on the model settings.

See Parallel Output Tool Calls for the full behavior of all three strategies, and #5339.

Slimmer default pydantic-ai extras

A bare uv add pydantic-ai / pip install pydantic-ai now installs pydantic-ai-slim[openai,anthropic,google,cli,mcp,evals,web,retries,logfire] — frontier providers plus minimal integrations. Providers and integrations that were previously bundled are no longer installed by default; add the ones you use explicitly, e.g. uv add 'pydantic-ai[bedrock,groq]': bedrock, groq, mistral, cohere, xai, huggingface, temporal, ag-ui, ui, and spec. See the installation guide for the full list of extras.

Some pydantic-ai-slim extras were also removed outright (not just dropped from the default bundle): the outlines-* extras (the Outlines integration is removed), vertexai (Vertex AI is now served by the google extra), fastmcp (the FastMCP back-compat shim is removed), and a2a (A2A now lives in the upstream fasta2a package). See #5467.

Instrumentation defaults to version 5 with aggregated usage attributes

The default instrumentation format is now version 5 (versions 2–4 still work but emit a deprecation warning; version 1 and its event_mode=/logger_provider= arguments are removed). In version 5, deferred tool calls (CallDeferred/ApprovalRequired) are no longer recorded as span errors.

Separately, InstrumentationSettings’s use_aggregated_usage_attribute_names now defaults to True: agent run spans report token usage under gen_ai.aggregated_usage.* while model request spans keep gen_ai.usage.*, which avoids double-counting in backends that sum parent and child usage. Dashboards and alerts that read token usage from run spans must be updated, or set use_aggregated_usage_attribute_names=False to keep the V1 attribute names.

See #5523.

Changes covered by deprecation warnings

These changes were announced in the latest V1 releases via deprecation warnings that name the replacement API. If you upgraded to the latest V1 and resolved every warning, you’ve already made them. The V1 → V2 migration map carries the full before → after for every symbol; this section records the behavior that changes with them and the PRs each one landed in.

Behavior changes that flip silently if the V1 deprecation warning was not addressed — even though these were announced, an unaddressed warning means the behavior changes without raising an error, so confirm you’ve handled them:

  • The bare openai: model prefix now uses the OpenAI Responses API (OpenAIResponsesModel) instead of the Chat Completions API (OpenAIChatModel). Use openai-chat: to keep Chat Completions, or openai-responses: to opt into the new default explicitly. Announced via #5334; flipped in #5469.
  • Provider-adaptive WebSearch and WebFetch capabilities are now native-only and raise on models that don’t support them, and MCP(url=...) runs the server locally by default. Restore the V1 fallbacks with WebSearch(local='duckduckgo'), WebFetch(local=True), and MCP(url=..., native=True). Announced via #5331; changed in #5333.

API removals and renames — look each old name up in the migration map; the PRs that announced and landed each group are:

GroupPRs
Providers: Grok → xAI (grok: prefix → xai:)#5460
Providers: Google GLA/Vertex → GoogleProvider/GoogleCloudProvider, GeminiModel → GoogleModel#5336, #5543, #5479
Models: OpenAIModel → OpenAIChatModel, system_prompt_role and sampling-settings move into the profile#5468
Models: StreamedResponse.usage() becomes a property (affects custom Model subclasses)#5546
Models: bare provider-prefix-less names (Agent('gpt-5')) now raise UserError#5464
Native tools: builtin_tools → native_tools throughout#5338, #5396
Native tools: UrlContextTool → WebFetchTool#5458
MCP: per-transport server classes → MCPToolset#5325, #5337
Agent config → capabilities: instrument=#5434
Agent config → capabilities: event_stream_handler=, prepare_tools=#5335, #5475
Agent config → capabilities: history_processors=#5425
Agent config: mcp_servers= → toolsets=, sequential_tool_calls() → parallel_tool_call_execution_mode()#5466
Tools: DeferredToolCalls → DeferredToolRequests, DeferredToolset → ExternalToolset#5459
Tools: FunctionToolset.tool() now requires a RunContext first parameter#5462
Tools: pydantic_ai.ext.aci removed (wrap with Tool.from_schema)#5510, #5467
Usage and response-field renames (request_tokens → input_tokens, vendor_details → provider_details, …)#5476
Events: dedicated OutputToolCallEvent/OutputToolResultEvent, FunctionToolResultEvent.result → .part#5332
Streaming: StreamedRunResult accessor renames, stream_responses() → stream_response()#5296, #5463
Streaming: Agent.run_stream_events() is an async context manager only#5440
Results: result.usage()/result.timestamp()/stream.get() become properties#5263
Integrations: Agent.to_a2a() and the bundled fasta2a move upstream#5426, #5502
Integrations: Agent.to_ag_ui()/AGUIApp → AGUIAdapter, cached_async_http_client → create_async_http_client()#5345, #5464
Graph: pydantic_graph.beta imports move to top-level pydantic_graph#5306, #5470
Instrumentation: version=1 and its event_mode=/logger_provider= arguments removed#5523
Pydantic Evals: keyword-only arguments, required Dataset(name=...), Evaluator.name → get_serialization_name()#5547, #5548
Pydantic Evals: evaluation_name/evaluator_version class attributes → get_default_evaluation_name()/get_evaluator_version()#5554, #5556

Four of these carry a caveat the name mapping alone doesn’t convey:

  • MCP: Agent.set_mcp_sampling_model() is not removed — it still sets the sampling model on every registered MCPToolset, while MCPToolset(sampling_model=...) sets it on one toolset at construction.
  • Instrumentation: version=2/3/4 still work but now emit a deprecation warning, and the default is version=5 — see Instrumentation defaults above for the behavior changes that ship with it.
  • Agent(instrument=...): only the constructor arguments are removed. The Agent.instrument property, Agent.instrument_all(), and InstrumentedModel are unchanged.
  • Outlines: the integration is removed outright. If you’d like to keep using Outlines with Pydantic AI, please file an issue at dottxt-ai/outlines. See #5444.

v1.0.1 (2025-09-05)

The following breaking change was accidentally left out of v1.0.0:

  • See #2808 - Remove Python evaluator from pydantic_evals for security reasons

v1.0.0 (2025-09-04)

  • See #2725 - Drop support for Python 3.9
  • See #2738 - Make many dataclasses require keyword arguments
  • See #2715 - Remove cases and averages attributes from pydantic_evals spans
  • See #2798 - Change ModelRequest.parts and ModelResponse.parts types from list to Sequence
  • See #2726 - Default InstrumentationSettings version to 2
  • See #2717 - Remove errors when passing AsyncRetrying or Retrying object to AsyncTenacityTransport or TenacityTransport instead of RetryConfig

v0.x.x

Before V1, minor versions were used to introduce breaking changes:

v0.8.0 (2025-08-26)

See #2689 - AgentStreamEvent was expanded to be a union of ModelResponseStreamEvent and HandleResponseEvent, simplifying the event_stream_handler function signature. Existing code accepting AgentStreamEvent | HandleResponseEvent will continue to work.

v0.7.6 (2025-08-26)

The following breaking change was inadvertently released in a patch version rather than a minor version:

See #2670 - TenacityTransport and AsyncTenacityTransport now require the use of pydantic_ai.retries.RetryConfig (which is just a TypedDict containing the kwargs to tenacity.retry) instead of tenacity.Retrying or tenacity.AsyncRetrying.

v0.7.0 (2025-08-12)

See #2458 - pydantic_ai.models.StreamedResponse now yields a FinalResultEvent along with the existing PartStartEvent and PartDeltaEvent. If you’re using pydantic_ai.direct.model_request_stream or pydantic_ai.direct.model_request_stream_sync, you may need to update your code to account for this.

See #2458 - pydantic_ai.models.Model.request_stream now receives a run_context argument. If you’ve implemented a custom Model subclass, you will need to account for this.

See #2458 - pydantic_ai.models.StreamedResponse now requires a model_request_parameters field and constructor argument. If you’ve implemented a custom Model subclass and implemented request_stream, you will need to account for this.

v0.6.0 (2025-08-06)

This release was meant to clean some old deprecated code, so we can get a step closer to V1.

See #2440 - The next method was removed from the Graph class. Use async with graph.iter(...) as run: run.next() instead.

See #2441 - The result_type, result_tool_name and result_tool_description arguments were removed from the Agent class. Use output_type instead.

See #2441 - The result_retries argument was also removed from the Agent class. Use output_retries instead.

See #2443 - The data property was removed from the FinalResult class. Use output instead.

See #2445 - The get_data and validate_structured_result methods were removed from the StreamedRunResult class. Use get_output and validate_response_output instead.

See #2446 - The format_as_xml function was moved to the pydantic_ai.format_as_xml module. Import it via from pydantic_ai import format_as_xml instead.

See #2451 - Removed deprecated Agent.result_validator method, Agent.last_run_messages property, AgentRunResult.data property, and result_tool_return_content parameters from result classes.

v0.5.0 (2025-08-04)

See #2388 - The source field of an EvaluationResult is now of type EvaluatorSpec rather than the actual source Evaluator instance, to help with serialization/deserialization.

See #2163 - The EvaluationReport.print and EvaluationReport.console_table methods now require most arguments be passed by keyword.

v0.4.0 (2025-07-08)

See #1799 - Pydantic Evals EvaluationReport and ReportCase are now generic dataclasses instead of Pydantic models. If you were serializing them using model_dump(), you will now need to use the EvaluationReportAdapter and ReportCaseAdapter type adapters instead.

See #1507 - The ToolDefinition description argument is now optional and the order of positional arguments has changed from name, description, parameters_json_schema, ... to name, parameters_json_schema, description, ... to account for this.

v0.3.0 (2025-06-18)

See #1142 — Adds support for thinking parts.

We now convert the thinking blocks ("<think>..."</think>") in provider specific text parts to Pydantic AI ThinkingParts. Also, as part of this release, we made the choice to not send back the ThinkingParts to the provider - the idea is to save costs on behalf of the user. In the future, we intend to add a setting to customize this behavior.

v0.2.0 (2025-05-12)

See #1647 — usage makes sense as part of ModelResponse, and could be really useful in “messages” (really a sequence of requests and response). In this PR:

  • Adds usage to ModelResponse (field has a default factory of Usage() so it’ll work to load data that doesn’t have usage)
  • changes the return type of Model.request to just ModelResponse instead of tuple[ModelResponse, Usage]

v0.1.0 (2025-04-15)

See #1248 — the attribute/parameter name result was renamed to output in many places. Hopefully all changes keep a deprecated attribute or parameter with the old name, so you should get many deprecation warnings.

See #1484 — format_as_xml was moved and made available to import from the package root, e.g. from pydantic_ai import format_as_xml.

Full Changelog

For the full changelog, see GitHub Releases.