microsoft/semantic-kernel · error · ArgumentException

A complete listen_for condition is required for orchestratio

Error message

A complete listen_for condition is required for orchestration steps.

What it means

Thrown by BuildOrchestrationAsync when an OrchestrationStep has a null ListenFor. Orchestration steps are listen/then rules; a missing listen_for makes the rule unprocessable, so the builder rejects it before attempting to wire edges.

Source

Thrown at dotnet/src/Experimental/Process.Core/Workflow/WorkflowBuilder.cs:236

    #endregion

    #region Orchestration

    private Task BuildOrchestrationAsync(List<OrchestrationStep> orchestrationSteps, ProcessBuilder processBuilder)
    {
        // If there are no orchestration steps, return
        if (orchestrationSteps.Count == 0)
        {
            return Task.CompletedTask;
        }

        // Process the orchestration steps
        foreach (var step in orchestrationSteps)
        {
            ListenCondition? listenCondition = step.ListenFor;
            if (listenCondition is null)
            {
                throw new ArgumentException("A complete listen_for condition is required for orchestration steps.");
            }

            List<ThenAction>? thenActions = step.Then;
            if (thenActions is null || thenActions.Count == 0)
            {
                throw new ArgumentException("At least one then action is required for orchestration steps.");
            }

            ProcessStepEdgeBuilder? edgeBuilder = null;

            if (listenCondition.AllOf != null && listenCondition.AllOf.Count > 0)
            {
                MessageSourceBuilder GetSourceBuilder(ListenEvent listenEvent)
                {
                    var sourceBuilder = this.FindSourceBuilder(new() { Event = listenEvent.Event, From = listenEvent.From }, processBuilder);
                    return new MessageSourceBuilder
                    (
                        messageType: listenEvent.Event,

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Add a complete 'listen_for' object to each orchestration step before 'then'.
  2. Validate step.ListenFor != null for every orchestration step before building.
  3. Remove orchestration entries that have no trigger condition if they are vestigial.

Example fix

// before
step.ListenFor = null; step.Then = new List<ThenAction> { ... };

// after
step.ListenFor = new ListenCondition { /* AllOf/AnyOf etc. */ };
Defensive patterns

Strategy: validation

Validate before calling

foreach (var s in orchestrationSteps)
    if (s.ListenFor is null) throw new ArgumentException($"Orchestration step missing listen_for.");

Type guard

static bool ListenForPresent(OrchestrationStep s) => s.ListenFor is not null;

Try / catch

try { await builder.BuildProcessAsync(workflow, yaml); }
catch (ArgumentException ex) when (ex.Message.Contains("listen_for condition is required"))
{ /* add the listen_for block */ }

Prevention

When it happens

Trigger: A workflow orchestration entry whose 'listen_for' is null/omitted while 'then' is present, or both missing with listen_for checked first.

Common situations: Workflow YAML with an orchestration block that lists 'then' actions but no 'listen_for'; deserialization leaving ListenFor null; partial rule definitions.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/be5064b433e36c99. Report an issue: GitHub.