v2.26.0
pydantic/pydantic-aiv2.26.0Aug 7, 2026by dsfaccini
AI Summary
Introduces first-party run cancellation capabilities, tool deferral features, and makes stream event iterators public for better agent lifecycle management.
Key Highlights
- Added first-party run cancellation: `AgentRun.cancel()`
- Support for hiding function tools until revealed
- Promoted `run_stream_events()` to public `AgentRunEvents`
New Features
- Tool hiding capability via tool search and `ToolReturn.tools`
- Run cancellation API (`AgentRun.cancel`, `RunContext.cancel`)
- Added `Model.resolve_prompt_cache_retention()`
Full Release Notes
<!-- Release notes generated using configuration in .github/release.yml at main --> ## What's Changed ### 🚀 Features * Support hiding function tools until revealed — via tool search, `load_capability`, or `ToolReturn.tools` — using each provider's native deferral/addition channel by @DouweM in https://github.com/pydantic/pydantic-ai/pull/7104 * Add first-party run cancellation: `AgentRun.cancel()`, `RunContext.cancel()`, `RunCancelled` by @DouweM in https://github.com/pydantic/pydantic-ai/pull/6497 * Add `Model.resolve_prompt_cache_retention()` to resolve effective prompt-cache retention from model settings by @DouweM in https://github.com/pydantic/pydantic-ai/pull/7254 * Promote `run_stream_events()` iterator to public `AgentRunEvents` handle with `cancel()` and run-state access by @DouweM in https://github.com/pydantic/pydantic-ai/pull/6498 * Cover and document DeepSeek V4 Flash via `OpenAIResponsesModel` + `DeepSeekProvider` by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7202 ### 🐛 Bug Fixes * Forward `model_id` through `WrapperModel` and resolve it against the active model in `TemporalModel` by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7181 * Map streamed OpenRouter reasoning details by their index by @VictorPeralta in https://github.com/pydantic/pydantic-ai/pull/7214 * Gate OpenRouter off native mid-conversation system messages with `supports_inline_system_prompts=False` by @DouweM in https://github.com/pydantic/pydantic-ai/pull/7253 * Restore the released legacy profile-key shim and fix two reveal-state edges (`is_tool_available`, `TestModel` native additions) by @DouweM in https://github.com/pydantic/pydantic-ai/pull/7260 * Keep deferred tools searchable after discovery and reset reveal state at `CompactionPart` boundaries by @DouweM in https://github.com/pydantic/pydantic-ai/pull/7225 * Forward events from `UIEventStream` callbacks that return an async iterator without being an async generator function by @DouweM in https://github.com/pydantic/pydantic-ai/pull/7256 * Send only the compacted window: drop history before the latest same-provider `CompactionPart` by @DouweM in https://github.com/pydantic/pydantic-ai/pull/7228 ## New Contributors * @VictorPeralta made their first contribution in https://github.com/pydantic/pydantic-ai/pull/7214 **Full Changelog**: https://github.com/pydantic/pydantic-ai/compare/v2.25.0...v2.26.0