{"record":{"id":"ee4e7e195169f447","repo":"NousResearch/hermes-agent","slug":"session-session-id-not-found-when-storing-title","errorCode":null,"errorMessage":"session {session_id} not found when storing title","messagePattern":"session (.+?) not found when storing title","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/title_generator.py","lineNumber":459,"sourceCode":"    auto_fn = getattr(session_db, \"set_auto_title\", None)\n\n    def _set(candidate):\n        if auto_fn is not None:\n            if not auto_fn(session_id, candidate, source=source):\n                logger.debug(\n                    \"Skipping %s title: a higher-authority title already holds \"\n                    \"session %s\",\n                    source, session_id,\n                )\n                return None\n            return candidate\n        # Older store without provenance support.\n        legacy_fn = getattr(session_db, \"set_auto_title_if_empty\", None)\n        if legacy_fn is not None:\n            return candidate if legacy_fn(session_id, candidate) else None\n        ok = session_db.set_session_title(session_id, candidate)\n        if ok is False:\n            raise RuntimeError(f\"session {session_id} not found when storing title\")\n        return candidate\n\n    try:\n        return _set(title)\n    except ValueError:\n        next_title_fn = getattr(session_db, \"get_next_title_in_lineage\", None)\n        if not dedupe or next_title_fn is None:\n            raise\n        deduped = next_title_fn(title)\n        if not deduped or deduped == title:\n            raise\n        return _set(deduped)\n\n\ndef apply_instant_title(\n    session_db,\n    session_id: str,\n    user_message: str,","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/title_generator.py#L441-L477","documentation":"Raised in agent/title_generator.py when session_db.set_session_title(session_id, candidate) returns exactly False after the provenance-aware and legacy set_auto_title_if_empty paths were unavailable/did not apply. set_session_title returning False means the session row for session_id does not exist in the SQLite session store, so the generated title has nowhere to land.","triggerScenarios":"Generating a title for a session_id that was deleted (or never committed) in the SessionDB; a session DB path mismatch (wrong HERMES_HOME/profile so a fresh empty DB is used); the session being garbage-collected between conversation end and async title generation; passing an externally-constructed session_id that was never persisted.","commonSituations":"Async/background title generation racing session deletion or /new; running with a different profile (-p) than the one that owns the session; tests using a temp HERMES_HOME where the session row was never created; session store schema or DB file swapped mid-process.","solutions":["Verify the session exists before storing: session_db.get_session(session_id) (or equivalent) — skip title storage if absent.","Ensure the title generator and the session store share the same HERMES_HOME/profile and the same SessionDB instance.","If the session was legitimately deleted, treat the RuntimeError as benign: catch it and drop the title.","Regenerate or persist the session first when the id came from an external source."],"exampleFix":"# before\nnew_title = generate_and_store_title(session_db, session_id, messages)\n\n# after\ntry:\n    new_title = generate_and_store_title(session_db, session_id, messages)\nexcept RuntimeError as exc:\n    if \"not found when storing title\" in str(exc):\n        new_title = None  # session gone; title is moot\n    else:\n        raise","handlingStrategy":"try-catch","validationCode":"row = session_db.get_session(session_id) if hasattr(session_db, \"get_session\") else None\nif row is None:\n    skip_title_generation()  # session gone; nothing to store\nelse:\n    title = generate_and_store_title(session_db, session_id, messages)","typeGuard":null,"tryCatchPattern":"try:\n    title = generate_and_store_title(session_db, session_id, messages)\nexcept RuntimeError as exc:\n    if \"not found when storing title\" in str(exc):\n        title = None  # benign: session deleted before title stored\n    else:\n        raise","preventionTips":["Confirm the session row exists before triggering async title generation.","Keep title generation and the session store on the same HERMES_HOME/profile and SessionDB instance.","Expect races with session deletion in async flows; treat this error as skippable noise."],"tags":["sessions","title-generation","sqlite","session-store"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}