fix(metrics): re-arm turn guard in anchorUserSpeechStart — pipeline turns emit no metrics/transcript#125
Merged
Conversation
…rns) Pipeline-mode user→agent turns after the firstMessage emitted no per-turn metrics and no live dashboard transcript. anchorUserSpeechStart() re-opens a turn (sets _turnStart) but did not clear the _turnAlreadyClosed guard left set by the previous turn's recordTurnComplete. startTurnIfIdle() is a no-op once _turnStart is non-null, so the guard never re-armed, and every subsequent recordTurnComplete() short-circuited to null — dropping per-turn latency/cost AND the live SSE turn_complete that feeds the dashboard transcript (it only showed up after call end). Fix: clear _turnAlreadyClosed in anchorUserSpeechStart(), mirroring startTurn(). The method already no-ops after commit, so this only re-arms at the start of a fresh uncommitted turn — the post-commit barge-in guard is untouched. Parity: identical one-line fix in both SDKs. No version bump (lands under ## Unreleased; release later). package-lock version synced 0.6.2 -> 0.6.3 to match package.json on main (stale lockfile). Tests: new metrics-turn-rearm tests (RED before, GREEN after) in both SDKs. Python 1940 pass, TypeScript 1555 pass, lint + build clean.
90de711 to
2ab4de6
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One-line bug in both SDKs. In pipeline mode, every user→agent turn after the
firstMessageemitted no per-turn metrics and no live dashboard transcript. Root cause:anchorUserSpeechStart()re-opens a turn (sets_turnStart) but did not clear the_turnAlreadyClosedguard left set by the previous turn'srecordTurnComplete. SincestartTurnIfIdle()no-ops once_turnStartis non-null, the guard never re-armed, so every subsequentrecordTurnComplete()short-circuited tonull.emitTurnMetrics(null)then bails beforeMetricsStore.recordTurn(), which is what broadcasts the SSEturn_completeevent the dashboard transcript subscribes to — so both the metrics and the live transcript share that dropped path (one root cause, not two bugs).Symptoms (real Twilio + Deepgram + Cerebras + Inworld pipeline call)
—/0 ms; COST panel empty per turn.[event] metricsfired (turn 0 =firstMessage); the real user turns emittedtranscriptbut nometrics.call_endmetrics.turnshad a single element despite 8 transcript entries.Fix
Clear the guard in
anchorUserSpeechStart(), mirroring whatstartTurn()already does:libraries/typescript/src/metrics.ts→this._turnAlreadyClosed = false;libraries/python/getpatter/services/metrics.py→self._turn_already_closed = FalseSafe:
anchorUserSpeechStart()no-ops once the turn is committed (_turnCommittedMono/_turn_committed_monoguard), so the flag is only re-armed at the start of a fresh, uncommitted turn — never the post-commit barge-in path the guard protects.Breaking change?
No. Internal metrics-accumulator fix, no public API change.
Versioning
No version bump — lands under
## Unreleased→### Fixed. Release rolls it into the next version later (not blocking). (package-lock.jsonversionsynced 0.6.2 → 0.6.3 to matchpackage.jsonon main — stale lockfile, not a bump.)Test plan
metrics-turn-rearmtests (TS + Python) — fail before the fix (recordTurnCompletereturns null), pass after.pytest tests/ -m "not soak"→ 1940 passed.npm test→ 1555 passed;npm run lint+npm run buildclean.