microsoft/semantic-kernel · error · ArgumentException

At least one action must be provided.

Error message

At least one action must be provided.

What it means

Thrown by the ProcessAgentActions constructor when both the codeActions and declarativeActions parameters are null. ProcessAgentActions is a DataContract-serialized container that must hold at least one action group — an agent step with zero actions is meaningless in the process model.

Source

Thrown at dotnet/src/Experimental/Process.Abstractions/ProcessAgentActions.cs:29

[DataContract]
public sealed class ProcessAgentActions
{
    /// <summary>
    /// Creates a new instance of the <see cref="ProcessAgentActions"/> class.
    /// </summary>
    /// <param name="codeActions">The code based actions. These are not serializable to a declarative format.</param>
    /// <param name="declarativeActions">The declarative action. These are required when building an exportable process.</param>
    /// <exception cref="ArgumentException"></exception>
    public ProcessAgentActions(
        ProcessAgentCodeActions? codeActions = null,
        ProcessAgentDeclarativeActions? declarativeActions = null)
    {
        this.CodeActions = codeActions;
        this.DeclarativeActions = declarativeActions;

        if (codeActions == null && declarativeActions == null)
        {
            throw new ArgumentException("At least one action must be provided.");
        }
    }

    /// <summary>
    /// The optional handler group for code-based actions.
    /// </summary>
    public ProcessAgentCodeActions? CodeActions { get; init; }

    /// <summary>
    /// The optional handler group for declarative actions.
    /// </summary>
    public ProcessAgentDeclarativeActions? DeclarativeActions { get; init; }
}

/// <summary>
/// Represents the code-based actions that can be performed by a process agent.
/// </summary>
public sealed class ProcessAgentCodeActions

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Provide at least one non-null action group: either a ProcessAgentCodeActions or a ProcessAgentDeclarativeActions (or both).
  2. If building through ProcessAgentBuilder, ensure that you call OnComplete(...) or OnError(...) with at least one condition or that code callbacks are supplied via the constructor.
  3. For unit tests, pass a minimal ProcessAgentCodeActions with a stub OnComplete/OnError action.

Example fix

// before
var actions = new ProcessAgentActions(); // throws

// after
var actions = new ProcessAgentActions(
    codeActions: new ProcessAgentCodeActions
    {
        OnComplete = (value, ctx) => { /* ... */ }
    });
Defensive patterns

Strategy: validation

Validate before calling

public static ProcessAgentActions CreateActions(
    ProcessAgentCodeActions? code = null,
    ProcessAgentDeclarativeActions? declarative = null)
{
    if (code is null && declarative is null)
    {
        throw new ArgumentException("Provide at least one action group.", nameof(code));
    }
    return new ProcessAgentActions(code, declarative);
}

Prevention

When it happens

Trigger: Constructing a new ProcessAgentActions() with no arguments, or passing both codeActions: null and declarativeActions: null. This also occurs indirectly when ProcessAgentBuilder.BuildStep assembles a ProcessAgentActions whose nested code/declarative objects are both effectively absent (though the builder normally provides non-null wrappers).

Common situations: Manually instantiating ProcessAgentActions for testing or serialization without providing at least one action group. Building an agent step that defines neither OnComplete/OnError code callbacks nor declarative conditions.

Related errors


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