Skip to content

FIX: omit unset speed from OpenAITTSTarget requests - #4488

Merged
Roman Lutz (romanlutz) merged 6 commits into
microsoft:mainfrom
AnvitDevadiga:fix/tts-omit-unset-speed
Nov 22, 2026
Merged

Roman Lutz (romanlutz) merged 6 commits into
microsoft:mainfrom
AnvitDevadiga:fix/tts-omit-unset-speed

Conversation

@AnvitDevadiga

Copy link
Copy Markdown
Contributor

Description

Fixes #4485. OpenAITTSTarget passed speed=body_parameters.get("speed") to audio.speech.create, so an unset speed reached the SDK as an explicit None, which it serializes as JSON null. gpt-4o-mini-tts rejects that with Invalid type for 'speed'.

  • Pass speed to the SDK only when it is set.
  • Add a unit test that the SDK call gets no speed argument when speed is None (the existing test covers the set case).

The SDK serializes an explicit speed=None as JSON null, which
gpt-4o-mini-tts rejects with a 400. Pass speed only when it is set.

Fixes microsoft#4485
Copilot AI balanced review requested due to automatic review settings November 21, 2026 03:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An existing backend test still requires the omitted speed keyword, so its assertion conflicts with the updated TTS request contract.

1 open issue
What changed in this PR

Fixes #4485 by preventing PyRIT’s OpenAITTSTarget from sending speed=null, which gpt-4o-mini-tts rejects.

Changes:

  • Omit the SDK’s speed argument when unset, while preserving configured values.
  • Add a regression test asserting that default-speed calls omit the argument.
File Description
tests/​unit/​prompt_target/​target/​test_tts_target.py Adds coverage for omitting unset speed.
pyrit/​prompt_target/​openai/​openai_tts_target.py Passes speed to the SDK only when configured.

Review effort: Balanced

The capability probe builds a TTS target without speed, so the SDK call
no longer receives a speed keyword.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new async test must be renamed to test_tts_send_prompt_omits_unset_speed_async to satisfy the mandatory _async suffix convention.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Low severity Add required _async suffix to the test name

tests/​unit/​prompt_target/​target/​test_tts_target.py:254

Rename this new async test to test_tts_send_prompt_omits_unset_speed_async to satisfy the mandatory _async suffix convention for async functions.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change that omits unset TTS speed values while preserving explicitly configured values.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

speed now reaches the SDK only via optional_parameters; the copy in
body_parameters was never read.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 22, 2026
Merged via the queue into microsoft:main with commit 2fc682c Nov 22, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: OpenAITTSTarget sends speed=null, which gpt-4o-mini-tts rejects

3 participants