Skip to content

fix(gateway): /title command fails when session doesn't exist in SQLite yet#2379

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
ten-jampa:fix/title-command-session-not-found
Mar 21, 2026
Merged

fix(gateway): /title command fails when session doesn't exist in SQLite yet#2379
teknium1 merged 1 commit intoNousResearch:mainfrom
ten-jampa:fix/title-command-session-not-found

Conversation

@ten-jampa
Copy link
Copy Markdown
Contributor

Bug Description

When using /title as the first command in a new Telegram (or other messaging platform) chat, it fails with:

Session not found in database.

Root Cause

The gateway maintains two session stores:

  1. +session_store+ (in-memory) - auto-creates sessions on first access
  2. +_session_db+ (SQLite via hermes_state.SessionDB) - only gets sessions when the agent runs and flushes messages

When /title is used before any actual conversation, the session exists in memory but not in SQLite. The set_session_title() method does an UPDATE query which returns 0 rows affected, causing the error.

Fix

Check if the session exists in SQLite before attempting to set the title. If it doesn't exist, create it first using create_session().

Testing

  • Start a new Telegram chat with Hermes
  • Send /title My Session as the first command
  • Should now succeed instead of showing 'Session not found in database'
…te yet

The /title command would fail with 'Session not found in database.' when
used as the first command in a new session. This happened because:

1. Gateway creates session in session_store (in-memory)
2. But SQLite _session_db only gets sessions when agent flushes messages
3. set_session_title() does UPDATE which fails if row doesn't exist

Now we check if session exists in SQLite and create it if needed before
attempting to set the title.

Fixes: Session not found in database. error on /title in new chats
@teknium1 teknium1 merged commit d3659c8 into NousResearch:main Mar 21, 2026
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…te yet (NousResearch#2379)

The /title command would fail with 'Session not found in database.' when
used as the first command in a new session. This happened because:

1. Gateway creates session in session_store (in-memory)
2. But SQLite _session_db only gets sessions when agent flushes messages
3. set_session_title() does UPDATE which fails if row doesn't exist

Now we check if session exists in SQLite and create it if needed before
attempting to set the title.

Fixes: Session not found in database. error on /title in new chats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants