microsoft/semantic-kernel · error · KernelException

The process state manager is not initialized.

Error message

The process state manager is not initialized.

What it means

Thrown in LocalProcess.EnqueueEdgesAsync when an edge's OutputTarget is a KernelProcessStateTarget but this._processStateManager is null. The process state manager is created during InitializeProcessAsync (line 211); reaching this throw means a state-target edge is being processed while the state manager was not initialized, which points to either a process that bypassed initialization or a state-target edge on a process that has no UserStateType configured.

Source

Thrown at dotnet/src/Experimental/Process.LocalRuntime/LocalProcess.cs:419

        {
            if (edge.Condition.DeclarativeDefinition?.Equals(ProcessConstants.Declarative.DefaultCondition, StringComparison.OrdinalIgnoreCase) ?? false)
            {
                defaultConditionedEdges.Add(edge);
                continue;
            }

            bool isConditionMet = await edge.Condition.Callback(processEvent.ToKernelProcessEvent(), this._processStateManager?.GetState()).ConfigureAwait(false);
            if (!isConditionMet)
            {
                continue;
            }

            // Handle different target types
            if (edge.OutputTarget is KernelProcessStateTarget stateTarget)
            {
                if (this._processStateManager is null)
                {
                    throw new KernelException("The process state manager is not initialized.").Log(this._logger);
                }

                await (this._processStateManager.ReduceAsync((stateType, state) =>
                {
                    var stateJson = JsonDocument.Parse(JsonSerializer.Serialize(state));
                    stateJson = JMESUpdate.UpdateState(stateJson, stateTarget.VariableUpdate.Path, stateTarget.VariableUpdate.Operation, stateTarget.VariableUpdate.Value);
                    return Task.FromResult(stateJson.Deserialize(stateType));
                })).ConfigureAwait(false);
            }
            else if (edge.OutputTarget is KernelProcessEmitTarget emitTarget)
            {
                // Emit target from process
            }
            else if (edge.OutputTarget is KernelProcessFunctionTarget functionTarget)
            {
                ProcessMessage message = ProcessMessageFactory.CreateFromEdge(edge, processEvent.SourceId, processEvent.Data);
                messageChannel.Enqueue(message);
            }

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure the KernelProcess is constructed with a valid UserStateType when using KernelProcessStateTarget edges.
  2. Verify that StartAsync or RunOnceAsync is called (which triggers lazy initialization via _initializeTask) before any messages reach state-target edges.
  3. If this is a sub-process, confirm the parent process properly initializes it through InitializeProcessAsync.
  4. Remove state-target edges from processes that do not declare a UserStateType.

Example fix

// before - process has no UserStateType but uses state targets
var process = new KernelProcess(state, steps, edges);
// after - provide UserStateType
var process = new KernelProcess(state, steps, edges, userStateType: typeof(MyProcessState));
Defensive patterns

Strategy: validation

Validate before calling

// Validate that state-target edges only exist on processes with a UserStateType
bool hasStateTargets = process.Edges.Values
    .SelectMany(edges => edges)
    .Any(e => e.OutputTarget is KernelProcessStateTarget);
if (hasStateTargets && process.UserStateType is null)
{
    throw new InvalidOperationException("Process uses KernelProcessStateTarget edges but has no UserStateType configured.");
}

Prevention

When it happens

Trigger: An edge with OutputTarget of type KernelProcessStateTarget is evaluated, but _processStateManager (initialized from the process's UserStateType) is null. This can happen if the process was constructed in a way that skipped InitializeProcessAsync, or if UserStateType is null/empty while state-target edges are still defined.

Common situations: Adding state-management edges to a process without configuring UserStateType on the KernelProcess; a race condition or ordering issue where edges are enqueued before initialization completes; using state targets in a sub-process whose initialization path differs.

Related errors


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