{"record":{"id":"6a836504641505a0","repo":"github/copilot-sdk","slug":"unknown-session-session-id","errorCode":null,"errorMessage":"unknown session {session_id}","messagePattern":"unknown session (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/copilot/client.py","lineNumber":4925,"sourceCode":"                registration = self._github_token_providers.get(registration_id)\n                if registration is not None:\n                    registration.session_id = session_id\n                    registration.committed = True\n\n    def _get_session(self, session_id: str) -> CopilotSession | None:\n        with self._sessions_lock:\n            return self._sessions.get(session_id)\n\n    async def _set_llm_inference_provider(self) -> None:\n        if self._request_handler is None or self._rpc is None:\n            return\n        await self._rpc.llm_inference.set_provider()\n\n    def _get_client_session_handlers(self, session_id: str) -> ClientSessionApiHandlers:\n        with self._sessions_lock:\n            session = self._sessions.get(session_id)\n        if session is None:\n            raise ValueError(f\"unknown session {session_id}\")\n        return session._client_session_apis\n\n    async def _handle_user_input_request(self, params: dict) -> dict:\n        \"\"\"\n        Handle a user input request from the CLI server.\n\n        Args:\n            params: The user input request parameters from the server.\n\n        Returns:\n            A dict containing the user's response.\n\n        Raises:\n            ValueError: If the request payload is invalid.\n        \"\"\"\n        session_id = params.get(\"sessionId\")\n        question = params.get(\"question\")\n","sourceCodeStart":4907,"sourceCodeEnd":4943,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/python/copilot/client.py#L4907-L4943","documentation":"ValueError raised by _get_client_session_handlers when no session is registered under the given session_id in self._sessions. The library looked up the session map and found nothing for that identifier.","triggerScenarios":"A callback/dispatch referencing a sessionId that was never created, was already deleted, or whose session object was removed; a stale or malformed session id passed to session-handler lookup.","commonSituations":"Events arriving after session disposal; client reconnecting with an old session id; resuming a session in a new process where the in-memory map is empty; a typo or parsing bug producing a wrong sessionId string.","solutions":["Verify the session was created (start_session/create session call) before use and keep the returned id","Check for events arriving after session disposal; ignore or re-create the session as appropriate","Ensure the same CopilotClient instance that created the session handles its callbacks","Log the sessionId and the set of known session ids to spot stale/mismatched identifiers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"with client._sessions_lock:\n    if session_id not in client._sessions:\n        log.warning(\"stale session callback %s ignored\", session_id)\n        return None","typeGuard":"def session_exists(client, session_id: str) -> bool:\n    with client._sessions_lock:\n        return session_id in client._sessions","tryCatchPattern":"try:\n    handlers = client._get_client_session_handlers(session_id)\nexcept ValueError as e:\n    if str(e).startswith(\"unknown session\"):\n        recreate_or_ignore_session(session_id)\n    else:\n        raise","preventionTips":["Keep session objects alive until all callbacks are drained","Ignore events for sessions you've disposed","Never reuse session ids across client instances or restarts","Log known session ids when an unknown-session error occurs"],"tags":["session","lookup","state"],"backgroundTag":"record-not-found","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"}