microsoft/semantic-kernel · error · KernelException
Step {step.Goal} requires arguments {string.Join(",", step.R
Error message
Step {step.Goal} requires arguments {string.Join(",", step.Requires.Where(p => !context.ContainsName(p)))} that are not provided. What it means
Before executing a flow step, FlowExecutor.ValidateStep checks that every name in step.Requires is present in the KernelArguments context. If any required variable is missing, KernelException lists the specific missing argument names. This prevents a step from running with incomplete inputs that would produce garbage.
Source
Thrown at dotnet/src/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs:493
{
// kvp.Value may contain empty strings when the loop was exited and the arguments the step provides weren't set
state.Variables[kvp.Key] = JsonSerializer.Serialize(kvp.Value.Where(x => !string.IsNullOrWhiteSpace(x)).ToList());
}
}
foreach (var variable in step.Provides)
{
context[variable] = state.Variables[variable];
}
await this._flowStatusProvider.SaveExecutionStateAsync(sessionId, state).ConfigureAwait(false);
}
private void ValidateStep(FlowStep step, KernelArguments context)
{
if (step.Requires.Any(p => !context.ContainsName(p)))
{
throw new KernelException($"Step {step.Goal} requires arguments {string.Join(",", step.Requires.Where(p => !context.ContainsName(p)))} that are not provided. ");
}
}
private async Task<RepeatOrStartStepResult?> CheckStartStepAsync(KernelArguments context, FlowStep step, string sessionId, string stepId, string input)
{
context = new KernelArguments(context)
{
["goal"] = step.Goal,
["message"] = step.StartingMessage
};
return await this.CheckRepeatOrStartStepAsync(context, this._checkStartStepFunction, sessionId, $"{stepId}_CheckStartStep", input).ConfigureAwait(false);
}
private async Task<RepeatOrStartStepResult?> CheckRepeatStepAsync(KernelArguments context, FlowStep step, string sessionId, string nextStepId, string input)
{
context = new KernelArguments(context)
{
["goal"] = step.Goal,View on GitHub (pinned to c028a0c7dc)
Solutions
- Before executing, verify all step.Requires names are present in the KernelArguments: check with context.ContainsName(name) for each.
- Inspect the flow definition to ensure each step's Provides covers the next step's Requires.
- Seed initial arguments with all required variables for the first step.
- Check for variable name mismatches (casing, typos) between Requires definitions and argument keys.
Example fix
// before — step requires 'topic' but it's missing
var args = new KernelArguments { ["input"] = "hello" };
await executor.ExecuteAsync(sessionId, flow, args);
// after — provide all required arguments
var args = new KernelArguments { ["input"] = "hello", ["topic"] = "science" };
await executor.ExecuteAsync(sessionId, flow, args); Defensive patterns
Strategy: validation
Validate before calling
// Validate all required arguments are present before executing the step
var missing = step.Requires.Where(p => !arguments.ContainsName(p)).ToList();
if (missing.Count > 0)
{
throw new ArgumentException(
$"Step '{step.Goal}' is missing required arguments: {string.Join(", ", missing)}");
} Try / catch
try { await executor.ExecuteAsync(sessionId, flow, arguments); }
catch (KernelException ex) when (ex.Message.Contains("requires arguments"))
{
logger.LogError(ex, "Step missing inputs. Ensure prior steps provide them.");
throw;
} Prevention
- Validate the flow definition: every step's Requires must be covered by a prior step's Provides or by initial arguments.
- Seed all initial arguments for the first step before starting the flow.
- Use a flow-validation pass at startup to detect dangling Requires across steps.
When it happens
Trigger: Executing a FlowStep whose Requires collection includes variables that were not populated in the KernelArguments passed to the executor. This happens when a prior step didn't produce an expected output, or when initial arguments are incomplete.
Common situations: A flow is started without seeding all initial variables the first step needs. A preceding step's Provides list doesn't include a variable that a later step Requires (flow definition mismatch). Variable name typo between step.Requires and the argument keys.
Related errors
- Failed to complete step {stepId} for session {sessionId}.
- Missing agent description: {agent.Name ?? agent.Id}
- Entry agent is not defined.
- The agent {agent.Name ?? agent.Id} cannot have a handoff to
- The following agents are not defined in the orchestration: {
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/7add2c8337eb1801.
Report an issue: GitHub.