Skip to content

fix(memory): turn recall no longer recalls the current session's turns - #468

Merged
mrnasil merged 3 commits into
mainfrom
perf/recall-skip-current-session
Nov 25, 2026
Merged

mrnasil merged 3 commits into
mainfrom
perf/recall-skip-current-session

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

Problem

Turn recall searched every indexed session turn, including the session that is asking. In bench_tokens.py --workload dev, turn 3's <recalled-context> carried this session's own turn 2 and turn 1 under "Past sessions": text already in the request. In a long session those near-identical hits also push real past sessions out of session_top_k.

Fix

  • recall_turn_context / build_recall_block take the current session id (CLI and TUI pass session.id).
  • The session search drops that session's turns before top_k is applied, so the slots go to other sessions.
  • build_inject_block and the memory search command are unchanged (no current session).

Effect

--workload dev (release, o200k): turn-3 recall block 817 → 616 tokens. The session total (248,340 → 249,499) moves within run-to-run noise: turn 2's code recall picked different chunks this run. This is mainly a duplicate-context and recall-quality fix, not a large token win.

Checks

  • cargo test -p whycodes-memory --lib (89; session_turn_search_and_inject now covers own-session skip and another session still recalled)
  • affected cmd::helpers:: (cli) and run::persist:: (tui) tests; clippy (memory, cli, tui); fmt; ratchets

🤖 Generated with Claude Code

mrnasil and others added 3 commits November 25, 2026 04:46
Each turn's recall searched every indexed session turn, including the
session asking. Its earlier turns are already in the request, so they
came back as "Past sessions" duplicates, and in a long session they
crowded real past sessions out of session_top_k. The current session id
now goes into recall and its turns are dropped before top_k is applied.

bench_tokens.py --workload dev: turn-3 recall 817 -> 616 tokens. The
session total moves within run-to-run recall noise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil merged commit f30fd89 into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the perf/recall-skip-current-session branch November 25, 2026 02:11
@mrnasil mrnasil mentioned this pull request Nov 26, 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