Skip to content

test(inference): pin pooled TTS socket reuse across a drained session - #2153

Closed
toubatbrian wants to merge 1 commit into
brian/fix-tts-multi-donefrom
brian/fix-tts-pool-reuse-regression
Closed

test(inference): pin pooled TTS socket reuse across a drained session#2153
toubatbrian wants to merge 1 commit into
brian/fix-tts-multi-donefrom
brian/fix-tts-pool-reuse-regression

Conversation

@toubatbrian

Copy link
Copy Markdown
Contributor

Stacked on #2146.

Problem

#2146 made a run end on a quiet timeout rather than on the done, and #2144 gates returning the socket to ConnectionPool on having reached that end. Those two rules meet in one place, so the pool either reuses its socket on every reply or on none — and nothing pinned which. A suspected collapse to a fresh gateway handshake per reply (~157ms on the voice path) was indistinguishable from correct behaviour by reading the code.

Fix

Test only, no behaviour change. Counts gateway handshakes over a conversation instead of asserting on audio alone.

Testing

On this branch: 5 clean multi-generation replies dial once; a session dropped mid-synthesis dials twice, so the eviction that fixes the misattribution bug is unaffected. Deleting sessionDrained = true from the quiet-timeout exit turns the first case into 5 dials for 5 replies, so the test fails closed on exactly the regression it is meant to catch.

Cross-checked against the production gateway rather than only the fake one: inworld/inworld-tts-2 answers one session.flush with 3 done events and then goes quiet with no trailing event, and over 5 replies both main and this branch dial once — reuse is intact on the stack, not near-zero.

Stacked PRs get no CI, so run locally: pnpm build, pnpm test agents (115 files, 1508 passed), pnpm format:check, pnpm lint all pass.

Made with Cursor

@toubatbrian
toubatbrian requested a review from a team as a code owner July 28, 2026 19:50
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9fb85dd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@toubatbrian
toubatbrian force-pushed the brian/fix-tts-pool-reuse-regression branch from cb8fa52 to c9af8c7 Compare July 28, 2026 23:57
Recycling the gateway socket now depends on two rules meeting: a run ends on a
quiet timeout rather than on the `done`, and the socket is only returned once
that end is reached. Nothing pinned which exit sets that, so the pool would
either reuse on every reply or on none with no test telling the two apart.

Counts gateway handshakes instead: a conversation of clean multi-generation
replies has to dial once, and a session dropped mid-synthesis has to dial again.

Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian
toubatbrian force-pushed the brian/fix-tts-pool-reuse-regression branch from c9af8c7 to 9fb85dd Compare July 29, 2026 01:16
@toubatbrian

Copy link
Copy Markdown
Contributor Author

Closing with #2146. This pins the drain semantics that #2146 introduces — without that PR there is no quiet-timeout end for a run, so there is nothing here to pin. Pool reuse on its own stays covered by tts_pool_reuse.test.ts on #2144.

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.

1 participant