microsoft/semantic-kernel · error · ArgumentException
A complete on_complete condition is required for declarative
Error message
A complete on_complete condition is required for declarative steps.
What it means
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.
Source
Thrown at dotnet/src/Experimental/Process.Core/Workflow/WorkflowBuilder.cs:148
var endBuilder = processBuilder.AddEndStep();
this._stepBuilders["End"] = endBuilder;
return Task.CompletedTask;
}
AgentDefinition? agentDefinition = node.Agent ?? throw new KernelException("Declarative steps must have an agent defined.");
var stepBuilder = processBuilder.AddStepFromAgent(agentDefinition, node.Id);
if (stepBuilder is not ProcessAgentBuilder agentBuilder)
{
throw new KernelException($"Failed to build step from agent definition: {node.Id}");
}
// ########################### Parsing on_complete and on_error conditions ###########################
if (node.OnComplete != null)
{
if (node.OnComplete.Any(c => c is null || c.OnCondition is null))
{
throw new ArgumentException("A complete on_complete condition is required for declarative steps.");
}
agentBuilder.OnComplete([.. node.OnComplete.Select(c => c.OnCondition!)]);
}
if (node.OnError != null)
{
if (node.OnError.Any(c => c is null || c.OnCondition is null))
{
throw new ArgumentException("A complete on_complete condition is required for declarative steps.");
}
agentBuilder.OnComplete([.. node.OnError.Select(c => c.OnCondition!)]);
}
// ########################### Parsing node inputs ###########################
if (node.Inputs != null)View on GitHub (pinned to c028a0c7dc)
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).
Example fix
// before
node.OnComplete = new[] { new CompleteCondition { OnCondition = null } };
// after
node.OnComplete = new[] { new CompleteCondition { OnCondition = myCondition } }; Defensive patterns
Strategy: validation
Validate before calling
if (node.OnComplete is not null && node.OnComplete.Any(c => c is null || c.OnCondition is null))
throw new ArgumentException("Each on_complete entry needs a complete condition."); Type guard
static bool OnCompleteIsValid(Node n) => n.OnComplete is null || n.OnComplete.All(c => c is not null && c.OnCondition is not null);
Try / catch
try { await builder.BuildProcessAsync(workflow, yaml); }
catch (ArgumentException ex) when (ex.Message.Contains("on_complete condition is required"))
{ /* fill or remove incomplete on_complete entries */ } Prevention
- 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.
When it happens
Trigger: A declarative node whose 'on_complete' array has a null element or an element with a null/missing 'on_condition'.
Common situations: Workflow YAML listing on_complete entries where one omits the condition object; deserialization producing partial entries; copy-paste errors leaving an empty condition block.
Related errors
- Declarative steps must have an agent defined.
- Failed to build step from agent definition: {node.Id}
- Workflow nodes are not specified.
- Workflow inputs are not specified.
- Unsupported node type: {node.Type}
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/1e1eca91dc7c31cc.
Report an issue: GitHub.