{"record":{"id":"1e1eca91dc7c31cc","repo":"microsoft/semantic-kernel","slug":"a-complete-on-complete-condition-is-required-for-d","errorCode":null,"errorMessage":"A complete on_complete condition is required for declarative steps.","messagePattern":"A complete on_complete condition is required for declarative steps\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Core/Workflow/WorkflowBuilder.cs","lineNumber":148,"sourceCode":"            var endBuilder = processBuilder.AddEndStep();\n            this._stepBuilders[\"End\"] = endBuilder;\n            return Task.CompletedTask;\n        }\n\n        AgentDefinition? agentDefinition = node.Agent ?? throw new KernelException(\"Declarative steps must have an agent defined.\");\n        var stepBuilder = processBuilder.AddStepFromAgent(agentDefinition, node.Id);\n        if (stepBuilder is not ProcessAgentBuilder agentBuilder)\n        {\n            throw new KernelException($\"Failed to build step from agent definition: {node.Id}\");\n        }\n\n        // ########################### Parsing on_complete and on_error conditions ###########################\n\n        if (node.OnComplete != null)\n        {\n            if (node.OnComplete.Any(c => c is null || c.OnCondition is null))\n            {\n                throw new ArgumentException(\"A complete on_complete condition is required for declarative steps.\");\n            }\n\n            agentBuilder.OnComplete([.. node.OnComplete.Select(c => c.OnCondition!)]);\n        }\n\n        if (node.OnError != null)\n        {\n            if (node.OnError.Any(c => c is null || c.OnCondition is null))\n            {\n                throw new ArgumentException(\"A complete on_complete condition is required for declarative steps.\");\n            }\n\n            agentBuilder.OnComplete([.. node.OnError.Select(c => c.OnCondition!)]);\n        }\n\n        // ########################### Parsing node inputs ###########################\n\n        if (node.Inputs != null)","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Core/Workflow/WorkflowBuilder.cs#L130-L166","documentation":"Thrown in the OnComplete branch of BuildDeclarativeStepAsync when node.OnComplete is non-null but contains an entry that is null or whose OnCondition is null. Declarative steps require each on_complete entry to carry a complete condition.","triggerScenarios":"A declarative node whose 'on_complete' array has a null element or an element with a null/missing 'on_condition'.","commonSituations":"Workflow YAML listing on_complete entries where one omits the condition object; deserialization producing partial entries; copy-paste errors leaving an empty condition block.","solutions":["Ensure every on_complete entry has a non-null element with a populated on_condition.","Remove empty/null on_complete entries from the workflow definition.","Validate OnComplete entries before building: node.OnComplete.All(c => c is not null && c.OnCondition is not null)."],"exampleFix":"// before\nnode.OnComplete = new[] { new CompleteCondition { OnCondition = null } };\n\n// after\nnode.OnComplete = new[] { new CompleteCondition { OnCondition = myCondition } };","handlingStrategy":"validation","validationCode":"if (node.OnComplete is not null && node.OnComplete.Any(c => c is null || c.OnCondition is null))\n    throw new ArgumentException(\"Each on_complete entry needs a complete condition.\");","typeGuard":"static bool OnCompleteIsValid(Node n) => n.OnComplete is null || n.OnComplete.All(c => c is not null && c.OnCondition is not null);","tryCatchPattern":"try { await builder.BuildProcessAsync(workflow, yaml); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"on_complete condition is required\"))\n{ /* fill or remove incomplete on_complete entries */ }","preventionTips":["Author on_complete entries from a template that mandates on_condition.","Strip null/empty conditions during a pre-build normalization pass.","Add schema validation for the workflow YAML."],"tags":["semantic-kernel","process","workflow","declarative","on-complete"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}