Pydantic AI realtime sessions: wait for playback before closing the final reply

If your Pydantic AI voice application closes its realtime session as soon as the final response finishes generating, review that shutdown boundary when adopting v2.46.0. For normal completion of a final spoken reply, use playback completion as the point that permits closure.

The concrete change is in the Pydantic AI v2.46.0 release notes: “Add RealtimeSession.wait_for_playback() and let the docs examples finish the reply before closing,” in the feature entry for PR #8141. That supports a focused lifecycle change. It does not establish a latency improvement or an audio-quality result.

The integration decision is where your application declares the conversation finished. My recommendation is to keep response generation completion and playback completion distinct in the normal shutdown path. Review the examples for your installed version to place wait_for_playback() before session closure. The release note alone does not supply enough detail for a reliable copy-and-paste calling sequence.

Before adopting that path, validate three cases separately:

Case What to check in your application
Final reply completes normally Record generation completion, the playback wait’s outcome, and session closure. Check that normal closure follows successful playback completion.
User interrupts the final reply Decide whether interruption cancels the planned close or ends the interaction. Verify that the application follows that policy, and record how the playback wait exits.
Connection drops during the wait Record the disconnect and wait outcome separately from successful completion. Verify that cleanup follows a defined failure path.

These are proposed tests, not reported behavior of the new method. In particular, interruption and disconnect should not inherit a “reply finished” label merely because the session ended. Choose an application policy for a wait that does not complete normally, including how cleanup will happen, then verify the actual API behavior before implementing it.

There is also a limit to what “playback finished” can mean based on this announcement. The release notes do not define the completion signal, which client audio buffers it covers, or timeout and cancellation semantics. They do not guarantee that the listener physically heard every word. If your acceptance criterion is audible completion on a particular client, include a client-side playback check instead of treating a server-side event log as sufficient proof.

The useful migration question is concrete: does the final-reply close path wait for playback, and can your logs distinguish that successful path from interruption or disconnection? The release gives you a new method and an example change to investigate; those separate outcomes are the application checks to bring to the upgrade.

For an upgrade evaluation, I would make the shutdown policy an explicit experimental variable. A before/after comparison that changes both the model and the final-reply close path would leave the cause of any improvement unresolved. The v2.46.0 release entry establishes the addition of RealtimeSession.wait_for_playback() and the example change; it supplies no measured model-quality result.

My suggested comparison is to hold the model, prompts, voice settings, client, and playback setup fixed, then compare the existing close path with the playback-aware path. Where feasible, run both paths on the same SDK version so unrelated release changes do not enter the comparison. Record the actual reply duration as well: even with the same prompt, different generated replies need not take the same time to play.

Define the outcome before running the comparison. For example, score whether the final reply reaches its end using a client-side observation, and report time to session closure separately. A later close can be consistent with allowing more of the reply to play; that timing alone would not establish slower model generation. Keep interrupted and disconnected trials visible as separate outcomes rather than silently excluding them from the denominator.

This is a proposed evaluation design, not a reported test. It would help decide whether the shutdown change meets the application’s completion criterion, while keeping any conclusion about the model itself outside what this release note supports.