-
Notifications
You must be signed in to change notification settings - Fork 88
fix: address review feedback for calls feature #5255
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
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 |
|---|---|---|
|
|
@@ -70,6 +70,10 @@ class CallStartTool implements Tool { | |
|
|
||
| const callContext = input.context as string | undefined; | ||
|
|
||
| // Create session outside the try block so it's available in the catch block | ||
| // for marking as failed if the provider call fails. | ||
| let sessionId: string | null = null; | ||
|
|
||
| try { | ||
| const config = getTwilioConfig(); | ||
| const provider = new TwilioConversationRelayProvider(); | ||
|
|
@@ -81,6 +85,7 @@ class CallStartTool implements Tool { | |
| toNumber: phoneNumber, | ||
| task: callContext ? `${task}\n\nContext: ${callContext}` : task, | ||
| }); | ||
| sessionId = session.id; | ||
|
|
||
| log.info({ callSessionId: session.id, to: phoneNumber, task }, 'Initiating outbound call'); | ||
|
|
||
|
|
@@ -111,6 +116,16 @@ class CallStartTool implements Tool { | |
| } catch (err) { | ||
| const msg = err instanceof Error ? err.message : String(err); | ||
| log.error({ err, phoneNumber }, 'Failed to initiate call'); | ||
|
|
||
| // Mark the session as failed so it doesn't stay in 'initiated' state | ||
| if (sessionId) { | ||
| updateCallSession(sessionId, { | ||
| status: 'failed', | ||
| endedAt: Date.now(), | ||
|
Comment on lines
+122
to
+124
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.
The new catch-path update applies to any exception after Useful? React with 👍 / 👎. |
||
| lastError: msg, | ||
| }); | ||
| } | ||
|
|
||
| return { content: `Error initiating call: ${msg}`, isError: true }; | ||
| } | ||
| } | ||
|
|
||
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.
This
await provider.endCall(...)runs before relay/orchestrator cleanup, so call termination now depends on Twilio responsiveness; when Twilio/network is slow or stalls,call_endcan hang and never reach the local cleanup path, leaving the active relay/orchestrator alive instead of ending promptly. BecauseendCalluses a plainfetchwithout an abort timeout, this regression can surface during provider incidents and prevents the tool from reliably stopping calls.Useful? React with 👍 / 👎.