.agents/memory/2026-03-01-embedding-tracker-prompt-submit-query-fixes.md

1.8 KiB
Raw Blame History

2026-03-01 Session Notes

Embedding Tracker & Prompt Submit Query Fixes

Implemented a plan to fix two critical bugs in the Signet daemon's memory pipeline:

Bug 1 Embedding Tracker Crash: The INSERT statement in embedding-tracker.ts:135 was missing the dimensions column, causing NOT NULL constraint failures. This was fixed by adding dimensions to both the INSERT and ON CONFLICT UPDATE clauses, passing vector.length as the dimensions value.

Bug 2 Prompt Submit Recall Queries Broken: The user-prompt-submit hook was building garbage FTS recall queries due to two upstream issues:

  • Claude Code path: The CLI at cli.ts:4816 was only checking parsed.user_prompt || parsed.userPrompt, but Claude Code sends { prompt: "..." } on stdin. Fixed by adding parsed.prompt as the first fallback.
  • OpenClaw adapter path: OpenClaw's before_agent_start event passes the entire formatted prompt (including metadata preamble with conversation info, sender, untrusted content markers) instead of just the user's message. Fixed by implementing extractUserMessage() to strip metadata patterns and return only the actual user message text.

Files Modified

  1. packages/daemon/src/embedding-tracker.ts Added dimensions column handling (already completed)
  2. packages/cli/src/cli.ts Updated stdin field resolution to check parsed.prompt first
  3. packages/adapters/openclaw/src/index.ts Implemented metadata extraction logic at line 881

Verification Plan

  • Rebuild daemon and verify no more embedding constraint errors
  • Test CLI stdin parsing with echo '{"prompt":"test query"}' | bun cli.ts hook user-prompt-submit
  • Monitor daemon logs for recall queries using actual user message words instead of metadata keywords
  • Run full test suite and typecheck