Skip to content

fix(realtime): skip invalid input_text parts in user input conversion#3243

Merged
seratch merged 1 commit intoopenai:mainfrom
adityasingh2400:fix/realtime-input-text-skip-invalid
May 8, 2026
Merged

fix(realtime): skip invalid input_text parts in user input conversion#3243
seratch merged 1 commit intoopenai:mainfrom
adityasingh2400:fix/realtime-input-text-skip-invalid

Conversation

@adityasingh2400
Copy link
Copy Markdown
Contributor

Summary

When a RealtimeModelSendUserInput event carries a dict user_input whose content includes an input_text part with a missing or non-string text field, _ConversionHelper.convert_user_input_to_conversation_item currently appends a Content(type="input_text", text=None) item. The realtime API rejects such payloads.

This change skips those parts entirely, matching the existing forward-compat behaviour for input_image with an invalid image_url. Only well-formed parts reach the wire.

Test plan

  • Added test_convert_user_input_dict_skips_invalid_input_text_parts covering missing-text and non-string-text cases plus a valid sibling (only the valid one survives).
  • pytest tests/realtime — 233 passed.
  • ruff check clean on touched files.

Previously, when a dict user_input contained an input_text part with a
missing or non-string `text` field, the conversion appended a
Content(type="input_text", text=None) item, producing a payload the
realtime API rejects. Skip those parts (matching the existing
behavior for input_image with an invalid image_url) so only valid
content reaches the wire.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@seratch
Copy link
Copy Markdown
Member

seratch commented May 8, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@seratch seratch added this to the 0.17.x milestone May 8, 2026
@seratch seratch merged commit 62f9416 into openai:main May 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:realtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants