{"record":{"id":"a154490ebfbcb114","repo":"github/copilot-sdk","slug":"client-not-connected-a15449","errorCode":null,"errorMessage":"Client not connected","messagePattern":"Client not connected","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/copilot/client.py","lineNumber":2826,"sourceCode":"\n        if memory is not None:\n            payload[\"memory\"] = _memory_to_wire(memory)\n\n        if canvases:\n            payload[\"canvases\"] = [c.to_dict() for c in canvases]\n        if request_canvas_renderer is not None:\n            payload[\"requestCanvasRenderer\"] = request_canvas_renderer\n        if request_extensions is not None:\n            payload[\"requestExtensions\"] = request_extensions\n        if extension_sdk_path is not None:\n            payload[\"extensionSdkPath\"] = extension_sdk_path\n        if extension_info is not None:\n            payload[\"extensionInfo\"] = extension_info.to_dict()\n        if canvas_provider is not None:\n            payload[\"canvasProvider\"] = canvas_provider.to_dict()\n\n        if not self._client:\n            raise RuntimeError(\"Client not connected\")\n\n        total_start = time.perf_counter()\n        # For cloud sessions, let the CLI/server assign the session id and\n        # register the session lazily once the response arrives. For non-cloud\n        # sessions we generate the id client-side (when the caller didn't\n        # supply one) so the session can be registered BEFORE the RPC — the\n        # CLI may issue session-scoped requests (e.g. ``sessionFs.writeFile``\n        # for workspace metadata) during ``session.create`` processing, before\n        # it has sent the response.\n        use_server_generated_id = cloud is not None and session_id is None\n        local_session_id: str | None = (\n            None if use_server_generated_id else (session_id or str(uuid.uuid4()))\n        )\n        if local_session_id is not None:\n            payload[\"sessionId\"] = local_session_id\n        github_token_provider_registration_id = self._register_github_token_provider(\n            github_token_provider, local_session_id\n        )","sourceCodeStart":2808,"sourceCodeEnd":2844,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/python/copilot/client.py#L2808-L2844","documentation":"Lifecycle guard in CopilotClient.create_session: the method was called before the client finished connecting to the CLI runtime, or after the connection dropped, so there is no transport to carry the session.create request. It is a local sentinel precondition error, not a remote failure.","triggerScenarios":"Thrown at python/copilot/client.py:2826 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use `async with CopilotClient(...) as client` or await the connect/start call before creating sessions","Confirm the CLI process launched successfully (path, version, startup logs) - a failed start leaves the client disconnected","Reconnect after a disconnect before reusing the same client instance"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}