Skip to content

fix(tts): release telephony provider resources after synthesis - #143065

Merged
steipete merged 1 commit into
mainfrom
codex/telephony-provider-resources
Sep 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/telephony-provider-resources

Conversation

@steipete

@steipete steipete commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #140674

What Problem This Solves

Fixes an issue where telephony speech requests could leave newly loaded plugin resources open, or lose managed provider resources while configuration, preparation, or synthesis was still running.

Why This Change Was Made

Own speech registrations for the complete finite telephony request, reusing the existing capability acquisition machinery. Share the canonical singular lookup policy while keeping configured catalogs separate from direct preference and override lookups; direct-only providers must not become automatic fallbacks.

Each attempt prepares its applicable configuration view. If runtime configuration refreshes while a primary provider is pending, fallback resolves the updated provider configuration while preserving the initial fallback order. Existing raw hosts, synchronous public SDK signatures, buffered synthesis and streaming retain their current contracts.

User Impact

Telephony PCM and result metadata remain usable after cleanup. Normal provider failures remain structured results. Persona selection, voice overrides, timeouts, aliases and fallback ordering are preserved.

Evidence

  • Original production failed six native resource cases; the raw-host control passed. Eight final native cases now pass, including a configuration-refresh comparison that first exposed and then repaired stale fallback selection in the intermediate candidate.
  • 265 speech, VoiceCall, capability and media siblings passed. Full eight-path checks, independent Codex review through P2 and ordinary build passed; build time was 263 seconds.
  • The actual compiled public telephony runtime passed success/failure/success in cold, managed and raw modes. Genuine 8 kHz PCM was saved, decoded and round-tripped after cleanup. SQLite close markers, read-only reopening and every managed process-tree exit were verified.
  • Illustrative call timings were cold 34.81/28.98/12.44 ms; managed 7.43/5.05/1.31 ms; raw 7.44/4.10/2.02 ms. These are three synthetic samples per mode, not a statistical speedup claim.
  • No carrier/vendor request or real credentials were used. Upstream VoiceCall request preparation and escaping streams are separate ownership boundaries. All eight candidate files are byte-identical after rebasing onto current main.

The branch is refreshed onto the independent Telegram fixture repair in #143197. Post-refresh composition passed 111 tests covering native telephony resources/personas, capability resolution and installed-provider compatibility. The incoming provider-enablement predicate is scoped to each synchronous resolution operation; the ownership change continues to refresh configuration between attempts.

@clawsweeper

clawsweeper Bot commented Sep 9, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L maintainer Maintainer-authored PR labels Sep 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 12:24 PM ET / 16:24 UTC (Revision 3).

ClawSweeper review

What this changes

Keeps speech-provider resources alive through telephony configuration, synthesis, and audio-result processing, then releases them while preserving provider selection.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main still lacks finite telephony resource ownership, and the aggregate PR explicitly delegates this work here. No blocking introduced defect was found. Likely related people: steipete, a medium-confidence routing candidate from prior area work.

Priority: P2
Reviewed head: c277f1201864770da492a5a84ac39ed655acb4e2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent lifecycle repair with meaningful native-resource coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied Repository State identifies maintainer-authored work, so the external-contributor gate does not apply. Its body reports compiled telephony calls exercising native resource cleanup and usable PCM afterward; those observations were not independently rerun.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied Repository State identifies maintainer-authored work, so the external-contributor gate does not apply. Its body reports compiled telephony calls exercising native resource cleanup and usable PCM afterward; those observations were not independently rerun.
Evidence reviewed 9 items Current main still needs this repair: The fetched main entrypoint calls resolveTtsRequestSetup and executeTtsProviderAttempts without an acquisition lifetime surrounding the operation.
Latest release comparison: v2026.9.3 and fetched main both identify telephony entrypoint blob 3441b2ea147e1aa4b402c1de813c18d5054022fc; the reviewed head has a different blob containing the ownership wrapper.
Introduced lifetime and selection boundary: The new request owner uses existing capability acquisition, prepares separate direct-lookup and catalog views, and refreshes the applicable configuration before each attempt. Shared synchronous callers retain their default registry behavior.
Findings None None.
Security None None.

