{"record":{"id":"8394835eb24efbd3","repo":"github/copilot-sdk","slug":"runtime-process-not-started","errorCode":null,"errorMessage":"Runtime process not started","messagePattern":"Runtime process not started","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Client.cs","lineNumber":2642,"sourceCode":"    {\n        var setupTimestamp = Stopwatch.GetTimestamp();\n        NetworkStream? networkStream = null;\n        JsonRpc? rpc = null;\n\n        try\n        {\n            Stream inputStream, outputStream;\n\n            if (ffiHost is not null)\n            {\n                inputStream = ffiHost.ReceiveStream;\n                outputStream = ffiHost.SendStream;\n            }\n            else if (_connection is StdioRuntimeConnection)\n            {\n                if (cliProcess == null)\n                {\n                    throw new InvalidOperationException(\"Runtime process not started\");\n                }\n\n                inputStream = cliProcess.StandardOutput.BaseStream;\n                outputStream = cliProcess.StandardInput.BaseStream;\n            }\n            else\n            {\n                if (tcpHost is null || tcpPort is null)\n                {\n                    throw new InvalidOperationException(\"Cannot connect because TCP host or port are not available\");\n                }\n\n                var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);\n                try\n                {\n                    var tcpConnectTimestamp = Stopwatch.GetTimestamp();\n                    LogConnectingToCliServer(_logger, tcpHost, tcpPort.Value);\n                    await socket.ConnectAsync(tcpHost, tcpPort.Value, cancellationToken);","sourceCodeStart":2624,"sourceCodeEnd":2660,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/dotnet/src/Client.cs#L2624-L2660","documentation":"When the connection mode is StdioRuntimeConnection, streams are wired to the spawned CLI process's stdin/stdout. This InvalidOperationException is thrown when the connection is stdio-mode but cliProcess was never spawned. It is an internal invariant: the client was started in stdio mode without a live process.","triggerScenarios":"Calling StartAsync/stream wiring while _connection is StdioRuntimeConnection and the CLI process handle (cliProcess) is still null — e.g. process spawn failed silently or wiring ran before spawn.","commonSituations":"CLI executable path misconfigured so spawn never happened; calling client APIs before StartAsync completed; a previous process crash left the connection object alive with no process.","solutions":["Ensure the CLI process is spawned before stream wiring — check that the CLI path (cliPath) points to an existing executable.","Complete StartAsync and await it before using the client.","If a previous session crashed, create a fresh CopilotClient instead of reusing a disposed connection.","Report a bug with repro steps if spawn succeeds but cliProcess is still null — it indicates an SDK invariant violation."],"exampleFix":"// before\nvar client = new CopilotClient();\nawait client.GetSessionAsync(...); // runtime not started\n\n// after\nvar client = new CopilotClient();\nawait client.StartAsync(); // spawns CLI process first\nawait client.GetSessionAsync(...);","handlingStrategy":"try-catch","validationCode":"if (_connection is StdioRuntimeConnection && cliProcess is null)\n    throw new InvalidOperationException(\"call StartAsync before using the client\");","typeGuard":null,"tryCatchPattern":"try { await session.SendAsync(msg); }\ncatch (InvalidOperationException ex) when (ex.Message == \"Runtime process not started\")\n{ await client.StartAsync(); }","preventionTips":["Always await StartAsync before any session API call","Check the CLI path is a valid executable at construction time","Recreate the client after a process crash instead of reusing it"],"tags":["stdio","process","lifecycle","dotnet"],"backgroundTag":"internal-invariant-violation","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}