From 001e85948f95f4e313a97b3e0aa01e63b66e626a Mon Sep 17 00:00:00 2001 From: "mars.yu" <18671933+yuyixg@users.noreply.github.com> Date: Fri, 13 Nov 2026 16:33:20 +0800 Subject: [PATCH] fix(twilio): log whether a line cut into is set to be said again, and why it wasn't After a cut-in the line never came back and the call sat silent for about six seconds, and nothing in the logs showed whether the caller had started talking (which cancels saying it again) or the line was never set to be said again (ResumeAfterCutInSeconds off for the agent). - The interrupt's log line says when the line will be said again if nothing follows, and after how many seconds. - A line set to be said again and dropped because the caller spoke is logged, with how soon after the cut-in. No change to what is said. Co-Authored-By: Claude Opus 5.5 --- .../Services/ConversationRelaySession.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Services/ConversationRelaySession.cs b/src/Plugins/BotSharp.Plugin.Twilio/Services/ConversationRelaySession.cs index a323d7abc..56c57efe7 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Services/ConversationRelaySession.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Services/ConversationRelaySession.cs @@ -317,6 +317,7 @@ private async Task HandleMessageAsync(string json) case "interrupt": // Playback stopped where the caller cut in; the caller's words follow as a prompt + bool sayAgain; lock (_sync) { _quietSinceUtc = DateTime.UtcNow; @@ -347,10 +348,12 @@ private async Task HandleMessageAsync(string json) && lineCutInto.StartsWith(heardOfLine, StringComparison.Ordinal) && CountWords(heardOfLine) >= HeardSomeWords; _utteranceCutIn |= _utteranceOpen; NoteCutIn(); + sayAgain = _resumeLine != null; } var interruptedAfter = GetString(root, "durationUntilInterruptMs"); _logger.LogInformation( - $"Caller interrupted the agent in conversation {_conversationId} after {interruptedAfter} ms."); + $"Caller interrupted the agent in conversation {_conversationId} after {interruptedAfter} ms" + + (sayAgain ? $"; the line is said again if nothing follows for {_relay.ResumeAfterCutInSeconds} s." : ".")); break; case "error": @@ -938,6 +941,13 @@ private async Task ResumeIfSilentAsync() // Anything from the caller since the cut-in (words, keys) is their turn: nothing is said again if (_ended || _activity != _cutInActivity) { + // Why logged: after a cut-in the line never came back and the call sat silent, and nothing showed whether + // the caller had started talking or the line was never set to be said again (a staging call, 2026-11-13) + if (!_ended) + { + _logger.LogInformation($"The caller spoke within {(DateTime.UtcNow - _cutInUtc).TotalSeconds:0.0} s of cutting in, " + + $"in conversation {_conversationId}; the line they cut into is not said again."); + } _resumeLine = null; return; }