Skip to content

fix: avoid fatal status for normal Rime TTS shutdown - #2407

Merged
wangyoucao577 merged 2 commits into
mainfrom
docs/tts-review-metadata
Nov 16, 2026
Merged

wangyoucao577 merged 2 commits into
mainfrom
docs/tts-review-metadata

Conversation

@YiminW

@YiminW YiminW commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Rime TTS reports code -1000 when its websocket closes normally during extension shutdown, which misclassifies a normal close as an unrecoverable error.

Goal

Suppress the fatal disconnect callback for deliberate shutdown and bump the Rime TTS package version to 0.4.15.

Design rationale

The websocket processing cleanup path now reports fatal disconnect only when the session is not already closing. Normal shutdown is handled by the caller and does not emit -1000.

Validation

  • Version consistency check passed for manifest.json and pyproject.toml.
  • git diff --check passed.
  • Extension tests could not start locally because ten_runtime is unavailable.

@github-actions

Copy link
Copy Markdown

[P2] Report a nonfatal disconnect when cancellation replaces the socket
ai_agents/agents/ten_packages/extension/rime_tts/rime_tts.py:204

_session_closing is also set by cancel(), which cancel_tts() calls on a flush. That path creates a replacement synthesizer directly, without the nonfatal disconnect reported by reset_synthesizer(). When the old channel tasks exit, this guard now suppresses the only disconnect callback, so observers can see the old connection as connected until the replacement reports its state, with no disconnect for the closed socket. Report a nonfatal disconnect before starting the replacement, with ownership protection against late callbacks; keep fatal reporting for unexpected termination.

[P2] Exercise the real WebSocket shutdown and replacement paths
ai_agents/agents/ten_packages/extension/rime_tts/rime_tts.py:204

The local lifecycle tests cover the replacement helper, while the request and flush tests mock RimeTTSClient; none runs _process_websocket() through deliberate close, flush cancellation, or unexpected termination. Consequently they cannot catch either a missing disconnect or a fatal disconnect during normal shutdown. Add deterministic fake-socket tests that assert callback codes and ordering for shutdown, flush/replacement, and an unexpected failure, including a subsequent successful connection. This is part of the required WebSocket test matrix for a touched TTS extension.

[P2] Assert audio-end accounting across terminal paths
ai_agents/agents/ten_packages/extension/rime_tts/manifest.json:4

The local suite reads request_total_audio_duration_ms in its flush test but only prints the calculated and reported values; it never compares them, and no test asserts request_event_interval_ms. Thus incorrect emitted-PCM duration or elapsed event interval can pass on success, partial failure, interruption, and no-audio termination. Add deterministic tests using known emitted PCM and a controlled clock, asserting both fields and exactly-once completion for those paths, as required by the TTS review test matrix.

[P2] Register an independent Rime TTFB reference
ai_agents/agents/ten_packages/extension/rime_tts/manifest.json:4

Neither guarder TTFB hook registry includes rime_tts, so install_ttfb_reference yields None and cannot independently compare the extension's TTFB metric against the first text send and first nonempty audio arrival. Add and register a Rime WebSocket observer with request/connection isolation and protocol tests, then verify it with a reference-enabled run. The TTS review baseline requires this hook for every touched extension.

@github-actions

Copy link
Copy Markdown

TTS review (rime_tts)

[P2] Add a regression test for the shutdown disconnect path
ai_agents/agents/ten_packages/extension/rime_tts/rime_tts.py:204
The fix changes which terminal path reports FATAL_ERROR (-1000) from the
`_process_websocket` finally block, but no extension-local test covers it, and
the PR says the suite could not run locally. tests/test_connection_lifecycle.py
only covers the replacement path (`suppress_connection_callbacks_for_replacement`).
Add deterministic tests around a fake `websockets.connect` that check two things.
First, `RimeTTSynthesizer.close()` and `RimeTTSClient.close()` (the on_stop path)
make no `on_connection_disconnected` call with code -1000. Second, an
unexpected end with `_session_closing == False`, such as the retry limit being
exceeded in `_process_ws_exception`, still reports -1000. Without the second
test, a later change could turn this guard into a blanket suppression and hide
real fatal disconnects.

Behavior note (not a defect): _session_closing is also set by cancel(), which runs on flush and RimeTTSClient.cancel(). So the guard also stops the old cancelled synthesizer from sending -1000 through the shared callback after a flush. That looks correct, because flush is not a fatal condition. The PR description only mentions on_stop, so please list flush as covered too and include it in the test above.

Version metadata: manifest.json and pyproject.toml are both at 0.4.15, which is a proper patch bump.

Outside the TTS extension

  • .agents/skills/ten-tts-review/SKILL.md and references/common.md add new review policy (release-bump rules and import/dependency reconciliation). The PR title and description don't mention these changes, and they are unrelated to the Rime fix. Please move them into a separate docs:/chore: PR, or at least describe them here, so reviewers of the skill policy see them.

@wangyoucao577
wangyoucao577 merged commit f25fca4 into main Nov 16, 2026
55 of 70 checks passed
@wangyoucao577
wangyoucao577 deleted the docs/tts-review-metadata branch November 16, 2026 10:50
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