Skip to content

fix: support 8-char short ID prefix matching for memory tools (v0.2.2)#14

Merged
tryweb merged 1 commit intomainfrom
fix/short-id-prefix-matching
Mar 21, 2026
Merged

fix: support 8-char short ID prefix matching for memory tools (v0.2.2)#14
tryweb merged 1 commit intomainfrom
fix/short-id-prefix-matching

Conversation

@tryweb
Copy link
Owner

@tryweb tryweb commented Mar 21, 2026

Problem

memory_scope_promote, memory_delete, memory_feedback_wrong, and memory_feedback_useful all return "Memory X not found in current scope" when given an 8-character short ID, even though memory_search finds the exact same memory.

Root Cause

memory_search outputs the full UUID in its result ([0f229546-c7af-4183-8558-2c12209b9314]). When an AI or user copies only the first 8 characters (0f229546) as a short-hand reference, all the ID-based tools fail silently because they use strict === matching against the full 36-char stored UUID.

Every affected method (hasMemory, deleteById, updateMemoryScope, updateMemoryUsage) did rows.find(row => row.id === id) — an exact match that never fires on a prefix.

Fix

  • Add private matchesId(candidateId, query) on MemoryStore: exact match for 36-char queries, startsWith prefix for shorter ones
  • Apply to all four methods
  • Raise id schema min(6)min(8) on all memory tools
  • Fix latent data-loss bug: DELETE in updateMemoryScope and updateMemoryUsage now uses match.id (the resolved full UUID), not the id parameter

Verification

npm run verify — foundation 11/11, regression 18/18, retrieval 2/2, all 0 failures.

memory_scope_promote, memory_delete, memory_feedback_wrong,
memory_feedback_useful all failed with 'not found' when given an
8-character short ID (first 8 chars of a UUID), even though
memory_search could find the same memory by text/vector.

Root cause: hasMemory(), deleteById(), updateMemoryScope(), and
updateMemoryUsage() all used strict === comparison against the full
36-char UUID stored in LanceDB.

Fix:
- Add matchesId(candidateId, query) private helper on MemoryStore:
  - query >= 36 chars → exact === match (unchanged behavior)
  - query < 36 chars  → startsWith prefix match
- Apply matchesId to all four methods
- Change id schema validation from min(6) to min(8) on all memory
  tools to align with the short-ID convention
- Fix latent data-loss bug: DELETE in updateMemoryScope and
  updateMemoryUsage now uses match.id (resolved full UUID) instead
  of the id argument, which could be a prefix

Bump version to 0.2.2.
@tryweb tryweb merged commit 41faf60 into main Mar 21, 2026
3 checks passed
@tryweb tryweb deleted the fix/short-id-prefix-matching branch March 21, 2026 12:26
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