microsoft/semantic-kernel · error · KernelException

Unexpected failure broadcasting to channel: {channelRef.Chan

Error message

Unexpected failure broadcasting to channel: {channelRef.Channel.GetType()}

What it means

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.

Source

Thrown at dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs:98

            return;
        }

        // Evaluate queue state
        bool isEmpty = true;
        do
        {
            // Queue state is only changed within acquired QueueLock.
            // If its empty here, it is synchronized.
            lock (queueRef.QueueLock)
            {
                isEmpty = queueRef.IsEmpty;

                // Propagate prior failure (inform caller of synchronization issue)
                if (queueRef.ReceiveFailure is not null)
                {
                    Exception failure = queueRef.ReceiveFailure;
                    queueRef.ReceiveFailure = null;
                    throw new KernelException($"Unexpected failure broadcasting to channel: {channelRef.Channel.GetType()}", failure);
                }

                // Activate non-empty queue
                if (!isEmpty)
                {
                    if (queueRef.ReceiveTask?.IsCompleted ?? true)
                    {
                        queueRef.ReceiveTask = ReceiveAsync(channelRef, queueRef, cancellationToken);
                    }
                }
            }

            if (!isEmpty)
            {
                await Task.Delay(this.BlockDuration, cancellationToken).ConfigureAwait(false);
            }
        }
        while (!isEmpty);

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Inspect the InnerException of the KernelException for the root cause.
  2. Implement retry logic around the multi-agent chat invocation for transient service errors.
  3. Check connectivity to the backing AI service (Azure OpenAI, OpenAI endpoint).
  4. Verify that all agents in the chat have valid, non-deleted threads and correct credentials.
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    await chat.InvokeAsync(ct);
}
catch (KernelException ex) when (ex.Message.Contains("Unexpected failure broadcasting to channel"))
{
    var rootCause = ex.InnerException;
    _logger.LogError(rootCause, "Channel broadcast failed during multi-agent sync.");
    // Retry or surface the root cause
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/fcbb0f0d2e816b0a. Report an issue: GitHub.