fix: clarify FTS5 query guidance for recall tools#332
Merged
Conversation
Clarify the lossless recall prompt and tool metadata so agents treat lcm_expand_query(query=...) the same way as lcm_grep full-text search. Add explicit guidance that FTS5 defaults to AND matching, that query strings should stay short and distinctive, and that prompt carries the natural-language question while query is only for recall matching. Regeneration-Prompt: | Improve the system prompt guidance for lcm_expand_query in the lossless-claw codebase. Agents were over-stuffing query with lots of keywords because they did not realize lcm_expand_query(query=...) runs through the same FTS5 full-text search path as lcm_grep, where terms are ANDed by default and extra words can force zero matches. Update the static recall policy and any session-specific compacted context guidance so it explicitly says query follows the same FTS5 rules as lcm_grep, that more terms make matching stricter rather than broader, that query should usually be 1-3 distinctive terms or a quoted phrase without synonym padding, and that prompt is where the natural-language answer request belongs. Tighten the lcm_grep and lcm_expand_query tool description/schema text so query construction is harder to misuse, add regression tests for the prompt and metadata strings, and include a patch changeset because this changes user-visible tool guidance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Clarify the recall prompt guidance and tool metadata so agents understand that
lcm_expand_query(query=...)uses the same FTS5 full-text search path aslcm_grep.Problem
Agents were over-stuffing the
queryparameter with keywords (e.g."fixed by Monday" pagedrop idea concept sales automation), treating it like a natural-language search. FTS5 defaults to AND matching, so extra terms narrowed results to zero even when the target summary existed.Changes
lcm_expand_queryquery constructionqueryis for FTS matching (1-3 terms or quoted phrase) andpromptis for natural-language questionslcm_grepandlcm_expand_queryTesting
pnpm testpasses (full suite)