NousResearch/hermes-agent · error · RuntimeError

session {session_id} not found when storing title

Error message

session {session_id} not found when storing title

What it means

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.

Source

Thrown at agent/title_generator.py:459

    auto_fn = getattr(session_db, "set_auto_title", None)

    def _set(candidate):
        if auto_fn is not None:
            if not auto_fn(session_id, candidate, source=source):
                logger.debug(
                    "Skipping %s title: a higher-authority title already holds "
                    "session %s",
                    source, session_id,
                )
                return None
            return candidate
        # Older store without provenance support.
        legacy_fn = getattr(session_db, "set_auto_title_if_empty", None)
        if legacy_fn is not None:
            return candidate if legacy_fn(session_id, candidate) else None
        ok = session_db.set_session_title(session_id, candidate)
        if ok is False:
            raise RuntimeError(f"session {session_id} not found when storing title")
        return candidate

    try:
        return _set(title)
    except ValueError:
        next_title_fn = getattr(session_db, "get_next_title_in_lineage", None)
        if not dedupe or next_title_fn is None:
            raise
        deduped = next_title_fn(title)
        if not deduped or deduped == title:
            raise
        return _set(deduped)


def apply_instant_title(
    session_db,
    session_id: str,
    user_message: str,

View on GitHub (pinned to c896c09c42)

Solutions

  1. Verify the session exists before storing: session_db.get_session(session_id) (or equivalent) — skip title storage if absent.
  2. Ensure the title generator and the session store share the same HERMES_HOME/profile and the same SessionDB instance.
  3. If the session was legitimately deleted, treat the RuntimeError as benign: catch it and drop the title.
  4. Regenerate or persist the session first when the id came from an external source.

Example fix

# before
new_title = generate_and_store_title(session_db, session_id, messages)

# after
try:
    new_title = generate_and_store_title(session_db, session_id, messages)
except RuntimeError as exc:
    if "not found when storing title" in str(exc):
        new_title = None  # session gone; title is moot
    else:
        raise
Defensive patterns

Strategy: try-catch

Validate before calling

row = session_db.get_session(session_id) if hasattr(session_db, "get_session") else None
if row is None:
    skip_title_generation()  # session gone; nothing to store
else:
    title = generate_and_store_title(session_db, session_id, messages)

Try / catch

try:
    title = generate_and_store_title(session_db, session_id, messages)
except RuntimeError as exc:
    if "not found when storing title" in str(exc):
        title = None  # benign: session deleted before title stored
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14). Data as JSON: /api/errors/ee4e7e195169f447. Report an issue: GitHub.