fix(state): exclude tool calls from trigram FTS

Keep structured tool_calls searchable through the standard FTS index while
removing their repetitive JSON from the trigram projection. Reuse the
existing optimize-storage rebuild path for deployed v1 layouts.

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
This commit is contained in:
Andrew Wikel
2026-08-17 01:49:25 -05:00
committed by kshitij
parent f39b749c4b
commit 5a7bee0fa8
5 changed files with 223 additions and 39 deletions
+5 -2
View File
@@ -1528,7 +1528,10 @@ class SessionSchemaMixin:
# advances to SCHEMA_VERSION here like every other migration —
# future v24+ migrations land automatically for legacy-FTS
# users too. Only the FTS *layout* waits for opt-in.
if fts5_available and self._db_has_legacy_inline_fts(cursor):
if (
fts5_available
and self._db_needs_fts_storage_upgrade(cursor)
):
self.set_meta("fts_optimize_available", "1", cursor=cursor)
if current_version < 25:
@@ -1561,7 +1564,7 @@ class SessionSchemaMixin:
# transition actually completes.
if (
fts5_available
and not self._db_has_legacy_inline_fts(cursor)
and not self._db_needs_fts_storage_upgrade(cursor)
and cursor.execute(
"SELECT 1 FROM state_meta "
"WHERE key = 'fts_rebuild_high_water' LIMIT 1"