{"record":{"id":"fcbb0f0d2e816b0a","repo":"microsoft/semantic-kernel","slug":"unexpected-failure-broadcasting-to-channel-chann","errorCode":null,"errorMessage":"Unexpected failure broadcasting to channel: {channelRef.Channel.GetType()}","messagePattern":"Unexpected failure broadcasting to channel: (.+?)","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs","lineNumber":98,"sourceCode":"            return;\n        }\n\n        // Evaluate queue state\n        bool isEmpty = true;\n        do\n        {\n            // Queue state is only changed within acquired QueueLock.\n            // If its empty here, it is synchronized.\n            lock (queueRef.QueueLock)\n            {\n                isEmpty = queueRef.IsEmpty;\n\n                // Propagate prior failure (inform caller of synchronization issue)\n                if (queueRef.ReceiveFailure is not null)\n                {\n                    Exception failure = queueRef.ReceiveFailure;\n                    queueRef.ReceiveFailure = null;\n                    throw new KernelException($\"Unexpected failure broadcasting to channel: {channelRef.Channel.GetType()}\", failure);\n                }\n\n                // Activate non-empty queue\n                if (!isEmpty)\n                {\n                    if (queueRef.ReceiveTask?.IsCompleted ?? true)\n                    {\n                        queueRef.ReceiveTask = ReceiveAsync(channelRef, queueRef, cancellationToken);\n                    }\n                }\n            }\n\n            if (!isEmpty)\n            {\n                await Task.Delay(this.BlockDuration, cancellationToken).ConfigureAwait(false);\n            }\n        }\n        while (!isEmpty);","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs#L80-L116","documentation":"Thrown by BroadcastQueue.EnsureSynchronizedAsync to propagate a prior receive failure that was stored in queueRef.ReceiveFailure. When the broadcast queue detects a previously cached exception from a ReceiveAsync operation, it clears it and wraps it in a KernelException with the channel type for diagnostics. This indicates an underlying channel operation failed during message broadcasting between agents in a multi-agent chat.","triggerScenarios":"During multi-agent AgentChat synchronization, a prior call to ReceiveAsync on a channel threw an exception that was captured into ReceiveFailure. On the next EnsureSynchronizedAsync call for that channel, the stored failure is re-thrown. The inner exception contains the original cause.","commonSituations":"An agent's channel (e.g., AzureAIChannel, OpenAIAssistantChannel) failed to process messages — network errors, service outages, or downstream AgentThreadOperationExceptions. This surfaces during agent-to-agent message broadcasting in AgentChat where multiple agents share channels. Transient Azure/OpenAI service errors that were swallowed during async receive bubble up here.","solutions":["Inspect the InnerException of the KernelException for the root cause.","Implement retry logic around the multi-agent chat invocation for transient service errors.","Check connectivity to the backing AI service (Azure OpenAI, OpenAI endpoint).","Verify that all agents in the chat have valid, non-deleted threads and correct credentials."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await chat.InvokeAsync(ct);\n}\ncatch (KernelException ex) when (ex.Message.Contains(\"Unexpected failure broadcasting to channel\"))\n{\n    var rootCause = ex.InnerException;\n    _logger.LogError(rootCause, \"Channel broadcast failed during multi-agent sync.\");\n    // Retry or surface the root cause\n}","preventionTips":["Always inspect the InnerException for the real root cause.","Implement retry policies around AgentChat invocations for transient service failures.","Monitor agent thread health and credential freshness in long-running multi-agent scenarios."],"tags":["broadcast","multi-agent","channel","kernalexception","internal"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}