v2.13.0
pydantic/pydantic-aiv2.13.0Jul 18, 2026by dsfaccini
AI Summary
This release focuses on enhancing observability with new OpenTelemetry settings and caching metrics, introduces hooks for model resolution, and fixes several streaming and context handling bugs.
Key Highlights
- Addition of `cache_hit_ratio` property to `RequestUsage` and `RunUsage` for monitoring caching efficiency.
- New `include_model_request_parameters` setting for OpenTelemetry instrumentation to control span attributes.
- New capability hooks: `get_model`, `resolve_model_id`, and `for_agent`.
- Bug fix for spurious OpenTelemetry context detachment errors during interrupted streaming.
New Features
- Add `include_model_request_parameters` instrumentation setting to omit the `model_request_parameters` span attribute.
- Add `RaiseContentFilterError` capability to raise content filter error for non-empty content filter responses.
- feat(usage): add `cache_hit_ratio` property to `RequestUsage` and `RunUsage`.
- Add `get_model`, `resolve_model_id`, and `for_agent` capability hooks.
Full Release Notes
<!-- Release notes generated using configuration in .github/release.yml at main --> ## What's Changed ### 🚀 Features * Add `include_model_request_parameters` instrumentation setting to omit the `model_request_parameters` span attribute by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6488 * Add `RaiseContentFilterError` capability to raise content filter error for non-empty content filter responses by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6167 * feat(usage): add `cache_hit_ratio` property to `RequestUsage` and `RunUsage` by @DouweM in https://github.com/pydantic/pydantic-ai/pull/6529 * Add `get_model`, `resolve_model_id`, and `for_agent` capability hooks by @DouweM in https://github.com/pydantic/pydantic-ai/pull/6333 ### 🐛 Bug Fixes * Fix `MistralModel` streaming settings by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/6563 * Close open message parts (text, thinking, tool calls) on UI stream error by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6550 * Fix spurious OTel `Failed to detach context` error when a streamed run is interrupted mid-segment by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6572 * fix(temporal): pass through `pydantic_monty` in workflow sandbox by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/6564 ### 📦 Dependencies * deps: bump `mcp` to 1.28.1 for Dependabot alerts by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/6562 **Full Changelog**: https://github.com/pydantic/pydantic-ai/compare/v2.12.0...v2.13.0