Skip to content

fix(hermes_state): gracefully degrade when SQLite build lacks FTS5#13222

Closed
hclsys wants to merge 1 commit into
NousResearch:mainfrom
hclsys:fix/session-db-fts5-graceful-degrade-13029
Closed

fix(hermes_state): gracefully degrade when SQLite build lacks FTS5#13222
hclsys wants to merge 1 commit into
NousResearch:mainfrom
hclsys:fix/session-db-fts5-graceful-degrade-13029

Conversation

@hclsys

@hclsys hclsys commented Apr 20, 2026

Copy link
Copy Markdown

Problem

Some SQLite builds (Python 3.11 on macOS via certain Homebrew and pyenv formulae) compile `sqlite3` without the FTS5 module. When FTS5 is missing, `CREATE VIRTUAL TABLE ... USING fts5(...)` throws `sqlite3.OperationalError: no such module: fts5`.

Before this patch, that error killed `SessionDB` init completely — every SQLite-backed feature (`hermes sessions list`, `hermes insights`, external tools like Scarf reading `state.db`) failed silently while the JSONL fallback kept the primary WhatsApp/CLI chat flow working. Reported by @chillprakash in #13029 with clear repro on macOS ARM64 + Python 3.11.13.

Fix

Init path (`hermes_state.py:343-378`): catch the `OperationalError` when the message matches `no such module / fts5`, log a one-time warning with a remediation hint (switch to Python 3.12/3.13/3.14 with FTS5 built in, or rebuild SQLite with FTS5 enabled), and set `self._fts5_available = False`. Other `OperationalError`s are still re-raised so legitimate schema bugs aren't swallowed.

Search path (`search_messages`): when `_fts5_available` is `False`, skip the `MATCH` branch entirely and route into the existing LIKE fallback that already handles CJK queries. No new fallback code — just extending the existing condition.

Pre-implement audit

  • A (existing helper): the LIKE fallback for CJK was already there; I reuse it rather than inventing a new one. ✓
  • B (shared callers): `SessionDB` is the single owner; init contract becomes strictly more permissive (never throws FTS5-missing), no downstream contract change. ✓
  • C (broader rival): `gh pr list --search "13029"` returned no rivals. ✓

Testing

  • New `TestFTS5Search::test_search_falls_back_to_like_when_fts5_unavailable` — creates 2 messages, flips `_fts5_available = False`, asserts `search_messages("docker")` returns both messages via LIKE.
  • Full `tests/test_hermes_state.py` suite passes (160/160).

Fixes #13029

Some SQLite builds (Python 3.11 on macOS via certain Homebrew and
pyenv installations) compile sqlite3 without the FTS5 module. When
FTS5 is missing, CREATE VIRTUAL TABLE ... USING fts5(...) throws
"no such module: fts5", which killed every SQLite-backed feature
because SessionDB init never completed: sessions list, insights,
external Scarf readers all failed while the JSONL fallback kept
the primary flow working and hid the failure.

Detect the FTS5-missing OperationalError during init, record the
state in self._fts5_available, and log a one-time warning. In
search_messages, skip the MATCH query when FTS5 is unavailable and
route through the existing LIKE fallback that was already used for
CJK queries. Non-search features (session list, history, insights
primary path) keep working unchanged.

Fixes NousResearch#13029
@hclsys

hclsys commented Apr 21, 2026

Copy link
Copy Markdown
Author

Closing for queue hygiene — crossed the 20h inherited ceiling with zero maintainer engagement. The SessionDB FTS5 graceful-degradation fix for #13029 remains clean and re-submittable — Python 3.11/macOS users hitting the 'no such module: fts5' crash still benefit from the fallback path.

@hclsys hclsys closed this Apr 21, 2026
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder labels Apr 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #10972 — same fix: graceful FTS5 degradation in SessionDB with LIKE fallback.

2 similar comments
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #10972 — same fix: graceful FTS5 degradation in SessionDB with LIKE fallback.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #10972 — same fix: graceful FTS5 degradation in SessionDB with LIKE fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session store fails to open when SQLite lacks FTS5 module (common on Python 3.11 macOS installs)

2 participants