microsoft/semantic-kernel · error · NotSupportedException
{nameof(CopilotStudioAgent)} is not for use with {nameof(Age
Error message
{nameof(CopilotStudioAgent)} is not for use with {nameof(AgentChat)}. What it means
Thrown by CopilotStudioAgent.GetChannelKeys() to signal that CopilotStudioAgent does not participate in the multi-agent AgentChat channel coordination system. The Copilot Studio integration is designed for direct single-agent invocation only; it overrides the channel-related abstract members to throw NotSupportedException to make the limitation explicit at the point AgentChat would try to use them.
Source
Thrown at dotnet/src/Agents/Copilot/CopilotStudioAgent.cs:127
{
await options.OnIntermediateMessage(result).ConfigureAwait(false);
}
StreamingChatMessageContent streamedResult = new(result.Role, content: null)
{
Items = [.. ContentProcessor.ConvertToStreaming(result.Items, this.Logger)],
InnerContent = result.InnerContent,
Metadata = result.Metadata,
};
yield return new(streamedResult, agentThread);
}
}
/// <inheritdoc/>
protected override IEnumerable<string> GetChannelKeys()
{
throw new NotSupportedException($"{nameof(CopilotStudioAgent)} is not for use with {nameof(AgentChat)}.");
}
/// <inheritdoc/>
protected override Task<AgentChannel> CreateChannelAsync(CancellationToken cancellationToken)
{
throw new NotSupportedException($"{nameof(CopilotStudioAgent)} is not for use with {nameof(AgentChat)}.");
}
/// <inheritdoc/>
protected override Task<AgentChannel> RestoreChannelAsync(string channelState, CancellationToken cancellationToken)
{
throw new NotSupportedException($"{nameof(CopilotStudioAgent)} is not for use with {nameof(AgentChat)}.");
}
private IAsyncEnumerable<ChatMessageContent> InvokeInternalAsync(ICollection<ChatMessageContent> messages, CopilotStudioAgentThread thread, CancellationToken cancellationToken)
{
string question = string.Join(Environment.NewLine, messages.Select(m => m.Content));
View on GitHub (pinned to c028a0c7dc)
Solutions
- Do not use CopilotStudioAgent with AgentChat. Invoke it directly via InvokeAsync/InvokeStreamingAsync with a CopilotStudioAgentThread.
- If multi-agent orchestration is needed, host the Copilot Studio agent behind a custom adapter that is not registered with AgentChat.
- Use a different agent type that supports the AgentChat channel model for multi-agent scenarios.
Example fix
// before — not supported
var chat = new AgentChat { };
chat.AddAgent(copilotAgent); // triggers GetChannelKeys -> NotSupportedException
// after — invoke directly
var thread = new CopilotStudioAgentThread(client);
await foreach (var r in copilotAgent.InvokeAsync(messages, thread)) { ... } Defensive patterns
Strategy: validation
Validate before calling
// Do not register CopilotStudioAgent with AgentChat
if (agent is CopilotStudioAgent)
throw new InvalidOperationException("CopilotStudioAgent cannot be used with AgentChat. Invoke directly."); Type guard
static bool SupportsAgentChat(Microsoft.SemanticKernel.Agents.Agent a) =>
a is not CopilotStudioAgent; Try / catch
try { chat.AddAgent(agent); }
catch (NotSupportedException ex) when (ex.Message.Contains("AgentChat"))
{
logger.LogError("CopilotStudioAgent does not support AgentChat. Use direct InvokeAsync instead.");
throw;
} Prevention
- Keep CopilotStudioAgent out of any AgentChat configuration.
- Invoke CopilotStudioAgent directly with a CopilotStudioAgentThread.
- Document in your codebase that Copilot Studio agents are single-agent, direct-invoke only.
When it happens
Trigger: Adding a CopilotStudioAgent to an AgentChat (multi-agent chat) instance, which internally calls GetChannelKeys() to coordinate channels across agents. Because Copilot Studio uses its own conversation/session model, it cannot be wired into the shared channel abstraction.
Common situations: Migrating from a single-agent OpenAI/Bedrock setup to a multi-agent AgentChat and including a Copilot Studio agent; following a multi-agent sample and substituting CopilotStudioAgent.
Related errors
- {nameof(A2AAgent)} is not for use with {nameof(AgentChat)}.
- {nameof(CopilotStudioAgent)} requires a message to be invoke
- client
- Message role must be either Assistant or User.
- runtimeClient
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/e15f68262b456cc2.
Report an issue: GitHub.