Skip to content

fix: apply per-tier topK truncation in searchMemory#1646

Merged
hijzy merged 1 commit into
MemTensor:mem-agent-0424from
syzsunshine219:test/hermes-plugin-0428
May 8, 2026
Merged

fix: apply per-tier topK truncation in searchMemory#1646
hijzy merged 1 commit into
MemTensor:mem-agent-0424from
syzsunshine219:test/hermes-plugin-0428

Conversation

@syzsunshine219
Copy link
Copy Markdown
Collaborator

@syzsunshine219 syzsunshine219 commented May 8, 2026

Summary

  • Fix topK overflow bug in searchMemory: the retrieval ranker's limit was the SUM of per-tier topK values (e.g. topK={tier1:3,tier2:3,tier3:3} → limit=9), allowing merged results to exceed the caller's expected total
  • Now enforces per-tier caps before returning hits, so topK=3 per tier returns at most 3 results per tier instead of up to 9 total
  • Fixes [BUG-2026-05-08] skill-type result overflow in search API

Test plan

  • Vitest unit tests pass (all search/retrieval related tests green)
  • test_B2_S04_search_topk_respects_limit now passes (was xfail before fix)
  • No regression in B2 preference persistence test suite

The retrieval ranker's limit was the SUM of per-tier topK values
(e.g. topK={tier1:3,tier2:3,tier3:3} → limit=9), allowing merged
results to exceed the caller's expected total. Now searchMemory
enforces per-tier caps before returning hits, so topK=3 per tier
returns at most 3 results per tier instead of up to 9 total.

Fixes [BUG-2026-05-08] skill-type overflow in search results.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hijzy hijzy merged commit 7f543e2 into MemTensor:mem-agent-0424 May 8, 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.

2 participants