pypi pydantic-ai 2.75.0
v2.75.0 (2026-11-25)

43 minutes ago

What's Changed

⚠️ Compatibility Notes

  • Keep workspace files below 'operator' authority out of the instructions in RepoContext, Skills and Memory, and add lowest_authority_under by @adtyavrdhn in #11837
    • 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.
  • Raise empty and unreadable model responses as ModelEmptyResponseError and ModelInvalidResponseError, so FallbackModel and ModelFallback fall back on them by @DouweM in #12108
    • 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).
  • Resolve Pax /permissions approvals through a token-taking HandleDeferredToolCalls handler with harness approval_ask by @DouweM in #13195
    • 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.
  • Share one instructions string across a conversation's requests instead of keeping a copy per request by @DouweM in #13308
    • 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.
  • Send Coder's no-unrequested-sub-agents line only to models that need it, and let instructions branch on the model serving each request by @DouweM in #13764
    • 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.
  • Count Gemini's thinking tokens as output in OpenAIChatModel usage by @pydanty in #14297
    • 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).
  • 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 by @DouweM in #14414
    • 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}.
  • Lower a capability's instructions with its authority, so with_authority covers get_instructions() and MCP server instructions by @DouweM in #14457
    • 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.

🚀 Features

  • Raise empty and unreadable model responses as ModelEmptyResponseError and ModelInvalidResponseError, so FallbackModel and ModelFallback fall back on them by @DouweM in #12108
  • Add RunContext.submit_output() to let a tool submit the run's final output by @DouweM in #11348
  • Add a Temporal ExternalEventWaiter so HandleDeferredToolCalls token handlers and AskUser wait durably in a workflow by @DouweM in #13215
  • Let ClearToolResults target specific tools, keep whole user turns with keep_turns, and take a callable placeholder by @DouweM in #12408
  • Send Coder's no-unrequested-sub-agents line only to models that need it, and let instructions branch on the model serving each request by @DouweM in #13764
  • Send Coder's OpenAI-specific 'max' guidance through per-model profile flags by @DouweM in #14418
  • Keep workspace files below 'operator' authority out of the instructions in RepoContext, Skills and Memory, and add lowest_authority_under by @adtyavrdhn in #11837
  • Lower a capability's instructions with its authority, so with_authority covers get_instructions() and MCP server instructions by @DouweM in #14457
  • Add AnnounceWorkingDirectory so Shell, FileSystem and custom tools name the working directory once by @DouweM in #14427
    • Shell and FileSystem agents get one more instruction line. With Coder(repo_context=False) or a plain Shell or FileSystem agent, a lazily created sandbox now starts before the first request instead of at the first tool call. Durable runs are unaffected.
  • Show your prompts in the Pax transcript on a grey background under a /theme palette by @dsfaccini in #12802
  • Resolve Pax /permissions approvals through a token-taking HandleDeferredToolCalls handler with harness approval_ask by @DouweM in #13195
  • Ask whether to trust a new folder in Pax, with /trust and a status-row indicator by @montybot-pydantic in #14349
  • Add pax --version by @DouweM in #14392
  • Make /sandbox faster on large repositories and say what it is doing by @adtyavrdhn in #14584

🐛 Bug Fixes

  • Require truststore>=0.10.5 so concurrent first requests through the default httpx2 client no longer crash by @mpfaffenberger in #13880
  • Read a cancelled Temporal activity's error so it isn't logged as never retrieved by @DouweM in #14398
  • Run for_run and for_run_step on the toolset a DynamicToolset factory returns, so dynamic capabilities keep nested dynamic tools by @dsfaccini in #13326
  • Count Gemini's thinking tokens as output in OpenAIChatModel usage by @pydanty in #14297
  • Keep a tool's capability_id when a prepare function rebuilds its ToolDefinition by @DouweM in #14374
  • Stop an exiting Pax session from marking another live session's background task as cancelled by @DouweM in #14394
  • Stop list_files/grep with a glob like * from walking hidden directories in the harness FileSystem by @mpfaffenberger in #14342
  • Classify an error status a retrying transport gave up on by the error's message, as the openai SDK does by @pydanty in #14353
  • Keep a completed sibling tool return in the interrupted history under end_strategy='exhaustive' by @pydanty in #14324
  • [cache] Keep the GPT-6.2 cached prefix when a dynamic instruction changes after an appended one by @dsfaccini in #14371
  • Share one instructions string across a conversation's requests instead of keeping a copy per request by @DouweM in #13308
  • 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 by @DouweM in #14414
  • Leave container_upload blocks out of the Anthropic count_tokens request, so CodeExecutionTool(files=...) can be counted by @dsfaccini in #13936
  • Send 'low' for thinking='minimal' on GPT-5.1 through GPT-5.5 with OpenAIProvider by @dsfaccini in #14415
  • Annotate pydantic_ai.__all__ so it still type-checks past 256 exports by @DouweM in #13761
  • Send no reasoning_effort for thinking on gpt-5-search-api with OpenAIProvider by @dsfaccini in #14484
  • Open the BoxdSandbox desktop panel's terminal below the panel instead of over it by @dsfaccini in #14557
  • Stop reporting a persistent shell command too long for an SSHWorkspace as a pending launch by @adtyavrdhn in #14581
  • Keep CapabilityInstructionSource and RunInstructionSource instruction ids through the Temporal payload converter by @DouweM in #14511
    • Instruction ids that the Temporal payload converter already recorded with the wrong source (toolset:<id> for a capability, agent:<name> for a run) can't be recovered, so the loaded capability's instruction block is stated once more, including in runs in flight at the upgrade.
  • Make Esc stop editing a queued Pax message instead of interrupting the turn by @DouweM in #10661
  • Describe the Pax coder plugin's instructions setting as added after the defaults, not replacing them by @DouweM in #14393
  • Name the Pax web UI's search and filter fields for screen readers, and test its recurring web UI defects by @dsfaccini in #14410

Full Changelog: v2.74.0...v2.75.0

Don't miss a new pydantic-ai release

NewReleases is sending notifications on new releases.