fix: exclude tool messages from FTS indexes to prevent trigram bloat - #35826
fix: exclude tool messages from FTS indexes to prevent trigram bloat#35826503496348-ops wants to merge 1 commit into
Conversation
Tool messages (role='tool') are 72% of indexed content but useless for search. Add WHEN new.role != 'tool' to triggers. Reduces FTS index by ~80%.
|
Thanks for targeting a real FTS storage cost. This needs rework before the proposed behavior can be evaluated safely. Problems
Suggested changes
Automated hermes-sweeper review. |
|
Closing with credit — tool-row exclusion from the FTS indexes shipped on main in PR #65798 (schema v23). You were the earliest submitter on this idea (May 31) and the diagnosis was exactly right: tool output dominates indexed bytes and the trigram tokenizer amplifies it. The merged design differs in one respect: tool rows are excluded from the trigram index only, while the standard FTS index keeps them — tool-output search ( Thanks @503496348-ops for flagging this early with real numbers (650 MB → 310 MB). |
Problem
FTS triggers index ALL messages including
role='tool'(JSON execution output). Tool messages are 72% of indexed content but rarely useful for search. Trigram tokenizer amplifies to 3-5x source size.Impact: cto-bot state.db 650MB (425MB FTS) -> 310MB after fix.
Fix
WHEN new.role != 'tool'on INSERT/UPDATE triggerscontent(nottool_name+tool_calls)Storage Impact