Make realtime shared settings warn, raise or ignore like standard `ModelSettings`: forced `tool_choice` raises on Gemini Live, `parallel_tool_calls=False` warns

Merged
DO
1mo ago
+477-189

Written by Claude (Douwe's coding agent) at Douwe's request.

Realtime shared settings now follow the policy #10508 set for standard models: tuning knobs a provider can't apply are ignored silently, guarantee settings warn with UnsupportedSettingWarning, and a tool_choice that forces a tool call raises. Before this, each realtime provider made its own call: GPT-Live raised for max_tokens, while Gemini quietly dropped a forced tool_choice.

[!WARNING]
Compatibility impact:

  • Gemini Live: a tool_choice of 'required' now raises UserError before connecting; until now it was ignored. A list of tool names now raises as well; it used to be treated as an allow-list.
  • New UnsupportedSettingWarnings, which fail under -W error:
    • parallel_tool_calls=False with function tools, on xAI, Gemini, Eleven Realtime and ElevenLabs Agents.
    • async_tool_calls=False with function tools, on models whose tool calls are always asynchronous.
    • A reconnect policy on ElevenLabs Agents. This used to raise UserError.

Why this can ship in a minor release:

  • Gemini can't express a forced tool choice (LiveConnectConfig/LiveClientSetup have no tool_config), so the session never did what the setting asked. Every other realtime provider already raises for it, and standard models raise for an explicit forcing tool_choice they can't honor (supports_forced_tool_choice).
  • The warnings are the ones #10508 added for standard models.

Migration:

  • On Gemini, use tool_choice=ToolOrOutput(function_tools=[...]) to restrict the tools, which is what a list of names did before.
  • Drop the ignored setting, or filter UnsupportedSettingWarning.

The rule (from #10508 and the forced-tool-choice profile flags)

KindStandard modelRealtime, after this PR
Tuning knob (max_tokens, thinking, TurnDetection knobs, a pinned transcription model)ignored silentlyignored silently
Guarantee (parallel_tool_calls=False/async_tool_calls=False with function tools, reconnect)UnsupportedSettingWarning, via Model.unsupported_settingsUnsupportedSettingWarning, via RealtimeModel.unsupported_settings (plus the profile's async_tool_call_mode) and the same helper
Explicit forcing tool_choice the model can't honorUserErrorUserError on every provider

Before → after

SettingOpenAIAzurexAIGeminiGPT-LiveEleven RealtimeElevenLabs Agents
max_tokensokokignoredokraise → ignoredokignored
parallel_tool_calls=Falseokoksilent → warnsilent → warnoksilent → warnsilent → warn
forcing tool_choiceraiseraiseraiseignored → raiseraiseraiseraise
input_transcription_model=Noneoffoffoffoffignoredignoredraise → ignored
pinned input_transcription_modelokokokignoredraise → ignoredraise → ignoredignored
turn_detection=Trueokokokokraise → okokok
TurnDetection knobsokokokokraise → ignoredokraise → ignored
reconnectokokokokokokraise → warn (a drop still ends the session)

async_tool_calls=False on an always-async model (Gemini 3.1 Flash Live, for example) goes from silent → warn.

Unchanged on purpose:

  • turn_detection=False still raises where the provider owns turn-taking (Gemini, GPT-Live, ElevenLabs Agents), since push-to-talk can't be provided there.
  • output_modality='text' on a speech-only model still raises.
  • input_transcription_model=None on providers that always transcribe stays silent.

Mechanism

  • RealtimeModel.unsupported_settings, typed by the new RealtimeModelSettingName, mirrors Model.unsupported_settings.
  • Model.prepare_request's loop moved into _unsupported_settings.warn_unsupported_settings, which now takes the guarantee set, so standard and realtime models share one implementation. The realtime session calls it once, before connecting, with the merged settings.
  • A shared reject_forced_tool_choice in realtime/_utils.py replaces the four copies of the forced-choice check (OpenAI protocol, GPT-Live, ElevenLabs Agents, and the new Gemini one).

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
  • PR title is fit for the release changelog.

🤖 Generated with Claude Code