What's Changed
馃殌 Features
- Add
pydantic_ai.prices.update_in_background()by @adtyavrdhn in #4841 - Handle barge-in in the session:
handle_barge_in=True,interrupt(played_bytes=...), andplayed_audio_bytesby @DouweM in #7870 - Add
provider_factorytoinfer_realtime_modelby @DouweM in #8106 - Add
@agent.on_eventfor registering event listeners on anAgentby @DouweM in #8101 - Add
respond=toRealtimeSession.send()and document that a text turn solicits a reply by @DouweM in #8110 - Add
RealtimeSession.enqueue()for out-of-band prompts from code driving the session by @DouweM in #8109
馃悰 Bug Fixes
- Map
finish_reasonon OpenAI Responses stream terminal events by @pydanty in #7916 - Fix
defer_loadingreveal synthesis splitting a parallel batch'stool_resultfrom itstool_useby @pydanty in #7879 - fix(realtime): roll back user-turn state when an audio chunk is not bytes-like by @simpleqt in #7905
- Let a capability cache derived state again, and refuse a collection the merge cannot rebuild by @DouweM in #8099
- Make a capability's auto-assigned registry key look like the run-local handle it is by @DouweM in #8119
- Stop sending
reasoningto the datedgpt-realtime-2025-08-28snapshot by @DouweM in #8103 - Subscribe
stream_audio()andstream_transcripts()views when they are called, not on first iteration by @DouweM in #8107 - End the realtime audio and transcript views when a tool fails and nobody is iterating by @DouweM in #8108
- Let a realtime tool hang up with
ctx.realtime_session.close()instead of wedging itself by @DouweM in #8105 - Fix the realtime "Speaking first" and relay examples, the
interrupt(played_ms=)cancel race, and two provider tables by @DouweM in #8132
New Contributors
Full Changelog: v2.39.0...v2.40.0