Skip to content

fix: clarify FTS5 query guidance for recall tools#332

Merged
jalehman merged 2 commits into
mainfrom
fix/fts-query-guidance
Apr 9, 2026
Merged

fix: clarify FTS5 query guidance for recall tools#332
jalehman merged 2 commits into
mainfrom
fix/fts-query-guidance

Conversation

@jalehman

@jalehman jalehman commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

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 as lcm_grep.

Problem

Agents were over-stuffing the query parameter 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

  • Add explicit FTS5 AND-matching guidance to the static recall policy prompt
  • Add per-session compacted context guidance for lcm_expand_query query construction
  • Clarify that query is for FTS matching (1-3 terms or quoted phrase) and prompt is for natural-language questions
  • Tighten tool description strings for both lcm_grep and lcm_expand_query
  • Add regression tests for prompt content and tool metadata

Testing

  • pnpm test passes (full suite)

jalehman added 2 commits April 8, 2026 17:50
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.
@jalehman jalehman merged commit 98cb02a into main Apr 9, 2026
2 checks passed
@jalehman jalehman deleted the fix/fts-query-guidance branch April 9, 2026 18:35
@github-actions github-actions Bot mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant