python Pydantic AI Releases · · 2.5.0

pydantic-ai v2.5.0: Security Fix, New Features, and Bug Fixes

sdkaimediapython-agentic
security feature patch

Version 2.5.0 of pydantic-ai addresses a moderate security vulnerability (GHSA-jpr8-2v3g-wgf9) related to message sanitization in the AG-UI serving path. This release also introduces new features like `sanitize_messages` for inbound history hardening and round-trip multimodal tool returns through AG-UI and Vercel AI adapters. The update includes numerous bug fixes across various components, impacting users of both v2 and v1 lines of the library.

  • Patched: 2.5.0 (v2) and 1.107.1 (v1)
  • Affected: >= 2.0.0, < 2.5.0 (v2) and >= 1.88.0, < 1.107.1 (v1)
  • Add sanitize_messages for inbound message-history hardening by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6169
  • Reject duplicate deferred tool call IDs by @hramezani in https://github.com/pydantic/pydantic-ai/pull/6241
  • Fix MoonshotAI Kimi thinking support and add models to KnownModelNames by @SuperMarioYL in https://github.com/pydantic/pydantic-ai/pull/6208
Security (2)
  • Patched: 2.5.0 (v2) and 1.107.1 (v1)
  • Affected: >= 2.0.0, < 2.5.0 (v2) and >= 1.88.0, < 1.107.1 (v1)
Features (2)
  • Add sanitize_messages for inbound message-history hardening by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6169
  • Round-trip multimodal tool returns through the AG-UI and Vercel AI adapters (history and streaming) by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/5255

Fixes (11)
  • Document why _clean_message_history merges consecutive ModelRequests regardless of conversation_id/metadata by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/6221

  • Align LLMJudge _build_prompt section order with its few-shot examples by @immuhammadfurqan in https://github.com/pydantic/pydantic-ai/pull/6111

  • Reject duplicate deferred tool call IDs by @hramezani in https://github.com/pydantic/pydantic-ai/pull/6241
  • Fix MoonshotAI Kimi thinking support and add models to KnownModelNames by @SuperMarioYL in https://github.com/pydantic/pydantic-ai/pull/6208
  • fix(dbos,prefect): preserve runtime toolsets in durable runs by @Trollgeir in https://github.com/pydantic/pydantic-ai/pull/6076
  • Exclude first-class token counts from gen_ai.usage.details.* OTel attributes to fix double-counting by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/6244

  • fix(dbos,prefect): preserve runtime event stream handlers by @Trollgeir in https://github.com/pydantic/pydantic-ai/pull/6093
  • Reject non-object agent spec inputs by @Ghraven in https://github.com/pydantic/pydantic-ai/pull/5820
  • Run the sync streaming wrappers on an anyio portal thread; fix async stream_text early-break teardown by @DouweM in https://github.com/pydantic/pydantic-ai/pull/6199

  • fix(bedrock): only synthesize a leading user message for models that require it by @DouweM in https://github.com/pydantic/pydantic-ai/pull/6255

  • fix(bedrock): correct bedrock_supported_media_kinds_in_tool_returns for Meta, Mistral, and Qwen by @DouweM in https://github.com/pydantic/pydantic-ai/pull/6254

Read the original announcement →

https://github.com/pydantic/pydantic-ai/releases/tag/v2.5.0

Related releases