-
Notifications
You must be signed in to change notification settings - Fork 329
fix(voice): expose speech handle generation errors #1965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@livekit/agents': patch | ||
| --- | ||
|
|
||
| Expose speech generation errors via `SpeechHandle.exception()`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,6 +243,12 @@ export class RunResult<T = unknown> { | |
| return; | ||
| } | ||
|
|
||
| const speechError = this.lastSpeechHandle.exception(); | ||
| if (speechError) { | ||
| this.doneFut.reject(speechError); | ||
| return; | ||
| } | ||
|
Comment on lines
+246
to
+250
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Error propagation only checks the last-completing speech handle In Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| const finalOutput = this.lastSpeechHandle._maybeRunFinalOutput; | ||
| if (finalOutput instanceof Error) { | ||
| this.doneFut.reject(finalOutput); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Reachability of try/catch depends on ThrowsPromise.race semantics
In
realtimeReplyTask,waitIfNotInterruptedatagents/src/voice/agent_activity.ts:3900racesgenerationPromiseagainst the interrupt future usingThrowsPromise.race. IfgenerationPromiserejects andThrowsPromise.racepropagates that rejection (like standardPromise.race), the error would throw from line 3900 and never reach the try/catch at lines 3907-3915. The try/catch is only reachable ifThrowsPromise.racetreats rejections as settled values rather than propagating them. The existing pre-PR code also didawait generationPromiseafterwaitIfNotInterruptedwithout a try/catch, suggestingThrowsPromisedoes NOT propagate rejections fromrace— otherwise the old code would have had unhandled errors in production. This is worth confirming against the@livekit/throws-transformerimplementation.(Refers to lines 3900-3915)
Was this helpful? React with 👍 or 👎 to provide feedback.