microsoft/semantic-kernel · error · KernelException

Unknown condition type: {condition.Type}

Error message

Unknown condition type: {condition.Type}

What it means

Thrown by DeclarativeEventHandlerGroupBuilder constructor when a DeclarativeProcessCondition's Type is not one of the recognized enum values: Default, Eval, or Always. This indicates either an out-of-range enum value, an undefined enum cast from an integer, or a future/unmapped condition type.

Source

Thrown at dotnet/src/Experimental/Process.Core/ProcessAgentBuilder.cs:314

                    this.EvalHandlers.Add(new DeclarativeEventHandlerBuilder(condition));
                }
                else if (condition.Type == DeclarativeProcessConditionType.Always)
                {
                    if (this.DefaultHandler is not null)
                    {
                        throw new KernelException("Only one `Always` handler is allowed in a group of event handlers.");
                    }

                    if (!string.IsNullOrWhiteSpace(condition.Expression))
                    {
                        throw new KernelException("`Always` handlers must not have an eval expression.");
                    }

                    this.AlwaysHandler = new DeclarativeEventHandlerBuilder(condition);
                }
                else
                {
                    throw new KernelException($"Unknown condition type: {condition.Type}");
                }
            }
        }
    }

    /// <summary>
    /// The list of semantic handlers for this group of event handlers.
    /// </summary>
    public DeclarativeEventHandlerBuilder? AlwaysHandler { get; init; }

    /// <summary>
    /// The optional default handler for this group of event handlers.
    /// </summary>
    public DeclarativeEventHandlerBuilder? DefaultHandler { get; set; }

    /// <summary>
    /// The list of state based handlers for this group of event handlers.
    /// </summary>

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Check the condition.Type value in the error message and correct it to one of: Default, Eval, or Always.
  2. Validate condition type strings during YAML/JSON parsing before passing to the builder.
  3. Upgrade to a version of the Process package that supports the condition type if it is a legitimate new type.

Example fix

// before — typo in YAML condition type
// conditions:
//   - type: Defualt   # misspelled

// after
// conditions:
//   - type: Default
Defensive patterns

Strategy: validation

Validate before calling

private static readonly HashSet<DeclarativeProcessConditionType> _validTypes = new()
{
    DeclarativeProcessConditionType.Default,
    DeclarativeProcessConditionType.Eval,
    DeclarativeProcessConditionType.Always
};

public static bool IsValidConditionType(DeclarativeProcessConditionType type)
    => _validTypes.Contains(type);

Type guard

public static bool IsValidConditionType(DeclarativeProcessConditionType type)
    => Enum.IsDefined(typeof(DeclarativeProcessConditionType), type)
       && (type == DeclarativeProcessConditionType.Default
           || type == DeclarativeProcessConditionType.Eval
           || type == DeclarativeProcessConditionType.Always);

Prevention

When it happens

Trigger: Passing a DeclarativeProcessCondition whose Type is an unexpected enum value (e.g., cast from an invalid integer, or a newly added enum member not yet handled by the builder). This commonly occurs when deserializing YAML/JSON with a misspelled or unsupported condition type string.

Common situations: YAML/JSON declarative process definition with a typo in the condition type field. Using a condition type from a newer SK version that this builder does not yet recognize. Casting an arbitrary integer to DeclarativeProcessConditionType producing an undefined enum member.

Related errors


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