Skip to content

SessionDB.__init__ crashes on SQLite without trigram tokenizer (v0.16.0 regression) #47002

Closed

Description

@keetyHuang

Environment

  • Hermes version: v0.16.0 (2026.6.5)
  • SQLite: any build that ships fts5 but lacks the optional trigram tokenizer (e.g. SQLite 3.26, or stripped-down distros)

Description

Starting from v0.16.0, SessionDB.__init__() aborts on these SQLite builds. The session DB becomes unusable, and any tool that opens a session (including session_search) fails with a raw OperationalError.

Steps to reproduce

On a Python/SQLite runtime that does not have the trigram tokenizer, run hermes. The first SessionDB() open raises:

sqlite3.OperationalError: no such tokenizer: trigram

In tests, the bug reproduces with a cursor mock that raises this error on trigram DDL:

class _NoTrigramCursor(sqlite3.Cursor):
    def executescript(self, sql_script):
        if "tokenize='trigram'" in sql_script:
            raise sqlite3.OperationalError("no such tokenizer: trigram")
        return super().executescript(sql_script)

Root cause

hermes_state.py:_is_fts5_unavailable_error only matches the whole-module absence case:

return "no such module" in err and "fts5" in err

The trigram DDL raises "no such tokenizer: trigram" instead, which does not match. The error propagates out of _ensure_fts_schema and aborts __init__.

The trigram table is documented as optional relative to the base fts5 table, but the matcher does not catch this per-tokenizer failure mode.

Suggested fix

Extend the matcher:

@staticmethod
def _is_fts5_unavailable_error(exc):
    err = str(exc).lower()
    if "no such module" in err and "fts5" in err:
        return True
    if "no such tokenizer" in err:  # trigram etc.
        return True
    return False

Out of scope (separate consideration)

The trigram failure path also calls _warn_fts5_unavailable, which flips self._fts_enabled = False after the base fts5 table has been successfully created. That globally disables full-text search even though the base path is still usable. Fixing that likely needs a separate capability probe (e.g. inside _ensure_fts_schema), not a one-line matcher change — flagging it here so the matcher fix is not assumed to fully solve the symptom on its own.

Activity

  1. added
    type/bugSomething isn't working
    P1High — major feature broken, no workaround
    comp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint
    on Jun 16, 2026
  2. alt-glitch commented on Jun 16, 2026

    @alt-glitch

    Related: #35931 (open PR implementing this exact matcher fix — recognizes "no such tokenizer" alongside "no such module: fts5"), #41033 / #41030 (trigram capability surfacing). Verified the bug is still live on main: hermes_state.py:_is_fts5_unavailable_error only matches "no such module" in err and "fts5" in err, so the trigram OperationalError still propagates and aborts SessionDB.__init__.

  3. added a commit that references this issue on Jun 19, 2026
    0403f41
  4. teknium1 commented on Jun 19, 2026

    @teknium1
    Collaborator

    Fixed in #48688 (commits 0403f41 / c10aa5d / 9ae98e0, @channkim + @liuhao1024). SessionDB.init no longer aborts on SQLite builds that have FTS5 but lack the trigram tokenizer — _is_fts5_unavailable_error now also matches 'no such tokenizer: trigram' (scoped to trigram only), and a trigram-only failure degrades just the trigram index: base messages_fts stays enabled and searchable, CJK/substring search falls back to LIKE. Verified live — no-trigram init survives, base FTS5 search preserved.

  5. added a commit that references this issue on Jun 19, 2026
    97f88ef
  6. added a commit that references this issue on Jun 25, 2026
    17e1421
  7. added a commit that references this issue on Jul 2, 2026
    94b3b75
  8. added a commit that references this issue on Jul 8, 2026
    a5b3ecf
  9. added a commit that references this issue on Jul 13, 2026
    eff2463
  10. added a commit that references this issue on Jul 21, 2026
    34d37f5
  11. added a commit that references this issue on Aug 7, 2026
    293bff5
  12. added a commit that references this issue on Sep 3, 2026
    9d1f7fc
  13. added a commit that references this issue on Oct 6, 2026
    c3d0ccd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions