{"record":{"id":"9590f30001d56705","repo":"microsoft/semantic-kernel","slug":"at-least-one-then-action-is-required-for-orchestra","errorCode":null,"errorMessage":"At least one then action is required for orchestration steps.","messagePattern":"At least one then action is required for orchestration steps\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Core/Workflow/WorkflowBuilder.cs","lineNumber":242,"sourceCode":"        // If there are no orchestration steps, return\n        if (orchestrationSteps.Count == 0)\n        {\n            return Task.CompletedTask;\n        }\n\n        // Process the orchestration steps\n        foreach (var step in orchestrationSteps)\n        {\n            ListenCondition? listenCondition = step.ListenFor;\n            if (listenCondition is null)\n            {\n                throw new ArgumentException(\"A complete listen_for condition is required for orchestration steps.\");\n            }\n\n            List<ThenAction>? thenActions = step.Then;\n            if (thenActions is null || thenActions.Count == 0)\n            {\n                throw new ArgumentException(\"At least one then action is required for orchestration steps.\");\n            }\n\n            ProcessStepEdgeBuilder? edgeBuilder = null;\n\n            if (listenCondition.AllOf != null && listenCondition.AllOf.Count > 0)\n            {\n                MessageSourceBuilder GetSourceBuilder(ListenEvent listenEvent)\n                {\n                    var sourceBuilder = this.FindSourceBuilder(new() { Event = listenEvent.Event, From = listenEvent.From }, processBuilder);\n                    return new MessageSourceBuilder\n                    (\n                        messageType: listenEvent.Event,\n                        source: this._stepBuilders[listenEvent.From],\n                        null // TODO: Pass through condition.\n                    );\n                }\n\n                // Handle AllOf condition","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Core/Workflow/WorkflowBuilder.cs#L224-L260","documentation":"Thrown by BuildOrchestrationAsync when an OrchestrationStep has a null or empty Then list. A listen_for condition without any 'then' actions has no effect, so the builder requires at least one action.","triggerScenarios":"An orchestration step whose 'then' array is null or contains zero entries (listen_for present but no consequent actions).","commonSituations":"Workflow YAML with a listen_for but an empty/missing then block; authoring a rule and forgetting to add actions; deserialization defaulting Then to an empty list.","solutions":["Add at least one entry to the 'then' array for each orchestration step.","Validate step.Then != null && step.Then.Count > 0 before building.","Remove orchestration entries that intentionally have no consequent action."],"exampleFix":"// before\nstep.Then = new List<ThenAction>();\n\n// after\nstep.Then = new List<ThenAction> { new ThenAction { /* target */ } };","handlingStrategy":"validation","validationCode":"foreach (var s in orchestrationSteps)\n    if (s.Then is null || s.Then.Count == 0) throw new ArgumentException($\"Orchestration step {s} needs at least one then action.\");","typeGuard":"static bool HasThenActions(OrchestrationStep s) => s.Then is { Count: > 0 };","tryCatchPattern":"try { await builder.BuildProcessAsync(workflow, yaml); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"then action is required\"))\n{ /* add at least one then action */ }","preventionTips":["Require at least one then action per orchestration rule in templates.","Validate Then non-empty alongside ListenFor in a pre-build validator.","Remove orchestration entries that intentionally have no consequent."],"tags":["semantic-kernel","process","workflow","orchestration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}