microsoft/semantic-kernel · error · NotSupportedException

{nameof(A2AAgent)} is not for use with {nameof(AgentChat)}.

Error message

{nameof(A2AAgent)} is not for use with {nameof(AgentChat)}.

What it means

A NotSupportedException thrown by A2AAgent.CreateChannelAsync, an Agent base-class override used by the AgentChat multi-agent orchestration channel system. A2AAgent is built on the A2A protocol (remote agent invocation) and does not implement the AgentChannel contract that AgentChat relies on, so any attempt to obtain a channel is explicitly rejected.

Source

Thrown at dotnet/src/Agents/A2A/A2AAgent.cs:113

            yield return new(result, agentThread);
        }

        // Notify the thread of any new messages that were assembled from the streaming response.
        foreach (var chatMessage in chatMessages)
        {
            await this.NotifyThreadOfNewMessage(agentThread, chatMessage, cancellationToken).ConfigureAwait(false);

            if (options?.OnIntermediateMessage is not null)
            {
                await options.OnIntermediateMessage(chatMessage).ConfigureAwait(false);
            }
        }
    }

    /// <inheritdoc/>
    protected override Task<AgentChannel> CreateChannelAsync(CancellationToken cancellationToken)
    {
        throw new NotSupportedException($"{nameof(A2AAgent)} is not for use with {nameof(AgentChat)}.");
    }

    /// <inheritdoc/>
    protected override IEnumerable<string> GetChannelKeys()
    {
        throw new NotSupportedException($"{nameof(A2AAgent)} is not for use with {nameof(AgentChat)}.");
    }

    /// <inheritdoc/>
    protected override Task<AgentChannel> RestoreChannelAsync(string channelState, CancellationToken cancellationToken)
    {
        throw new NotSupportedException($"{nameof(A2AAgent)} is not for use with {nameof(AgentChat)}.");
    }

    #region private
    private async IAsyncEnumerable<AgentResponseItem<ChatMessageContent>> InternalInvokeAsync(string name, ICollection<ChatMessageContent> messages, A2AAgentThread thread, AgentInvokeOptions options, [EnumeratorCancellation] CancellationToken cancellationToken)
    {
        Verify.NotNull(messages);

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Do not use A2AAgent with AgentChat/AgentGroupChat; invoke it directly via InvokeAsync/InvokeStreamingAsync.
  2. Use a ChatCompletionAgent or other channel-capable agent for AgentChat scenarios.
  3. If multi-agent orchestration is needed, drive each A2AAgent via its own InvokeAsync and assemble results manually.

Example fix

// before - throws NotSupportedException
var chat = new AgentGroupChat(kernel) { ExecutionSettings = ... };
chat.AddAgent(a2aAgent);
await chat.InvokeAsync();
// after - invoke A2A agent directly
await foreach (var item in a2aAgent.InvokeAsync(messages, thread))
    Console.WriteLine(item.Message.Content);
Defensive patterns

Strategy: type-guard

Validate before calling

if (agent is A2AAgent) throw new InvalidOperationException("A2AAgent cannot be used with AgentChat; invoke it directly.");
chat.AddAgent(agent);

Type guard

static bool IsChatCompatible(Agent a) => a is not A2AAgent;

Try / catch

try { chat.AddAgent(agent); await chat.InvokeAsync(); }
catch (NotSupportedException ex) when (ex.Message.Contains("A2AAgent")) { /* remove A2AAgent, invoke it directly */ }

Prevention

When it happens

Trigger: Adding an A2AAgent to an AgentChat (e.g. AgentGroupChat) and invoking the chat, which triggers channel creation via CreateChannelAsync.

Common situations: Mixing A2A protocol agents with the channel-based AgentChat orchestration; copy-pasting an AgentGroupChat setup that worked for ChatCompletionAgent/OpenAIAssistantAgent and substituting an A2AAgent.

Related errors


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