microsoft/semantic-kernel · error · KernelException

The step has not been initialized.

Error message

The step has not been initialized.

What it means

StepActor.AssignStepFunctionParameterValues checks that _functions, _inputs, and _initialInputs are non-null. These are populated during ActivateStepAsync (lazy via _activateTask). If activation has not completed or failed, the fields remain in an uninitialized state and this KernelException is thrown.

Source

Thrown at dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs:225

    /// <summary>
    /// The name of the step.
    /// </summary>
    protected virtual string Name => this._stepInfo?.State.Name ?? throw new KernelException("The Step must be initialized before accessing the Name property.").Log(this._logger);

    /// <summary>
    /// Emits an event from the step.
    /// </summary>
    /// <param name="processEvent">The event to emit.</param>
    /// <returns>A <see cref="ValueTask"/></returns>
    public ValueTask EmitEventAsync(KernelProcessEvent processEvent) => this.EmitEventAsync(ProcessEvent.Create(processEvent, this._eventNamespace!));

    // TODO: this can be moved to shared runtime code, looks almost/same to localRuntime implementation
    internal virtual void AssignStepFunctionParameterValues(ProcessMessage message)
    {
        if (this._functions is null || this._inputs is null || this._initialInputs is null)
        {
            throw new KernelException("The step has not been initialized.").Log(this._logger);
        }

        // Add the message values to the inputs for the function
        foreach (var kvp in message.Values)
        {
            if (this._inputs.TryGetValue(message.FunctionName, out Dictionary<string, object?>? functionName) && functionName != null && functionName.TryGetValue(kvp.Key, out object? parameterName) && parameterName != null)
            {
                this._logger?.LogWarning("Step {StepName} already has input for {FunctionName}.{Key}, it is being overwritten with a message from Step named '{SourceId}'.", this.Name, message.FunctionName, kvp.Key, message.SourceId);
            }

            if (!this._inputs.TryGetValue(message.FunctionName, out Dictionary<string, object?>? functionParameters))
            {
                this._inputs[message.FunctionName] = [];
                functionParameters = this._inputs[message.FunctionName];
            }

            if (kvp.Value is KernelProcessEventData proxyData)
            {

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure the Kernel's service provider can resolve all dependencies needed by ActivatorUtilities.CreateInstance for the step type.
  2. Check that ActivateStepAsync did not throw by inspecting the faulted Lazy<ValueTask> — look for earlier logged exceptions from the step actor.
  3. In tests, trigger lazy activation by awaiting the activate task before calling AssignStepFunctionParameterValues directly.
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure activation succeeds by triggering it through a normal method call first:
await stepActor.InitializeStepAsync(stepInfo, parentProcessId);
// Trigger lazy activation:
try { await stepActor.PrepareIncomingMessagesAsync(); }
catch (Exception ex) { logger.LogError(ex, "Step activation failed; check DI and state type."); }

Try / catch

try
{
    await stepActor.ProcessIncomingMessagesAsync();
}
catch (KernelException ex) when (ex.Message.Contains("step has not been initialized"))
{
    logger.LogError("Step activation failed. Inspect earlier logs for the root cause (DI, type loading, or state deserialization).");
}

Prevention

When it happens

Trigger: AssignStepFunctionParameterValues is called before ActivateStepAsync has populated the function/input dictionaries. Since HandleMessageAsync awaits _activateTask.Value before calling this method, the throw indicates activation faulted or was bypassed.

Common situations: ActivateStepAsync threw an exception (e.g. DI resolution failure, method-not-found, state deserialization error) that was stored in the Lazy<ValueTask> and surfaces here. Also from direct calls in tests that skip activation.

Related errors


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