{"record":{"id":"906241ba9687d27d","repo":"microsoft/semantic-kernel","slug":"agent-failure-run-not-created-for-thread-thre","errorCode":null,"errorMessage":"Agent Failure - Run not created for thread: ${threadId}","messagePattern":"Agent Failure - Run not created for thread: (.+?)","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Agents/AzureAI/Internal/AgentThreadActions.cs","lineNumber":459,"sourceCode":"                    switch (stepUpdate.UpdateKind)\n                    {\n                        case StreamingUpdateReason.RunStepCompleted when stepUpdate.Value.StepDetails is RunStepToolCallDetails toolDetails:\n                            ProcessToolCallStep(stepUpdate.Value, toolDetails, agent, messages, threadId, stepFunctionResults);\n                            break;\n\n                        case StreamingUpdateReason.RunStepCompleted when stepUpdate.Value.StepDetails is RunStepMessageCreationDetails:\n                            messageCreationStepsToProcess.Add(stepUpdate.Value);\n                            break;\n\n                        default:\n                            break;\n                    }\n                }\n            }\n\n            if (run == null)\n            {\n                throw new KernelException($\"Agent Failure - Run not created for thread: ${threadId}\");\n            }\n\n            // Is in terminal state?\n            if (s_failureStatuses.Contains(run.Status))\n            {\n                throw new KernelException($\"Agent Failure - Run terminated: {run.Status} [{run.Id}]: {run.LastError?.Message ?? \"Unknown\"}\");\n            }\n\n            if (run.Status == RunStatus.RequiresAction)\n            {\n                List<RunStep> activeSteps = [];\n                await foreach (var step in client.GetStepsAsync(run, cancellationToken).ConfigureAwait(false))\n                {\n                    if (step.Status == RunStepStatus.InProgress)\n                    {\n                        activeSteps.Add(step);\n                    }\n                }","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Agents/AzureAI/Internal/AgentThreadActions.cs#L441-L477","documentation":"Thrown in the streaming InvokeStreamingAsync path when, after polling, the local 'run' variable is still null - meaning the run was never successfully created/returned by the service. Note a formatting bug: the message uses \"${threadId}\" which in C# emits a literal '$' before the interpolated threadId value, so the displayed threadId is still present but prefixed with '$'. This is a service-side run-creation failure.","triggerScenarios":"Streaming invoke where the polling loop completes without ever assigning a non-null run object - typically the createRun API call failed or returned nothing usable before the loop checked run == null.","commonSituations":"Transient Azure AI service outage during run creation; authentication/authorization failure preventing run creation; throttling at creation time; SDK version mismatch causing a deserialization gap.","solutions":["Treat as transient: retry the streaming invocation with exponential backoff.","Verify credentials (TokenCredential) and that the assistant/agent Id is valid.","Check Azure service health and throttling headers.","Capture the threadId from your call context (the exception text shows it after the '$') for support correlation."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await foreach (var m in agent.InvokeStreamingAsync(messages, thread, ct)) { /*...*/ } }\ncatch (KernelException ex) when (ex.Message.Contains(\"Run not created\"))\n{\n    // run creation failed; retry with backoff, verify credentials/assistant id\n    logger.LogWarning(\"Streaming run not created: {Msg}\", ex.Message);\n}","preventionTips":["Verify TokenCredential and assistant/agent Id before streaming.","Wrap streaming calls in retry logic for run-creation failures.","Fall back to non-streaming invocation if streaming run creation repeatedly fails."],"tags":["runtime","azureai","agent-run","streaming","transient","network"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}