Repository navigation
Conversation
…the dialogs The hang-up response_content and the transfer transition_message are played as audio files by the redirect endpoints, not spoken in the realtime stream, so they never reached the conversation dialogs. Append them as an assistant message before the redirect, which closes the stream and disposes the scope, and only when the audio file exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Summary by Qodofix(twilio): save hang-up and transfer lines to conversation dialogs
AI Description
Merge Risk
|
Code Review by Qodo
1. Storage failures block live call redirects
|
| var storage = _services.GetRequiredService<IConversationStorage>(); | ||
| await storage.Append(conversationId, new RoleDialogModel(AgentRole.Assistant, args.ResponseContent) |
There was a problem hiding this comment.
1. Storage failures block live call redirects 🐞 Bug ☼ Reliability
Both phone-call functions await the new IConversationStorage.Append before calling TryRedirectCallAsync, without handling persistence errors. If the repository write fails after audio generation, the exception prevents a live call from reaching its hang-up or transfer redirect.
Agent Prompt
## Issue description
A failed dialog write prevents either phone-call function from redirecting the live call.
## Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/HangupPhoneCallFn.cs[58-67]
- src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/TransferPhoneCallFn.cs[63-70]
## Recommended Fix
Make dialog persistence best-effort in both functions: catch and log append failures with their exception, then attempt the redirect regardless. Preserve the intended dialog write when storage is available.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| var storage = _services.GetRequiredService<IConversationStorage>(); | ||
| await storage.Append(conversationId, new RoleDialogModel(AgentRole.Assistant, args.TransitionMessage) |
There was a problem hiding this comment.
2. Ended calls gain lines they never heard 🐞 Bug ≡ Correctness
The new assistant dialog is appended before TryRedirectCallAsync determines whether the call can be redirected. When Twilio reports that a call has already ended, the service returns false without delivering the audio, but both functions have already stored the line as spoken.
Agent Prompt
## Issue description
Hang-up and transfer record audio lines even when Twilio says the call was already over and no audio could be delivered.
## Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/HangupPhoneCallFn.cs[58-67]
- src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/TransferPhoneCallFn.cs[63-75]
## Recommended Fix
Account for the redirect result before recording a line as delivered in both functions. Preserve the required storage lifetime when arranging the redirect and write, and do not persist a spoken-line dialog when the redirect returns false.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // The caller hears this as audio, so keep it in the dialogs too. Save it before the redirect, | ||
| // which closes the stream and disposes this scope. | ||
| var storage = _services.GetRequiredService<IConversationStorage>(); | ||
| await storage.Append(conversationId, new RoleDialogModel(AgentRole.Assistant, args.ResponseContent) |
There was a problem hiding this comment.
3. Reused audio gets the wrong transcript 🐞 Bug ≡ Correctness
Both functions append the current text whenever SaveSpeechAsync returns a filename, although that filename can refer to an existing recording of different text. On a repeated hang-up or transfer in a realtime conversation without a synthesis model, the fixed-name audio file is reused while the new dialog records the latest argument instead.
Agent Prompt
## Issue description
A returned audio filename does not always mean the file contains the current hang-up or transfer text.
## Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/HangupPhoneCallFn.cs[47-62]
- src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/TransferPhoneCallFn.cs[53-67]
- src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs[470-486]
## Recommended Fix
When speech generation reuses an existing file, obtain and store the text associated with that file rather than the latest argument. Alternatively, generate a distinct audio file for each distinct line before appending its text.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
reviewed |
✅ AegisCode Code Review Report: PassNo counted findings. Unit Tests: not run (No unit tests were found) Test Coverage: Failed |
The hang-up response_content and the transfer transition_message are played as audio files by the redirect endpoints, not spoken in the realtime stream, so they never reached the conversation dialogs. Append them as an assistant message before the redirect, which closes the stream and disposes the scope, and only when the audio file exists.