Reveal tools mid-session in realtime sessions on models that take tool updates, via `RealtimeModelProfile.supports_tool_updates` and `UpdateTools`
A realtime session sent the model its tools once, when it opened. So an agent with a defer_loading=True capability that contributes tools, or a defer_loading=True tool, couldn't open a session at all: loading the capability or searching for the tool mid-call would have revealed tools the model never got.
On a model that takes new tools mid-session, the session now sends it the tools a call reveals, ahead of that call's result. This rebuilds Aditya Vardhan's #7570 on current main (after #11930), following his approach: the UpdateTools codec input, sent in the same send as the tool result and ahead of it, the supports_tool_updates profile flag, recording the reveal in history, and rewriting the captured config for reconnects. The commits credit him with Co-authored-by.
[!WARNING]
Compatibility impact: RealtimeInput, the union a RealtimeConnection.send accepts, gains UpdateTools. A session sends it only to a connection whose model's profile sets supports_tool_updates, which defaults to False, so an existing connection never receives it, but code that matches RealtimeInput exhaustively (assert_never) stops type-checking. DEFAULT_REALTIME_PROFILE gains supports_tool_updates: False.
Why this can ship in a minor release: the version policy allows adding new types to unions and new optional profile fields, and no existing connection's behavior changes. The API compatibility check is waived for both in .github/api-compatibility-waivers/.
Migration: in an exhaustive match over RealtimeInput, handle UpdateTools (or raise for it, as the built-in connections without the flag do).
What a session does now
- Reveals. Three things reveal tools, as in a standard run:
load_capability(its capability's tools),search_tools(thedefer_loading=Truetools it finds), and a tool returningToolReturn.tools. The session resolves a revealed tool as it resolves the tools it opens with, and sends every tool the model can call as oneUpdateTools, narrowed bytool_choice. That goes out in the same send as the result and ahead of it, so the model never hears about a tool it can't call yet. - History. A
ToolReturn.toolsreveal is recorded as aToolAvailabilityDeltaPartafter the return, where the graph records it (a search result records its own matches). Aload_capabilitycall is now recorded as aLoadCapabilityCallPart, so the session's own history marks the capability loaded. Before each model turn, the session readsloaded_capability_idsanddiscovered_tool_namesoff history, as the graph does before each request. So the model can call a revealed tool, and a standard run continuing the history has the same tools. This is tested. - Reconnect. The OpenAI-protocol connections (OpenAI, Azure GA and Voice Live, xAI, WebRTC sideband) write the new tools into the captured
session.updatethat a redial replays. GPT-Live writes them into the captureddelegation.responsesconfig, as #11930 does for instructions. - Opening. History that already loaded a capability or revealed a tool sends those tools at connect, on every model. Otherwise the two open-time
UserErrors (a deferred capability that contributes tools, adefer_loading=Truetool) now apply only to models withoutsupports_tool_updates. A deferred capability that contributes native tools still raises everywhere, because no provider turns a native tool on mid-session. - A reveal a model can't take. On a model without the flag, a reveal the open-time checks couldn't foresee (a tool that appears only after the session opened, through a dynamically built toolset) is recorded in history, and the session warns once that the model can't call it, following #11066's warn-don't-raise style for guarantees a provider can't keep.
- Unchanged. Per-turn differences from a dynamic toolset or
prepare_toolsstay local, as before (#7251). Custom connections default to unsupported, since the profile default isFalse.
Public API
RealtimeModelProfile.supports_tool_updates(defaultFalse).pydantic_ai.realtime.codec.UpdateTools, added toRealtimeInput.
OpenAIRealtimeConnection, XaiRealtimeConnection and ElevenLabsRealtimeConnection take a new optional session_config keyword argument, the configuration a redial replays, which their models pass. GPT-Live's connection already took backend=.
Live probes
| Provider | supports_tool_updates | Evidence |
|---|---|---|
OpenAI gpt-realtime, gpt-realtime-2.1 | True | parity cassettes |
| Gateway OpenAI | True | parity cassette |
xAI grok-voice-latest, grok-voice-think-fast-1.0 | True | parity cassettes |
GPT-Live (delegation.responses.tools) | True | test_deferred_capability_tools_go_to_the_backend cassette. The update keeps the backend's native web search |
| Azure AI Voice Live | True | test_deferred_capability_tools_are_revealed_mid_session cassette, recorded with the Voice Live key. The fixture now passes AZURE_VOICELIVE_* through when recording |
| Azure GA | True (via the OpenAI profile) | not re-probed: our Azure OpenAI key returns 401, so the parity row is skipped like the other recent scenarios |
| Eleven Realtime | False | ElevenLabs accepts the update and the model calls the new tool. But its replies after a session.update no longer echo the response.metadata the session uses to tell its replies apart, so the session never finished the turn. Kept off, and noted on the provider page |
| Gemini Live, ElevenLabs Agents | False | tools are fixed at setup or configured on the agent |
Tests
tests/realtime/test_tool_reveals.py, scripted-connection session tests:- a capability load reveals its tools ahead of the result, and the revealed tool is called;
- a standard run continues the session's history with the tools revealed;
- seeded history advertises at connect on a model without updates;
- a second load is refused;
- tool search reveals a
defer_loading=Truetool; - a
ToolReturn.toolsreveal is recorded once; - the update is narrowed by
tool_choice; - an unloaded capability's tool is refused;
- the warn-once path;
- an instruction-only load sends no update;
- unrevealed tools are refused at open.
test_capability_tool_reveal_parityintests/realtime/test_parity_ws.py, recorded live for OpenAI Ć2, xAI Ć2 and gateway OpenAI. Azure is skipped (401). Every row's profile flag is asserted intest_text_tool_round_parity.- GPT-Live and Azure Voice Live cassettes, and a reconnect test checking that the redialed
session.updatecarries the revealed tools.
Notes for review
- To keep complexity down,
OpenAIRealtimeConnection.sendis now amatchover the input type, with one method per multi-statement branch. GPT-Live's instruction-change branch and its new tools branch share_update_backend. - A developer-error reveal (an ordinary tool returning
ToolReturn.toolsnaming a still-unloaded capability's tool) raises the sameUserErroras a standard run, which ends the session. The question #7570 raised is still open.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
š¤ Generated with Claude Code
Summary by cubic
Realtime sessions now reveal tools mid-session on models that take tool updates, so loading a deferred capability, a tool-search match, and ToolReturn.tools work as they do in standard runs. Previously the session fixed its tools at connect, so opening with a hidden tool raised UserError. Closes #7288.
How it works
- New
RealtimeModelProfile.supports_tool_updates(defaultFalse) and theUpdateToolscodec input; the OpenAI, xAI, and ElevenLabs connections take an optionalsession_config. - A reveal sends one
UpdateTools, narrowed bytool_choice, ahead of the revealing result in the same send, and records the reveal in history as aToolAvailabilityDeltaPart. Loading an already-active capability is a no-op, as in standard runs. - OpenAI-protocol connections and GPT-Live keep the updated tools in the config a reconnect replays; a GPT-Live sideband update preserves the backend's native web search.
- Verified on OpenAI
gpt-realtime, GPT-Live, Azure (GA and Voice Live), and xAI Grok Voice. Gemini Live, Eleven Realtime, and ElevenLabs Agents keep the tools they opened with, so the open-timeUserErrors remain there (#7191). - On models without the flag, a reveal not caught at open time is recorded in history and the session warns once that the model can't call it.
RealtimeInputgainsUpdateToolsalongside main's independentAppendVoiceInstructionsinput (#14191), sharing the union andDEFAULT_REALTIME_PROFILE. API-compatibility waivers at v2.75.0 cover the combined change: both new inputs and both new profile flags, each defaulting toFalse.
Migration
- In an exhaustive match over
RealtimeInput, handleUpdateTools, or raise for it as the built-in connections without the flag do.