Learning resourcesReviewed · Pydantic

Pydantic AI: History and handoff

This Pydantic AI guide helps Python developers continue voice conversations across realtime sessions and text agents, but portability depends on transcripts and provider support. It explains conversation snapshots, usage-aware handoffs, audio and image retention, and transcription edge cases.

Researched 15 Nov 2026

In short.

This Pydantic AI guide helps Python developers preserve and transfer voice conversations, but replay and handoff depend on available transcripts and provider capabilities. It documents shared message types, conversation bundles that carry usage totals, bounded audio and image retention, and history updates caused by transcription delays or interruptions. It is useful for designing conversation continuity, although installation, authentication, pricing, release compatibility and measured runtime behavior are not established by this page.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete selected page at [https://pydantic.dev/docs/ai/realtime/history/index.md], captured at 2026-11-15T12:04:57.180Z with source revision sha256:bc8749c1a272fd708ffef8d67919065cfa1e6c0906b142593ba508202eadb014. Scope includes the introductory documentation-index and query-parameter notices, history snapshots, session seeding, text handoff, context-window reporting, audio and image retention, and transcription edge cases. Linked pages, library implementation, provider terms, pricing and installation documentation are excluded. Examples were not executed; runtime behavior and release compatibility are not assessed.

The overview

Identity

History and handoff is a feature guide in the Pydantic AI realtime documentation at [https://pydantic.dev/docs/ai/realtime/history/index.md]. It explains how voice-session history can seed another realtime session or pass to a text agent for summarization, extraction and follow-up.

The resource is documentation with Python examples. Its scope is conversation continuity and retention; it does not provide a complete voice application.

Assessment

The guide is useful when a voice assistant needs to resume a conversation, produce written notes or continue work with another agent. Its strongest detail concerns cases that simple transcript copying misses: interrupted speech, late transcripts, tool-result ordering and usage tracking across handoffs.

It supports implementation planning, but does not establish that any particular application or provider combination works in practice. No execution results, reliability measurements or performance benchmarks are supplied.

Users

The main audience is Python developers building voice assistants with Pydantic AI. Beginners can use the examples to understand passing a conversation between agents, while experienced developers get details needed for persistence, provider portability and retention decisions.

The examples assume familiarity with asynchronous Python and Agent objects. Installation, microphone integration and a complete application interface are outside the page.

Capabilities

Realtime sessions expose all_messages() for seeded history plus session messages, and new_messages() for messages added during the session. Both return copy-on-read snapshots. A new session accepts message_history, and a text Agent.run() can receive a session snapshot.

A conversation bundle also carries cumulative usage and conversation_id. Passing a text result's conversation into a realtime session preserves those values; session.conversation provides the bundle for continuing with a text run.

Additional controls retain audio or sampled images and expose context_window_used when sufficient provider information exists. Optional speech timestamps remain in history, while a text agent receives the assistant's transcript.

Using it

Requirements

The examples assume a Python environment with Pydantic AI and access to suitable realtime and text models. This page does not specify installation commands, authentication steps, minimum Python or package versions, or a complete audio transport.

Before designing cross-model continuation, inspect supports_session_seeding, supports_seeding_images and supports_seeding_audio on RealtimeModelProfile. Transcript-free user audio can seed a compatible model only when recorded at that model's input sample rate. Assistant speech always needs a transcript for seeding.

History from a browser or another untrusted client needs sanitization with sanitize_messages before seeding. Seeded history is trusted server-side state: opening system prompts become session instructions, and image URLs can trigger server downloads.

Mechanism

Realtime sessions use the same ModelMessage history as standard agent runs. Spoken turns use SpeechPart; text, images and tool exchanges retain the ordinary ModelRequest and ModelResponse structure. When a session starts without message_history, the agent's system prompts are recorded first as a ModelRequest of SystemPromptParts, so they carry over on handoff or seeding. Later system prompts and instruction changes remain at their conversation positions.

Seeding projects supported content into the provider's conversation format. Tool exchanges use native function calls where possible and readable text otherwise. Session-specific thinking signatures and native execution metadata are omitted. History processors do not run during realtime seeding.

History reflects provider ordering and completion signals. Later snapshots can contain updated copies of earlier messages after interruption or audio eviction. Tool returns can also be inserted immediately after their calling response. Applications that persist history should therefore store the latest snapshot rather than only append messages beyond a previous length.

Setup

Create an Agent, choose a compatible realtime model and open its asynchronous session. Use message_history for an existing message sequence, or conversation when cumulative usage and conversation identity must continue from a text run.

Choose retention settings deliberately. Audio defaults to transcript_only; input_audio, output_audio and all retain the corresponding finalized WAV audio. Image sampling uses retain_images_every_n, while retain_images_max sets the retained-image cap.

Check the destination model's capabilities and sanitize untrusted history before passing it into the session. For a later text task, provide the session history to Agent.run(); use the conversation bundle when usage continuity matters.

Example

The page creates a voice Agent and a text notetaker. The voice session receives a request to be reminded to book a train tomorrow, waits for RealtimeTurnCompleteEvent and closes. The notetaker then receives session.all_messages() as message_history and is asked to summarize the conversation.

The displayed summary repeats the booking reminder. This is illustrative documentation output; the supplied evidence does not establish an executed result. The example demonstrates a handoff after closing the voice session. For work that must finish during an open call, the page instead points to exposing a delegated text agent as a realtime function tool.

Assessment & evidence

Limitations

Video, documents, uploaded-file references and model-generated files cannot seed a realtime session. Unsupported content raises UserError. Content-less speech is skipped during seeding, and assistant audio without a transcript cannot transfer to another session or a text agent.

Transcript availability affects when history becomes visible. On OpenAI, Azure OpenAI and xAI, a completed reply can wait for its preceding user transcript for up to 30 seconds after the reply finishes. Providers also differ in speech boundaries and ordering, so retained microphone audio can include silence rather than a precisely trimmed utterance.

context_window_used is None until it can be calculated, and it can decrease during a session because providers compact or truncate the conversation server-side without reporting it. The page reports no usable fraction for xAI Grok Voice. ElevenLabs Agents requires context_usage in client_events for its context report.

Evicting retained audio preserves the transcript but removes the audio. Retained audio also appears in message history, tool-visible messages and response-span inputs and outputs. Retention choices therefore affect persistence and observability as well as replay.

Reasoning

The shared message representation offers a practical way to move from speech interaction to structured text work without manually rebuilding every turn. Conversation bundles add continuity for usage limits and telemetry correlation.

Transcripts are central to portable continuation because assistant speech requires them, while audio-input support varies by destination model. Retaining recordings adds information to local history and observability, but does not by itself improve model compatibility.

The important design distinction is between locally retained history and the provider's active context. Audio eviction and image sampling control what the application keeps; separate provider settings govern long-conversation truncation or compression.

Alternatives

For a written summary or extraction after a call, pass history to a text agent. For another voice interaction, seed a new realtime session. For work during a call, expose the text agent as a realtime function tool. A summary can also seed a fresh session when carrying the full conversation is unsuitable.

Use message_history when the message sequence is sufficient, or conversation when cumulative usage and conversation identity must travel with it. Transcript-only retention is the default; retaining recordings serves workflows that need the audio itself.

The supplied page does not compare other agent frameworks or standalone voice services, so their relative capabilities and costs are not assessed.

Evidence

The evidence is the complete captured Pydantic AI History and handoff page at [https://pydantic.dev/docs/ai/realtime/history/index.md]. It contains API descriptions, configuration defaults, provider-specific behavior and Python examples.

These are documentation claims rather than independent measurements. Linked API references, provider guides, implementation code and example applications are outside the supplied evidence. No code was executed, and runtime correctness, latency, transcription quality and interoperability remain unassessed.

Access & freshness

Costs

Provider prices, total operating costs and any applicable fees are unknown from this page. Carrying a conversation bundle preserves usage accounting across a handoff so configured usage limits can keep counting; it does not establish a monetary budget or price.

For retained audio, the default duration budget is 1,800 seconds across both speakers, described as about 86 MB at 24 kHz. Seeded audio and audio held by events awaiting consumption are outside that simple retained-history bound. Image retention defaults to a maximum of 100 images.

These retention controls affect local history. Providers still receive all submitted audio and image frames, so reducing retained history does not establish lower provider usage or charges.

Rights

The supplied page does not state licensing or redistribution terms for its prose, examples or the Pydantic AI library. Those rights are unknown from this evidence.

Provider terms and rights governing conversation recordings, uploaded images or generated content are also not established here.

Freshness

The page was captured on 15 November 2026 at 12:04:57 UTC. It does not state a publication date, last-updated date or Pydantic AI release version.

The provider behavior and model identifiers belong to that captured documentation. Compatibility with a particular installed release, current model availability and subsequent documentation changes are unknown.

Actions

Choose whether the application needs a post-call text task, a resumed voice session or delegated work during a call. Match that choice to the documented handoff method and destination model profile.

Retain transcripts for portable continuation, sanitize client-supplied history and decide whether audio or images need to persist. Set retention budgets with the understanding that they do not cap provider context.

Before relying on the integration, verify the installed release's API and provider requirements. Exercise interrupted speech, delayed transcripts, tool completion and history persistence in the intended application. These behaviors have not been executed or validated by the supplied evidence.

Evidence for this report

selected-page.txtselected · checked 2026-11-15