{"record":{"id":"d87abe1a9b44e544","repo":"microsoft/semantic-kernel","slug":"unsupported-thread-type-typeof-t-name","errorCode":null,"errorMessage":"Unsupported thread type: {typeof(T).Name}","messagePattern":"Unsupported thread type: (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Core/ProcessBuilder.cs","lineNumber":433,"sourceCode":"\n        return this.AddStep(proxyBuilder, aliases);\n    }\n\n    /// <summary>\n    /// Adds a thread to the process.\n    /// </summary>\n    /// <typeparam name=\"T\">The concrete type of the <see cref=\"AgentThread\"/></typeparam>\n    /// <param name=\"threadName\">The name of the thread.</param>\n    /// <param name=\"threadPolicy\">The policy that determines the lifetime of the <see cref=\"AgentThread\"/></param>\n    /// <param name=\"threadId\">The Id of an existing thread that should be used.</param>\n    public ProcessBuilder AddThread<T>(string threadName, KernelProcessThreadLifetime threadPolicy, string? threadId = null) where T : AgentThread\n    {\n        Verify.NotNullOrWhiteSpace(threadName, nameof(threadName));\n\n        var threadType = typeof(T) switch\n        {\n            Type t when t == typeof(AzureAIAgentThread) => KernelProcessThreadType.AzureAI,\n            _ => throw new ArgumentException($\"Unsupported thread type: {typeof(T).Name}\")\n        };\n\n        var processThread = new KernelProcessAgentThread() { ThreadName = threadName, ThreadId = threadId, ThreadType = threadType };\n        this._threads[threadName] = processThread;\n        return this;\n    }\n\n    /// <summary>\n    /// Adds a thread to the process.\n    /// </summary>\n    /// <param name=\"threadName\">The name of the thread.</param>\n    /// <param name=\"threadPolicy\">The policy that determines the lifetime of the <see cref=\"AgentThread\"/></param>\n    public ProcessBuilder AddThread(string threadName, KernelProcessThreadLifetime threadPolicy)\n    {\n        Verify.NotNullOrWhiteSpace(threadName, nameof(threadName));\n        Verify.NotNull(threadPolicy, nameof(threadPolicy));\n\n        var processThread = new KernelProcessAgentThread() { ThreadName = threadName, ThreadPolicy = threadPolicy };","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Core/ProcessBuilder.cs#L415-L451","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use process.AddThread<AzureAIAgentThread>(threadName, threadPolicy) since AzureAIAgentThread is currently the only supported type.","If you need a different thread type, use the non-generic AddThread(string, KernelProcessThreadLifetime) overload that does not require a type argument.","Check for SDK updates that may have added support for your thread type, or file an issue requesting support."],"exampleFix":"// before\nprocess.AddThread<MyCustomThread>(\"myThread\", KernelProcessThreadLifetime.Scoped);\n\n// after — use the supported Azure type\nprocess.AddThread<AzureAIAgentThread>(\"myThread\", KernelProcessThreadLifetime.Scoped);\n\n// or use the non-generic overload\nprocess.AddThread(\"myThread\", KernelProcessThreadLifetime.Scoped);","handlingStrategy":"type-guard","validationCode":"Type threadType = typeof(T);\nif (threadType != typeof(AzureAIAgentThread))\n    throw new InvalidOperationException(\n        $\"Thread type {threadType.Name} is not supported. Use AzureAIAgentThread or the non-generic AddThread overload.\");\n\nprocess.AddThread<T>(threadName, threadPolicy);","typeGuard":"static bool IsSupportedThreadType<T>() where T : AgentThread\n    => typeof(T) == typeof(AzureAIAgentThread);","tryCatchPattern":null,"preventionTips":["Check the SDK's supported thread types before calling the generic AddThread<T>.","Prefer the non-generic AddThread overload when you don't need a specific thread type.","Subscribe to SDK release notes for newly added thread type support."],"tags":["thread","type-switch","process-builder","dotnet"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}