Skip to content

fix(openai-tts)!: prefer params url over top-level url - #2402

Merged
wangyoucao577 merged 3 commits into
mainfrom
fix/openai-tts-params-url-precedence
Nov 13, 2026
Merged

wangyoucao577 merged 3 commits into
mainfrom
fix/openai-tts-params-url-precedence

Conversation

@wangyoucao577

@wangyoucao577 wangyoucao577 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

When both params.url and a top-level url are configured, OpenAI TTS currently sends requests to the top-level address. Prefer a nonblank string in params.url, then fall back to top-level url, params.base_url plus /audio/speech, and the default OpenAI endpoint.

Preserve the existing fallback for missing, empty, whitespace-only, and non-string params.url values. Update the endpoint documentation and add HTTP transport tests that verify the selected POST URL, PCM response, authentication, and removal of endpoint-only parameters from the request body.

Bump the extension version from 0.6.10 to 0.7.0 in both manifest.json and pyproject.toml. This is a breaking configuration change: when both URLs are set and params.url is a nonblank string, requests now use params.url. Deployments that relied on the top-level URL taking precedence must update their configuration before upgrading.

Declare the direct runtime imports (certifi, httpcore, httpx, and pydantic), enable the HTTP/2 extra required by the client, and add the test imports as an optional test dependency group.

Validation:

  • Python 3.10 dependency resolution and imports passed in a fresh virtual environment, including HTTP/2 client initialization.
  • Extension standalone suite in that environment: 36 passed.
  • task check: 1,716 Python files pass.
  • Extension Pylint with the standalone TEN dependencies: 10.00/10.
  • Live-provider guarder tests were not run because this environment has no OpenAI TTS credentials.

@github-actions

Copy link
Copy Markdown

[P2] Cover exact audio-end accounting across terminal paths
ai_agents/agents/ten_packages/extension/openai_tts2_python/tests/test_params.py:375

The new transport test stops at client response events, and the existing local suite checks audio duration only on flush with a 10 ms tolerance; it never asserts request_event_interval_ms. Consequently, incorrect duration or interval values on success, partial-audio error, flush, or empty output can pass this extension's required test gate. Add extension-level tests using known PCM and a controlled clock that assert both fields exactly and verify at most one end event for each path.

[P2] Exercise interrupted HTTP streams and recovery
ai_agents/agents/ten_packages/extension/openai_tts2_python/tests/test_params.py:351

The added mock transport always returns a complete, successful body. The local suite does not cover a stream error after partial audio, cancellation while waiting for the first byte, or PCM samples split across HTTP chunks; the existing recovery test fails before the response begins. These cases can leave a request unfinished, emit stale audio, or lose samples without a failing test. Add controlled streaming responses for these cases and assert response closure, emitted bytes and terminal events, plus a successful following request.

[P2] Measure TTFB independently at the HTTP boundary
ai_agents/agents/ten_packages/extension/openai_tts2_python/config.py:71

The registered OpenAI guarder hook wraps OpenAITTSClient.get and records audio only after that production adapter yields its decoded/aligned response; it also records text at the adapter call rather than at the HTTP send boundary. An adapter buffering or decoding delay is therefore included in the reference itself, so the comparison cannot independently detect it. Provide an HTTP send/first nonempty response-byte observer with request isolation and focused tests, then validate it with a reference-enabled run. The required independent hook applies to existing extensions touched by this PR.

@wangyoucao577
wangyoucao577 marked this pull request as ready for review November 13, 2026 00:47
@github-actions

Copy link
Copy Markdown

[P2] Cover non-audio HTTP responses and transient service errors
ai_agents/agents/ten_packages/extension/openai_tts2_python/tests/test_params.py:351

The new transport test exercises only a 200 response with PCM, while the existing local error tests cover a 401 and a connection failure. There is no extension-level coverage for an empty response, a 200 response with an unexpected content type, or a 429/5xx response. In particular, the client currently streams any 200 body as PCM without checking its content type, so a proxy's HTML error page can reach the audio output without a test failing. Add deterministic HTTP response tests that assert no non-audio bytes are emitted, transient errors are reported correctly, and a subsequent request succeeds. This is part of the required local HTTP test matrix for touched TTS extensions.

@wangyoucao577 wangyoucao577 changed the title fix(openai-tts): prefer params url over top-level url fix(openai-tts)!: prefer params url over top-level url Nov 13, 2026
@github-actions

Copy link
Copy Markdown

[P2] Cover appended and interleaved request input
ai_agents/agents/ten_packages/extension/openai_tts2_python/tests/test_params.py:351

The new transport test calls the client with one complete text, and the existing state-machine test sends two separate inputs that are each already final. No local test appends text to an existing request or interleaves segments from different request IDs. A regression that finalizes on the first segment, loses the later text, or associates audio and terminal events with the wrong request would therefore pass the required TTS lifecycle gate. Add an extension-level test with non-final and final segments for interleaved request IDs, asserting the synthesized text, audio ownership, and one correctly ordered terminal event per request.

@wangyoucao577
wangyoucao577 merged commit 619abef into main Nov 13, 2026
35 of 36 checks passed
@wangyoucao577
wangyoucao577 deleted the fix/openai-tts-params-url-precedence branch November 13, 2026 01:46
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.

2 participants