#21016: Fix memory_forget candidate IDs to prevent deletion retry loop
extensions: memory-lancedb
size: XS
## Summary
This fixes a failure loop in `memory_forget`:
- `memory_forget(query=...)` returned candidate IDs truncated to 8 chars in human-visible output.
- The follow-up call requires `memoryId` to be a full UUID.
- The agent repeatedly copied the truncated ID from tool output, which failed UUID validation, and retried without progress.
Result: memory deletion often failed in practice even when the right candidate was found.
## Root problem
`memory_forget` had a mismatch between:
- **What it displayed** as the next-step identifier (8-char ID prefix), and
- **What it accepted** for deletion (full UUID only).
That mismatch produced repeated tool errors during autonomous loops because the model naturally reused the visible ID it was given.
## What changed
- Updated `memory_forget` candidate output to display full IDs inline (instead of 8-char prefixes).
## Files
- `extensions/memory-lancedb/index.ts`
## Options evaluated
### Option 1 (implemented): show full IDs in candidate output
Pros:
- Directly resolves the failure loop by making output immediately reusable as `memoryId`.
- Very small and low-risk change.
- No behavioral expansion in delete semantics.
- No ambiguity/collision handling needed.
Tradeoff:
- Slightly longer output lines.
Note on context impact:
- Showing full IDs adds only **marginal** extra context tokens.
- That additional verbosity is limited to the **memory deletion candidate flow** (`memory_forget` disambiguation), not the primary memory recall workflow (`memory_recall`), so normal recall behavior/context footprint is unchanged.
### Option 2 (not implemented): accept truncated/prefix IDs in `memory_forget`
This would require expanding delete semantics to support prefix resolution, including:
- Distinguishing full UUID vs prefix input.
- Prefix lookup across candidate IDs (or DB-backed ID search).
- Exact-match precedence rules.
- Prefix-length guardrails (e.g., minimum length).
- Ambiguity handling when multiple IDs share a prefix.
- Clear deterministic error paths for:
- no matches,
- ambiguous matches,
- invalid formats.
- Additional tests across all branches above.
Option 2 is feasible, but it introduces materially more logic and edge-case behavior than needed to solve the immediate reliability issue.
## Why option 1
Option 1 fixes the operational bug at its source (tool output/input mismatch) with minimal code and risk, and prevents the observed repeated-error behavior without broadening deletion behavior.
## Validation
- `pnpm lint` passed
- `pnpm vitest run extensions/memory-lancedb/index.test.ts` passed
Most Similar PRs
#10001: fix(memory-lancedb): support partial ID matching in memory_forget
by jeremylancaster · 2026-02-06
77.8%
#11179: fix(memory): replace confusing "No API key" errors in memory tools ...
by liuxiaopai-ai · 2026-02-07
66.0%
#3401: fix(memory-lancedb): improve autoCapture with turn-by-turn processing
by mike-nott · 2026-01-28
64.6%
#9149: Fix: Allow QMD backend to work without OpenAI auth
by vishaltandale00 · 2026-02-04
63.4%
#17624: Fix memory flush YYYY-MM-DD placeholder resolution
by grunt3714-lgtm · 2026-02-16
63.1%
#4386: fix(memory): persist dirty flag to prevent false positive on status
by Iamadig · 2026-01-30
62.4%
#18916: fix(agents): suppress memory tool delivery to prevent reply drop
by BinHPdev · 2026-02-17
62.4%
#18756: fix the memory manager class hierarchy declared at the wrong level
by leoh · 2026-02-17
62.3%
#6362: fix(memory): add ignore patterns to chokidar file watcher
by Glucksberg · 2026-02-01
62.2%
#17743: fix(agents): disable orphaned user message deletion that causes ses...
by clawrl3000 · 2026-02-16
62.2%