Skip to content

fix: skip instructional prompts in auto-recall query normalization#1594

Closed
SonicBotMan wants to merge 1 commit intoMemTensor:mainfrom
SonicBotMan:fix/skip-instructional-prompts-in-auto-recall
Closed

fix: skip instructional prompts in auto-recall query normalization#1594
SonicBotMan wants to merge 1 commit intoMemTensor:mainfrom
SonicBotMan:fix/skip-instructional-prompts-in-auto-recall

Conversation

@SonicBotMan
Copy link
Copy Markdown

Problem

The normalizeAutoRecallQuery() function in apps/memos-local-openclaw/index.ts passes long instructional prompts to FTS5 search, causing query failures and wasted LLM calls.

Root Cause

When used with Hermes Agent, the before_prompt_build hook receives internal agent prompts (like _SKILL_REVIEW_PROMPT) that are:

  • Long instructional texts (300+ characters)
  • Not user queries
  • Not suitable for FTS5 search

These prompts cause:

  1. FTS5 query failures: The sanitized query is too long/complex for FTS5
  2. Wasted LLM calls: filterRelevant() receives empty responses from DeepSeek reasoning models
  3. Degraded performance: FTS search falls back to vector-only search

Example Failing Prompt

Review the conversation above consider saving updating skill if appropriate Focus on was non trivial approach used to complete task that required trial error changing course due to experiential findings along the way did the user expect desire different method outcome? If relevant skill already exists update it with what you learned Otherwise create new skill if the approach is reusable If nothing is worth saving just say Nothing to save stop

Solution

Added early detection for instructional prompts in normalizeAutoRecallQuery():

  1. Length check: Prompts > 300 chars are almost certainly system instructions
  2. Pattern matching: Detect "You are..." system prompt patterns
  3. Known prompts: Skip "Review the conversation above..." Hermes review prompts
if (query.length > 300) {
  return "";  // System instructions, not user queries
}
if (/^You are\b/i.test(query)) {
  return "";  // System prompt pattern
}
if (/Review the conversation above/i.test(query)) {
  return "";  // Hermes review prompt
}

Testing

Verified locally with Hermes Agent v0.10.0 + MemTensor v1.0.4:

  • FTS5 query failures dropped from 96 to 0
  • Auto-recall still works correctly for actual user queries
  • No regression in memory/skill search functionality

Impact

  • Low risk: Only skips prompts that would fail anyway
  • No breaking changes: Existing behavior preserved for valid queries
  • Performance improvement: Eliminates wasted FTS5 and LLM calls

The normalizeAutoRecallQuery() function was passing long instructional
prompts (like Hermes Agent's _SKILL_REVIEW_PROMPT) to FTS5 search,
causing query failures and wasted LLM calls.

Added detection for:
- Prompts > 300 chars (almost certainly system instructions)
- 'You are...' system prompt patterns
- 'Review the conversation above...' Hermes review prompts

This fixes FTS5 query failures and improves auto-recall efficiency.
@SonicBotMan SonicBotMan deleted the fix/skip-instructional-prompts-in-auto-recall branch April 29, 2026 17:01
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