microsoft/semantic-kernel · error · ArgumentException

Unsupported thread type: {typeof(T).Name}

Error message

Unsupported thread type: {typeof(T).Name}

What it means

Thrown by ProcessBuilder.AddThread<T> when the generic type parameter T does not match any of the supported AgentThread concrete types. Currently only AzureAIAgentThread is recognized and mapped to KernelProcessThreadType.AzureAI; any other type argument triggers this exception.

Source

Thrown at dotnet/src/Experimental/Process.Core/ProcessBuilder.cs:433

        return this.AddStep(proxyBuilder, aliases);
    }

    /// <summary>
    /// Adds a thread to the process.
    /// </summary>
    /// <typeparam name="T">The concrete type of the <see cref="AgentThread"/></typeparam>
    /// <param name="threadName">The name of the thread.</param>
    /// <param name="threadPolicy">The policy that determines the lifetime of the <see cref="AgentThread"/></param>
    /// <param name="threadId">The Id of an existing thread that should be used.</param>
    public ProcessBuilder AddThread<T>(string threadName, KernelProcessThreadLifetime threadPolicy, string? threadId = null) where T : AgentThread
    {
        Verify.NotNullOrWhiteSpace(threadName, nameof(threadName));

        var threadType = typeof(T) switch
        {
            Type t when t == typeof(AzureAIAgentThread) => KernelProcessThreadType.AzureAI,
            _ => throw new ArgumentException($"Unsupported thread type: {typeof(T).Name}")
        };

        var processThread = new KernelProcessAgentThread() { ThreadName = threadName, ThreadId = threadId, ThreadType = threadType };
        this._threads[threadName] = processThread;
        return this;
    }

    /// <summary>
    /// Adds a thread to the process.
    /// </summary>
    /// <param name="threadName">The name of the thread.</param>
    /// <param name="threadPolicy">The policy that determines the lifetime of the <see cref="AgentThread"/></param>
    public ProcessBuilder AddThread(string threadName, KernelProcessThreadLifetime threadPolicy)
    {
        Verify.NotNullOrWhiteSpace(threadName, nameof(threadName));
        Verify.NotNull(threadPolicy, nameof(threadPolicy));

        var processThread = new KernelProcessAgentThread() { ThreadName = threadName, ThreadPolicy = threadPolicy };

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Use process.AddThread<AzureAIAgentThread>(threadName, threadPolicy) since AzureAIAgentThread is currently the only supported type.
  2. If you need a different thread type, use the non-generic AddThread(string, KernelProcessThreadLifetime) overload that does not require a type argument.
  3. Check for SDK updates that may have added support for your thread type, or file an issue requesting support.

Example fix

// before
process.AddThread<MyCustomThread>("myThread", KernelProcessThreadLifetime.Scoped);

// after — use the supported Azure type
process.AddThread<AzureAIAgentThread>("myThread", KernelProcessThreadLifetime.Scoped);

// or use the non-generic overload
process.AddThread("myThread", KernelProcessThreadLifetime.Scoped);
Defensive patterns

Strategy: type-guard

Validate before calling

Type threadType = typeof(T);
if (threadType != typeof(AzureAIAgentThread))
    throw new InvalidOperationException(
        $"Thread type {threadType.Name} is not supported. Use AzureAIAgentThread or the non-generic AddThread overload.");

process.AddThread<T>(threadName, threadPolicy);

Type guard

static bool IsSupportedThreadType<T>() where T : AgentThread
    => typeof(T) == typeof(AzureAIAgentThread);

Prevention

When it happens

Trigger: Calling process.AddThread<CustomThread>(...) where CustomThread is not AzureAIAgentThread. Also occurs if you pass a base type such as AgentThread itself, or a future thread type the library has not yet mapped.

Common situations: Using a custom AgentThread subclass for a non-Azure provider (e.g. OpenAI or a local thread implementation) that the process builder does not yet support; upgrading the Semantic Kernel version where new thread types were added but this switch was not updated; calling the non-generic AddThread overload incorrectly via reflection with an unsupported type.

Related errors


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