{"record":{"id":"66293b1f99607c7f","repo":"microsoft/semantic-kernel","slug":"the-process-cannot-be-started-before-it-has-been-i","errorCode":null,"errorMessage":"The process cannot be started before it has been initialized.","messagePattern":"The process cannot be started before it has been initialized\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Runtime.Dapr/Actors/ProcessActor.cs","lineNumber":85,"sourceCode":"        await this.StateManager.AddStateAsync(ActorStateKeys.StepParentProcessId, parentProcessId).ConfigureAwait(false);\n        await this.StateManager.AddStateAsync(ActorStateKeys.StepActivatedState, true).ConfigureAwait(false);\n        if (!string.IsNullOrWhiteSpace(eventProxyStepId))\n        {\n            await this.StateManager.AddStateAsync(ActorStateKeys.EventProxyStepId, eventProxyStepId).ConfigureAwait(false);\n        }\n        await this.StateManager.SaveStateAsync().ConfigureAwait(false);\n    }\n\n    /// <summary>\n    /// Starts the process with an initial event and an optional kernel.\n    /// </summary>\n    /// <param name=\"keepAlive\">Indicates if the process should wait for external events after it's finished processing.</param>\n    /// <returns> <see cref=\"Task\"/></returns>\n    public Task StartAsync(bool keepAlive)\n    {\n        if (!this._isInitialized)\n        {\n            throw new InvalidOperationException(\"The process cannot be started before it has been initialized.\").Log(this._logger);\n        }\n\n        this._processCancelSource = new CancellationTokenSource();\n        this._processTask = this._joinableTaskFactory.RunAsync(()\n            => this.Internal_ExecuteAsync(keepAlive: keepAlive, cancellationToken: this._processCancelSource.Token));\n\n        return Task.CompletedTask;\n    }\n\n    /// <summary>\n    /// Starts the process with an initial event and then waits for the process to finish. In this case the process will not\n    /// keep alive waiting for external events after the internal messages have stopped.\n    /// </summary>\n    /// <param name=\"processEvent\">Required. The <see cref=\"KernelProcessEvent\"/> to start the process with.</param>\n    /// <returns>A <see cref=\"Task\"/></returns>\n    public async Task RunOnceAsync(string processEvent)\n    {\n        Verify.NotNull(processEvent, nameof(processEvent));","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Runtime.Dapr/Actors/ProcessActor.cs#L67-L103","documentation":"Thrown as InvalidOperationException by ProcessActor.StartAsync when _isInitialized is false. The process actor must first be initialized via InitializeProcessAsync (which builds the step graph and saves state) before StartAsync can launch the Pregel execution loop. Calling StartAsync on a fresh or un-initialized actor triggers this guard.","triggerScenarios":"ProcessActor.StartAsync is called before InitializeProcessAsync has completed, or the actor was re-activated from scratch (no persisted state) and OnActivateAsync did not find existing process info to restore, leaving _isInitialized false.","commonSituations":"Calling StartAsync directly on a new ProcessActor without going through InitializeProcessAsync; a Dapr actor re-activation where the state store lost the persisted process info; incorrect actor id causing activation of a fresh actor instead of the intended one; state store connectivity issues during OnActivateAsync.","solutions":["Always call InitializeProcessAsync with a valid DaprProcessInfo before calling StartAsync.","Verify the Dapr state store is healthy so that OnActivateAsync can restore the process on re-activation.","Ensure the actor id used for StartAsync matches the one used during InitializeProcessAsync.","Use the DaprKernelProcessContext API rather than calling actor methods directly."],"exampleFix":"// before - calling StartAsync without initialization\nawait processActor.StartAsync(keepAlive: true);\n// after - initialize first\nawait processActor.InitializeProcessAsync(processInfo, parentProcessId).ConfigureAwait(false);\nawait processActor.StartAsync(keepAlive: true).ConfigureAwait(false);","handlingStrategy":"validation","validationCode":"// Always initialize the process actor before starting it\nawait processActor.InitializeProcessAsync(processInfo, parentProcessId).ConfigureAwait(false);\n// Then start\nawait processActor.StartAsync(keepAlive: true).ConfigureAwait(false);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call InitializeProcessAsync before StartAsync.","Use DaprKernelProcessContext which manages the initialize-then-start lifecycle.","Verify the Dapr state store is healthy so OnActivateAsync can restore process info on re-activation.","Ensure actor ids are consistent between initialization and start calls."],"tags":["process-framework","dapr","process","initialization","actor"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}