microsoft/semantic-kernel · error · KernelException

The step has not been initialized.

Error message

The step has not been initialized.

What it means

Thrown by LocalStep.AssignStepFunctionParameterValues when _functions, _inputs, or _initialInputs are null. These fields are populated during the lazy InitializeStepAsync call. This error means parameter assignment was attempted before the step completed initialization, or after its state was cleared.

Source

Thrown at dotnet/src/Experimental/Process.LocalRuntime/LocalStep.cs:142

    /// <returns>A <see cref="ValueTask"/></returns>
    public ValueTask EmitEventAsync(KernelProcessEvent processEvent)
    {
        Verify.NotNullOrWhiteSpace(processEvent.Id, $"{nameof(processEvent)}.{nameof(KernelProcessEvent.Id)}");

        ProcessEvent emitEvent = ProcessEvent.Create(processEvent, this._eventNamespace);
        if (this.EventProxy?.Invoke(emitEvent) ?? true)
        {
            this.EmitEvent(emitEvent);
        }

        return default;
    }

    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. Route messages through HandleMessageAsync which awaits _initializeTask.Value before calling AssignStepFunctionParameterValues.
  2. Ensure StartAsync or RunOnceAsync is called so the lazy initialization is triggered.
  3. Do not call internal methods directly; use the public/internal process API surface.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: AssignStepFunctionParameterValues is invoked on a LocalStep whose InitializeStepAsync has not yet been awaited (the _initializeTask has not completed). Under normal flow HandleMessageAsync awaits the initialization task first; direct calls bypass this guard.

Common situations: Calling AssignStepFunctionParameterValues outside of the HandleMessageAsync flow; a race condition where messages are processed before initialization; reusing a step instance after DeinitializeStepAsync.

Related errors


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