Skip to content

fix(realtime): omit null audio formats in SIP call attach updates#2454

Merged
seratch merged 1 commit into
openai:mainfrom
weiguangli-io:codex/openai-agents-2308-audio-format-null
Feb 10, 2026
Merged

fix(realtime): omit null audio formats in SIP call attach updates#2454
seratch merged 1 commit into
openai:mainfrom
weiguangli-io:codex/openai-agents-2308-audio-format-null

Conversation

@weiguangli-io
Copy link
Copy Markdown
Contributor

Summary

Fixes #2308 by avoiding format: null in session.update payloads when attaching to an existing SIP call via call_id.

In call-attach mode, input_audio_format / output_audio_format can be intentionally omitted. The SDK was still serializing these as explicit null values, which can cause the Realtime API to reject the update with errors like:

  • Invalid type for 'session.audio.input.format': expected an object, but got null

What changed

  • In OpenAIRealtimeWebSocketModel._get_session_config:
    • only set audio.input.format if a non-null format can be converted.
    • only set audio.output.format if a non-null format can be converted.
  • Added regression tests to verify:
    • with call_id and no explicit formats, update payload omits both format fields.
    • with explicit formats, payload still includes normalized audio/pcmu fields.

Validation

  • uv run --with ruff ruff check src/agents/realtime/openai_realtime.py tests/realtime/test_realtime_model_settings.py
  • uv run --with mypy mypy src/agents/realtime/openai_realtime.py tests/realtime/test_realtime_model_settings.py
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --with pytest pytest -q tests/realtime/test_realtime_model_settings.py
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --with coverage --with pytest coverage run -m pytest -q tests/realtime/test_realtime_model_settings.py

Changed executable lines coverage (local):

  • src/agents/realtime/openai_realtime.py: 100% (6/6)

@seratch seratch merged commit f1d8923 into openai:main Feb 10, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool calling is not working with Realtime Agent

2 participants