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 ProcessAgentCodeActionsView on GitHub (pinned to c028a0c7dc)
Solutions
- Provide at least one non-null action group: either a ProcessAgentCodeActions or a ProcessAgentDeclarativeActions (or both).
- 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.
- 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
- Always pass at least one non-null action group to ProcessAgentActions.
- Use the ProcessAgentBuilder API rather than constructing ProcessAgentActions directly.
- In tests, provide minimal stub ProcessAgentCodeActions.
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
- AgentDefinition.Name cannot be null or empty.
- AgentDefinition.Id cannot be null or empty.
- All declarative agents must have an Id or a Name assigned.
- AgentDefinition Id must be set
- Expression must be a property access expression
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/0cb136cfe1f9f792.
Report an issue: GitHub.