v2.38.0

pydantic/pydantic-aiv2.38.0Sep 3, 2026by adtyavrdhn

AI Summary

This release introduces support for new AI models including Gemini 3.8 Flash and Claude Fable/Mythos 5.1, alongside new context tracking capabilities. It also allows applications to emit custom events into the run event stream and includes various bug fixes for streaming and tool handling across different providers.

Key Highlights

  • Adds support for Gemini 3.8 Flash, Claude Fable 5.1, and Claude Mythos 5.1 models.
  • Introduces `context_window` and `context_window_used` fields for better resource tracking.
  • Allows application code to emit `CustomEvent`s and `CapabilityEvent`s into the event stream.
  • Adds a profile flag to reject streams that do not include a `finish_reason`.

New Features

  • Added `context_window` to `ModelProfile`.
  • Added `context_window_used` to `RunContext`.
  • Added profile flag to reject streams without `finish_reason`.
  • Added support for `gemini-3.8-flash` model.
  • Added support for `claude-fable-5-1` and `claude-mythos-5-1` models.
  • Allows emitting typed `CustomEvent`s and `CapabilityEvent`s from application code.

Full Release Notes

<!-- Release notes generated using configuration in .github/release.yml at main -->

## What's Changed
### ⚠️ Compatibility Notes
* Give one-off capabilities a default `id` and a `combine` rule for repeats by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7248
### 🚀 Features
* Add `context_window` to `ModelProfile` and `context_window_used` to `RunContext` by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/4611
* Add profile flag to reject streams without `finish_reason` by @jonashaag in https://github.com/pydantic/pydantic-ai/pull/7096
* Add `gemini-3.8-flash` model by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/8021
* Let application code and capabilities emit typed `CustomEvent`s and `CapabilityEvent`s into the run event stream and subscribe with `@on_event` by @DouweM in https://github.com/pydantic/pydantic-ai/pull/6258
* Add Claude Fable 5.1 (`claude-fable-5-1`) and Claude Mythos 5.1 (`claude-mythos-5-1`) support by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7989
* Add `VLLMProvider` for vLLM servers by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/6153
### 🐛 Bug Fixes
* Support `CancellationToken` in UI adapter run methods by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7743
* Stop `pytest tests/durable_exec/temporal` from crashing when the suite's requirements are missing by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7898
* Fix DeepSeek and Together forced `tool_choice` handling and support `NativeOutput` on DeepSeek's Responses API by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7450
* Restore raw tool-call IDs when replaying Bedrock Mantle Responses history by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7962
* Keep a run cancelled during its first tool call resumable by @DouweM in https://github.com/pydantic/pydantic-ai/pull/7993
* Fix `CodeExecutionTool` uploads never reaching a fresh Anthropic container on a multi-turn history by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7864
* Prevent synthetic reasoning IDs from reaching OpenAI Responses by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/8020
* Emit `REASONING_*` events from `ag-ui-protocol` 0.1.11 instead of 0.1.13 by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/7226
* Accept the environment-key call pattern in `GoogleProvider`'s overload by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/8030
* Fix `XaiModel` streamed text after a native tool call being merged into the ended pre-call part by @pydanty[bot] in https://github.com/pydantic/pydantic-ai/pull/7925
* Persist Anthropic stale thinking-block recovery across turns by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/8037
* Preserve dynamic `native` factory config in `XSearch` and `ImageGeneration` fallback subagents by @CoralGarden52 in https://github.com/pydantic/pydantic-ai/pull/7541
### 📦 Dependencies
* Bump `genai-prices` to 0.1.6 by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/8019

## New Contributors
* @piomeer made their first contribution in https://github.com/pydantic/pydantic-ai/pull/7952
* @jonashaag made their first contribution in https://github.com/pydantic/pydantic-ai/pull/7096
* @CoralGarden52 made their first contribution in https://github.com/pydantic/pydantic-ai/pull/7541

**Full Changelog**: https://github.com/pydantic/pydantic-ai/compare/v2.37.0...v2.38.0