github/copilot-sdk · error · RuntimeError
Client not connected
Error message
Client not connected
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at python/copilot/client.py:2826 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/a154490ebfbcb114.
Report an issue: GitHub.
Appendix: source
Thrown at python/copilot/client.py:2826
if memory is not None:
payload["memory"] = _memory_to_wire(memory)
if canvases:
payload["canvases"] = [c.to_dict() for c in canvases]
if request_canvas_renderer is not None:
payload["requestCanvasRenderer"] = request_canvas_renderer
if request_extensions is not None:
payload["requestExtensions"] = request_extensions
if extension_sdk_path is not None:
payload["extensionSdkPath"] = extension_sdk_path
if extension_info is not None:
payload["extensionInfo"] = extension_info.to_dict()
if canvas_provider is not None:
payload["canvasProvider"] = canvas_provider.to_dict()
if not self._client:
raise RuntimeError("Client not connected")
total_start = time.perf_counter()
# For cloud sessions, let the CLI/server assign the session id and
# register the session lazily once the response arrives. For non-cloud
# sessions we generate the id client-side (when the caller didn't
# supply one) so the session can be registered BEFORE the RPC — the
# CLI may issue session-scoped requests (e.g. ``sessionFs.writeFile``
# for workspace metadata) during ``session.create`` processing, before
# it has sent the response.
use_server_generated_id = cloud is not None and session_id is None
local_session_id: str | None = (
None if use_server_generated_id else (session_id or str(uuid.uuid4()))
)
if local_session_id is not None:
payload["sessionId"] = local_session_id
github_token_provider_registration_id = self._register_github_token_provider(
github_token_provider, local_session_id
)View on GitHub (pinned to cd8cf15dc3)