Skip to content

refactor(tts): reuse selected speech descriptors during preparation - #188280

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/speech-s17-selected-descriptor
Oct 30, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/speech-s17-selected-descriptor

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Related: #188252

What Problem This Solves

Speech voice/model resolution re-looks up the provider descriptor already selected by its caller.

User Impact

No intended user-visible behavior or shipped public-contract change.

Why This Change Was Made

Pass that selected descriptor through the private resolution path and remove the extra wrapper. Keep public getResolvedSpeechProviderConfig, canonical aliases, config selection, auth and resource behavior unchanged.

13 net production lines removed; tests and docs unchanged.

Evidence

@vincentkoc vincentkoc self-assigned this Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review October 30, 2026 11:19
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR passes the selected speech provider descriptor into configuration preparation and removes a redundant private ID-based forwarding function.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported simplification with passing exact-head validation and no actionable findings; direct runtime evidence for the changed TTS path is not supplied.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal refactor is outside the ordinary contributor proof gate; supplied evidence establishes source inspection and passing exact-head CI, without claiming a live buffered, streaming, or telephony synthesis run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Partial
Reason: The maintainer-authored direction supports removing redundant integration glue, and this patch reduces it while preserving observable contracts; it correctly uses Related for the broader campaign.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it is a useful maintainer-authored simplification with no actionable correctness or security findings, and the exact-head CI gate passes.

Priority: P3
Reviewed head: cb10d8e0375859a0c63429c96c5f47a237d89d79

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped-entry-point trace demonstrates synthesis after this refactor; the ordinary contributor proof gate does not apply to this maintainer-authored PR.
Agent review details

How this fits together

Buffered, streaming, and telephony speech requests share provider-attempt preparation, which combines provider descriptors, configuration, voice models, and persona settings before synthesis.

flowchart TD
A[Speech request] --> B[Owned provider registry]
B --> C[Selected provider descriptor]
C --> D[Configuration preparation]
D --> E[Readiness and synthesis]
E --> F[Audio and attempt metadata]
Loading

Technical review

Best possible solution:

Retain the existing configuration owner, pass it the selected descriptor, and preserve public ID-based lookup and request-owned resource lifetimes.

Do we have a high-confidence way to reproduce the issue?

This PR reports redundant internal work rather than a user-facing failure; source inspection confirms the repeated provider lookup on the base.

Is this the best way to solve the issue?

The patch is the smallest coherent reduction: the existing resolver already accepts a descriptor, the sole internal caller supplies it, and no new state or competing owner is introduced.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5eda46670486.

Provenance checked

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff reuses the selected descriptor, migrates its sole caller, and preserves the public ID-based lookup signature. (src/tts/tts-provider-resolution.ts:284, cb10d8e03758)
  • Existing configuration owner retained: resolveLazyProviderConfig already accepts a descriptor and retains alias-keyed configuration, explicit-model precedence, voice-model defaults, and provider timeout handling. (src/tts/tts-provider-resolution.ts:174, cb10d8e03758)
  • Request ownership preserved: The selected descriptor comes from the request-owned registry; acquisition, readiness, synthesis, and resource release remain with their existing owners across buffered, streaming, and telephony callers. (src/tts/tts-synthesis-support.ts:302, cb10d8e03758)
  • Current main still contains the redundant path: The affected files on fetched main match the introduction base, so this simplification is not already implemented there. (src/tts/tts-provider-resolution.ts:277, 5eda46670486)
  • Maintainer-approved campaign scope: Refactor inference contracts and remove duplicate integration glue #188252 requests focused inference-contract and forwarding reductions while preserving lifecycle and shipped compatibility; this PR implements a narrow part of that campaign.
  • Exact-head validation: GitHub reports a clean merge state, passing CI, dependency-review, and security-sensitive-review statuses for the reviewed head; paginated check inspection found no pending or failed runs. (cb10d8e03758)

Likely related people:

  • Vincent Koc: Raw commit 9fc1f0b adds packages/speech-core/src/tts-synthesis-support.ts:271 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9fc1f0b96bb8; files: packages/speech-core/src/tts-synthesis-support.ts)

PR surface

Source -13. Total -13 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 13 26 -13
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 13 26 -13

Root-cause cluster

Relationship: partial_overlap
Canonical: #188252
Summary: This PR implements the speech-descriptor preparation portion of the broader inference-contract cleanup campaign.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P3: This is a focused internal simplification with no intended user-visible behavior change or established urgent defect.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a focused internal simplification with no intended user-visible behavior change or established urgent defect.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 30, 2026, 7:35 AM ET / 11:35 UTC.

@vincentkoc
vincentkoc merged commit 00ebec0 into main Oct 30, 2026
205 checks passed
@vincentkoc
vincentkoc deleted the refactor/speech-s17-selected-descriptor branch October 30, 2026 12:38
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

NEXTAltair added a commit to NEXTAltair/openclaw that referenced this pull request Nov 10, 2026
目的:
プラグインがプロバイダーに合わせた発話ガイダンスを組めるよう、
現在有効な一次 TTS プロバイダー・モデル・ペルソナを合成せずに取得する。

変更:
api.runtime.tts.prepareSpeechPromptContext を追加する。通常の TTS と同じ
ユーザー設定、agent / channel / account 層、ペルソナ binding、
モデル解決を使い、auto オフ・テキスト上書き不許可・一次 binding 不可は
ready: false を返す。合成、fallback、credential、音声ファイル、
テキスト書き換えは行わず、プロバイダー設定や秘密情報も返さない。
runtime facade は選択中 registry とプラグインの寿命に束縛する。

検証:
tts-prompt-context と registry.runtime-config のテストが通過。

rebase 時のコンフリクト解決 (onto 57fd13e, 元コミット 89d6eb7578c):
- 上流 329a56d (openclaw#178002) が resolveReadySpeechProvider を単一呼び出しとして
  フォールバックループ内のクロージャへ畳み込んだ。本コミットで
  tts-prompt-context.ts が2つ目の呼び出し元になるため、export した関数として
  1か所に戻し、ループ側のクロージャはその呼び出しに置き換えた。
  畳み込みで外れていた VoiceModelRef の import も戻した
- 上流 b3d00c9 (openclaw#183424) が types-core.ts の TTS 型エイリアスを
  TtsRuntimeApi[...] の直接参照へ畳んだ。エイリアスは復活させず、
  prepareSpeechPromptContext も同じ直接参照の形で追加

rebase 時のコンフリクト解決 (onto 258d034, 元コミット 892cff4dd4d):
- 上流 00ebec0 (openclaw#188280) が getResolvedSpeechProviderConfigForVoiceModel の
  引数を providerId から provider (SpeechProviderPlugin) へ変えた。export 済みの
  resolveReadySpeechProvider をその形へ合わせ、ループ側は本コミットの呼び出しを採用
- 上流 e1f1a79 (openclaw#188398) が prepareTtsRequest を runtime-api.ts から外し、
  loadTtsRequestRuntime の読み込み先を tts-request.js へ変えて、knip の
  動的 consumer 追跡に lazy TTS メソッドを登録した。そのままでは
  prepareSpeechPromptContext が tts-request.js に無く実行時に解決できないため、
  同じ方式で tts-prompt-context.js 専用の lazy loader / binder を足し、
  型も typeof import(tts-prompt-context.js) の直接参照にし、
  knip-dynamic-consumers.mjs に consumer を登録した。runtime-api.ts からの
  再 export は上流の方針どおり置かず、test-support は直接 import する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant