{"record":{"id":"fd13042ab56dc735","repo":"microsoft/semantic-kernel","slug":"failed-to-complete-step-stepid-for-session-sess","errorCode":null,"errorMessage":"Failed to complete step {stepId} for session {sessionId}.","messagePattern":"Failed to complete step (.+?) for session (.+?)\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs","lineNumber":789,"sourceCode":"                    continue;\n                }\n\n                this._logger?.LogWarning(\"Action: No result from action\");\n            }\n            else\n            {\n                actionStep.Observation = \"ACTION $JSON_BLOB must be provided as part of thought process.\";\n                this._logger?.LogWarning(\"Action: No action to take\");\n            }\n\n            if (this._config.MinIterationTimeMs > 0)\n            {\n                // continue to next iteration\n                await Task.Delay(this._config.MinIterationTimeMs).ConfigureAwait(false);\n            }\n        }\n\n        throw new KernelException($\"Failed to complete step {stepId} for session {sessionId}.\");\n    }\n\n    private sealed class RepeatOrStartStepResult(bool? execute, string? prompt = null)\n    {\n        public bool? Execute { get; } = execute;\n\n        public string? Prompt { get; } = prompt;\n    }\n}\n","sourceCodeStart":771,"sourceCodeEnd":799,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs#L771-L799","documentation":"FlowExecutor runs a ReAct-style loop for up to _config.MaxStepIterations. Each iteration asks the model to produce a thought + action, executes the action, and checks whether the step's Provides variables are satisfied. If the loop exhausts all iterations without the step completing (no final answer and all provides populated), KernelException is thrown. This is a timeout-equivalent for a step that never converged.","triggerScenarios":"The model repeatedly fails to produce a valid ACTION JSON blob (falling into the 'ACTION $JSON_BLOB must be provided' branch), or produces actions whose results never populate all of step.Provides, or never emits a FinalAnswer. The loop runs MaxStepIterations times and gives up.","commonSituations":"Weak or misconfigured model that struggles with the ReAct prompt format. MaxStepIterations set too low for a complex step. The action plugin returns empty results, so provides are never satisfied. A content filter or token limit truncates the model output so the action parse fails every time.","solutions":["Increase _config.MaxStepIterations to give the step more reasoning rounds.","Inspect the saved ReAct steps (via the flow status provider) to see what the model produced each iteration — look for malformed actions or empty results.","Improve the step's prompt/instructions so the model produces well-formed ACTION JSON.","Verify the action functions/plugins return non-empty results that populate the step's Provides variables.","Use a more capable model if the current one consistently fails the ReAct format.","Reduce MinIterationTimeMs if it is inflating wall-clock without adding value."],"exampleFix":"// before — default iteration count too low for complex step\nvar config = new FlowConfig { MaxStepIterations = 3, MinIterationTimeMs = 1000 };\n\n// after — more iterations, less delay\nvar config = new FlowConfig { MaxStepIterations = 10, MinIterationTimeMs = 0 };","handlingStrategy":"try-catch","validationCode":"// Pre-call: ensure config has enough iterations for complex steps\nif (config.MaxStepIterations < 5)\n{\n    logger.LogWarning(\"MaxStepIterations is low ({N}); complex steps may fail to converge.\", config.MaxStepIterations);\n}","typeGuard":null,"tryCatchPattern":"try { await executor.ExecuteAsync(sessionId, flow, arguments); }\ncatch (KernelException ex) when (ex.Message.Contains(\"Failed to complete step\"))\n{\n    // Inspect saved ReAct steps to diagnose why the step didn't converge\n    var steps = await statusProvider.GetReActStepsAsync(sessionId, stepId);\n    logger.LogWarning(\"Step did not converge after {Count} iterations. Last thought: {Thought}\",\n        steps.Count, steps.LastOrDefault()?.Thought);\n    throw;\n}","preventionTips":["Set MaxStepIterations generously (e.g. 10+) for complex multi-action steps.","Monitor ReAct step logs to detect models that struggle with the action format.","Ensure action plugins return non-empty results that populate all step.Provides variables.","Use a capable model that reliably follows the ReAct prompt format."],"tags":["flow-executor","iteration","react","model-output","experimental","orchestration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}