{"record":{"id":"1776f155cc77d7e6","repo":"HKUDS/Vibe-Trading","slug":"session-session-id-not-found-1776f1","errorCode":null,"errorMessage":"Session {session_id} not found","messagePattern":"Session (.+?) not found","errorType":"http","errorClass":"ValueError","httpStatus":404,"severity":"error","filePath":"agent/src/session/service.py","lineNumber":271,"sourceCode":"\n        Args:\n            session_id: Session ID.\n            content: Message content.\n            role: Message role.\n            include_shell_tools: Whether this attempt may use shell tools.\n\n        Returns:\n            Dictionary containing message_id and attempt_id.\n\n        Raises:\n            ValueError: If the session does not exist.\n            SessionBusyError: If the session already has a run in progress.\n                Callers surface this as HTTP 409; the user can wait for the\n                running attempt or cancel it first.\n        \"\"\"\n        session = self.store.get_session(session_id)\n        if not session:\n            raise ValueError(f\"Session {session_id} not found\")\n\n        # Claim the session before persisting anything. Reserving after the\n        # user message is appended (or relying on _active_loops, which is only\n        # populated once the registry is built) lets two concurrent sends both\n        # store a message and create an attempt.\n        if role == \"user\":\n            self._reserve_session(session_id)\n        handed_off = False\n\n        try:\n            message = Message(session_id=session_id, role=role, content=content)\n            self.store.append_message(message)\n            self._search_index.index_message(session_id, role, content)\n            self.event_bus.emit(session_id, \"message.received\", {\"message_id\": message.message_id, \"role\": role, \"content\": content})\n\n            if role != \"user\":\n                return {\"message_id\": message.message_id}\n","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/session/service.py#L253-L289","documentation":"send_message raises ValueError when store.get_session returns nothing for the given session_id — the session was never created or has been deleted/expired from the session store.","triggerScenarios":"POSTing a message to a session id that doesn't exist; using an id from a deleted session; persistence reset (store wiped/restarted with in-memory backend) while clients held old ids; typos/truncation in the id.","commonSituations":"Dev restarts with ephemeral session storage invalidating client-held ids; expired TTL cleanup; frontend caching stale session ids; load balancer hitting a node with a different store.","solutions":["Create the session first and use the returned id for subsequent messages","Refresh/re-create the session if it was deleted or the store was reset","For durable deployments, configure a persistent session store so ids survive restarts"],"exampleFix":"# before\nsvc.send_message(\"sess-does-not-exist\", \"hello\")\n# after\nsession = svc.create_session(...)\nsvc.send_message(session.id, \"hello\")","handlingStrategy":"validation","validationCode":"if not session_service.store.get_session(session_id):\n    session = session_service.create_session(...)  # then use session.id\nassert session_service.store.get_session(session_id), \"session missing\"","typeGuard":"def session_exists(svc, sid: str) -> bool:\n    return svc.store.get_session(sid) is not None","tryCatchPattern":"try:\n    service.send_message(session_id, text)\nexcept ValueError as e:\n    if \"not found\" in str(e):\n        session = service.create_session(...)\n        service.send_message(session.id, text)","preventionTips":["Create the session first and persist its id","Handle 404 by transparently re-creating the session for users","Use durable session storage in production so ids survive restarts","Don't cache session ids across deployments that reset storage"],"tags":["session","not-found","lookup"],"backgroundTag":"resource-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}