How this fits together

Telephony text-to-speech receives text, configuration, and voice preferences through OpenClaw’s plugin runtime. It selects speech providers and returns PCM audio and metadata to calling integrations.

flowchart TD
  A[Text and voice preferences] --> B[Telephony request]
  B --> C[Acquire provider resources]
  C --> D[Select provider and fallback order]
  D --> E[Prepare and synthesize speech]
  E --> F[Read PCM and result metadata]
  F --> G[Release owned resources]
  G --> H[Return audio or structured failure]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +283, Tests +429, Docs +8. Total +720 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 413 130 +283
Tests 2 431 2 +429
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 852 132 +720

Review metrics

Metric Value Why it matters
Production versus test growth Production net +283 lines; tests/support net +429 lines Production growth implements retained lookup views and per-attempt configuration preparation; native-resource tests protect the resulting lifecycle and selection contracts.

Technical review

Best possible solution:

Use one finite telephony lifetime that retains selected providers through completed audio processing while preserving caller-owned synchronous and streaming lifetimes.

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

Yes, source inspection establishes a focused path: a telephony provider holding native resources can be loaded without finite cleanup or lose its managed parent during synthesis. The new tests exercise those boundaries; this review did not execute them.

Is this the best way to solve the issue?

Yes, extending the existing acquisition owner and canonical lookup policy addresses the resource lifetime without creating a competing provider-selection policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs bounded telephony provider leaks and premature cleanup without evidence of a widespread urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied Repository State identifies maintainer-authored work, so the external-contributor gate does not apply. Its body reports compiled telephony calls exercising native resource cleanup and usable PCM afterward; those observations were not independently rerun.

Evidence

What I checked:

  • Current main still needs this repair: The fetched main entrypoint calls resolveTtsRequestSetup and executeTtsProviderAttempts without an acquisition lifetime surrounding the operation. (src/tts/tts-telephony.ts:15, a57c799c86df)
  • Latest release comparison: v2026.9.3 and fetched main both identify telephony entrypoint blob 3441b2ea147e1aa4b402c1de813c18d5054022fc; the reviewed head has a different blob containing the ownership wrapper. (src/tts/tts-telephony.ts:15, 1391f7cd2d40)
  • Introduced lifetime and selection boundary: The new request owner uses existing capability acquisition, prepares separate direct-lookup and catalog views, and refreshes the applicable configuration before each attempt. Shared synchronous callers retain their default registry behavior. (src/tts/tts-synthesis-support.ts:282, c277f1201864)
  • Resource regression coverage: Read all eight native-resource cases covering cold success/failure, managed release during configuration/preparation, raw ownership, direct-only fallback exclusion, sequential requests, and refreshed fallback configuration. These exercise real loader registrations and SQLite resources; tests were not executed during this review. (src/tts/tts-telephony.resources.test.ts:186, c277f1201864)
  • Documented compatibility boundary: The added contract limits automatic ownership to finite telephony operations, preserves raw-host and synchronous lookup lifetimes, excludes streaming, and requires returned audio to survive registration disposal. Public docs: docs/plugins/sdk-overview/host-hooks.md. (docs/plugins/sdk-overview/host-hooks.md:64, c277f1201864)
  • Captured runtime evidence: The supplied primary body, sourceRevision 31dcb160d1b044ecf072c3c7e38e29752d462e11aaef80fa2b35c5ffd00b6a54, reports compiled public telephony success/failure/success in cold, managed, and raw modes, usable 8 kHz PCM after cleanup, SQLite close/reopen checks, and joined managed processes. It also reports 265 sibling tests and a completed build. These are author-reported observations, not reviewer execution. (c277f1201864)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-09T11:14:21.830Z sha e6559c9 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-09T11:37:29.960Z sha e6559c9 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 9, 2026 11:32
@steipete
steipete force-pushed the codex/telephony-provider-resources branch from e6559c9 to c277f12 Compare September 9, 2026 16:17
@steipete
steipete merged commit d8420e5 into main Sep 9, 2026
181 checks passed
@steipete
steipete deleted the codex/telephony-provider-resources branch September 9, 2026 17:27
@steipete

steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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