{"record":{"id":"49831ded18080c97","repo":"microsoft/semantic-kernel","slug":"the-process-state-manager-is-not-initialized","errorCode":null,"errorMessage":"The process state manager is not initialized.","messagePattern":"The process state manager is not initialized\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.LocalRuntime/LocalProcess.cs","lineNumber":419,"sourceCode":"        {\n            if (edge.Condition.DeclarativeDefinition?.Equals(ProcessConstants.Declarative.DefaultCondition, StringComparison.OrdinalIgnoreCase) ?? false)\n            {\n                defaultConditionedEdges.Add(edge);\n                continue;\n            }\n\n            bool isConditionMet = await edge.Condition.Callback(processEvent.ToKernelProcessEvent(), this._processStateManager?.GetState()).ConfigureAwait(false);\n            if (!isConditionMet)\n            {\n                continue;\n            }\n\n            // Handle different target types\n            if (edge.OutputTarget is KernelProcessStateTarget stateTarget)\n            {\n                if (this._processStateManager is null)\n                {\n                    throw new KernelException(\"The process state manager is not initialized.\").Log(this._logger);\n                }\n\n                await (this._processStateManager.ReduceAsync((stateType, state) =>\n                {\n                    var stateJson = JsonDocument.Parse(JsonSerializer.Serialize(state));\n                    stateJson = JMESUpdate.UpdateState(stateJson, stateTarget.VariableUpdate.Path, stateTarget.VariableUpdate.Operation, stateTarget.VariableUpdate.Value);\n                    return Task.FromResult(stateJson.Deserialize(stateType));\n                })).ConfigureAwait(false);\n            }\n            else if (edge.OutputTarget is KernelProcessEmitTarget emitTarget)\n            {\n                // Emit target from process\n            }\n            else if (edge.OutputTarget is KernelProcessFunctionTarget functionTarget)\n            {\n                ProcessMessage message = ProcessMessageFactory.CreateFromEdge(edge, processEvent.SourceId, processEvent.Data);\n                messageChannel.Enqueue(message);\n            }","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.LocalRuntime/LocalProcess.cs#L401-L437","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the KernelProcess is constructed with a valid UserStateType when using KernelProcessStateTarget edges.","Verify that StartAsync or RunOnceAsync is called (which triggers lazy initialization via _initializeTask) before any messages reach state-target edges.","If this is a sub-process, confirm the parent process properly initializes it through InitializeProcessAsync.","Remove state-target edges from processes that do not declare a UserStateType."],"exampleFix":"// before - process has no UserStateType but uses state targets\nvar process = new KernelProcess(state, steps, edges);\n// after - provide UserStateType\nvar process = new KernelProcess(state, steps, edges, userStateType: typeof(MyProcessState));","handlingStrategy":"validation","validationCode":"// Validate that state-target edges only exist on processes with a UserStateType\nbool hasStateTargets = process.Edges.Values\n    .SelectMany(edges => edges)\n    .Any(e => e.OutputTarget is KernelProcessStateTarget);\nif (hasStateTargets && process.UserStateType is null)\n{\n    throw new InvalidOperationException(\"Process uses KernelProcessStateTarget edges but has no UserStateType configured.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set UserStateType on KernelProcess when using state-target edges.","Run a validation pass before StartAsync to check for state-target edges without a configured state type.","Avoid mixing stateless processes with state-management edges."],"tags":["process-framework","state-management","initialization","edges"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}