v2.38.1

pydantic/pydantic-aiv2.38.1Sep 3, 2026by dsfaccini

AI Summary

This release introduces support for new AI models including Gemini 3.8 Flash and Claude Fable/Mythos 5.1, adds a VLLM provider, and enhances event streaming with typed events. It also includes numerous bug fixes for DeepSeek, Anthropic, and Bedrock integrations.

Key Highlights

  • Adds support for `gemini-3.8-flash`, `claude-fable-5-1`, and `claude-mythos-5-1` models.
  • Introduces a new `VLLMProvider` for vLLM servers.
  • Enhances event streaming with typed `CustomEvent` and `CapabilityEvent` support via `@on_event`.
  • Adds `context_window` and `context_window_used` tracking to `ModelProfile` and `RunContext`.

New Features

  • Add `context_window` to `ModelProfile` and `context_window_used` to `RunContext`.
  • Add profile flag to reject streams without `finish_reason`.
  • Add `gemini-3.8-flash` model.
  • Let application code and capabilities emit typed `CustomEvent`s and `CapabilityEvent`s into the run event stream.
  • Add Claude Fable 5.1 (`claude-fable-5-1`) and Claude Mythos 5.1 (`claude-mythos-5-1`) support.
  • Add `VLLMProvider` for vLLM servers.

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](https://github.com/apps/pydanty) 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.1