microsoft/semantic-kernel · error · NotSupportedException

Agent type {agentDefinition.Type} is not supported.

Error message

Agent type {agentDefinition.Type} is not supported.

What it means

Thrown by AgentFactory.CreateAsync when the abstract TryCreateAsync returns null, indicating the factory does not support the AgentDefinition.Type value. AgentFactory is the experimental (SKEXP0110) extensibility point for declarative agent creation; each concrete factory declares which Type strings it handles via its Types list.

Source

Thrown at dotnet/src/Agents/Abstractions/Definition/AgentFactory.cs:55

    {
        return this.Types.Any(s => string.Equals(s, agentDefinition.Type, StringComparison.OrdinalIgnoreCase));
    }

    /// <summary>
    /// Create a <see cref="Agent"/> from the specified <see cref="AgentDefinition"/>.
    /// </summary>
    /// <param name="kernel">Kernel instance to associate with the agent.</param>
    /// <param name="agentDefinition">Definition of the agent to create.</param>
    /// <param name="agentCreationOptions">Options used when creating the agent.</param>
    /// <param name="cancellationToken">Optional cancellation token.</param>
    /// <return>The created <see cref="Agent"/>, if null the agent type is not supported.</return>
    public async Task<Agent> CreateAsync(Kernel kernel, AgentDefinition agentDefinition, AgentCreationOptions? agentCreationOptions = null, CancellationToken cancellationToken = default)
    {
        Verify.NotNull(kernel);
        Verify.NotNull(agentDefinition);

        var kernelAgent = await this.TryCreateAsync(kernel, agentDefinition, agentCreationOptions, cancellationToken).ConfigureAwait(false);
        return (Agent?)kernelAgent ?? throw new NotSupportedException($"Agent type {agentDefinition.Type} is not supported.");
    }

    /// <summary>
    /// Tries to create a <see cref="Agent"/> from the specified <see cref="AgentDefinition"/>.
    /// </summary>
    /// <param name="kernel">Kernel instance to associate with the agent.</param>
    /// <param name="agentDefinition">Definition of the agent to create.</param>
    /// <param name="agentCreationOptions">Options used when creating the agent.</param>
    /// <param name="cancellationToken">Optional cancellation token.</param>
    /// <return>The created <see cref="Agent"/>, if null the agent type is not supported.</return>
    public abstract Task<Agent?> TryCreateAsync(Kernel kernel, AgentDefinition agentDefinition, AgentCreationOptions? agentCreationOptions = null, CancellationToken cancellationToken = default);
}

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Check the agentDefinition.Type value and ensure it matches a type your factory supports (case-insensitive).
  2. Register the correct AgentFactory subclass for the agent type you want to create.
  3. Call factory.IsSupported(agentDefinition) before CreateAsync to guard.
  4. Verify the agent definition file/template has the correct type field.

Example fix

// before
var agent = await factory.CreateAsync(kernel, definition, null, ct); // throws

// after
if (factory.IsSupported(definition))
{
    var agent = await factory.CreateAsync(kernel, definition, null, ct);
}
else
{
    throw new ArgumentException($"No factory for type '{definition.Type}'. Supported: {string.Join(", ", factory.Types)}");
}
Defensive patterns

Strategy: validation

Validate before calling

if (!factory.IsSupported(agentDefinition))
{
    throw new ArgumentException(
        $"Agent type '{agentDefinition.Type}' is not supported. " +
        $"Supported types: {string.Join(", ", factory.Types)}");
}

Try / catch

try
{
    var agent = await factory.CreateAsync(kernel, definition, null, ct);
}
catch (NotSupportedException ex) when (ex.Message.Contains("is not supported"))
{
    _logger.LogError("Unsupported agent type: {Type}", definition.Type);
    throw;
}

Prevention

When it happens

Trigger: An AgentDefinition with a Type that no registered AgentFactory can handle is passed to CreateAsync. The factory's TryCreateAsync returns null because IsSupported(agentDefinition) is false for the given Type.

Common situations: Wrong or misspelled agent type in a declarative YAML/JSON agent definition. Forgetting to register the appropriate factory (e.g., AzureAIAgentFactory, OpenAIAssistantAgentFactory) in the factory registry. Using a type from a newer SDK version on an older runtime. Custom factory that does not cover the type string being requested.

Related errors


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