Repository navigation
improve(memory): bound vector recall decision counts - #147900
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 12:46 AM ET / 04:46 UTC. ClawSweeper reviewWhat this changesMemory Core bounds the counts used when vector search returns too few matches and adds a native SQLite regression test for the reduced counting work. Merge readiness✅ Ready for maintainer review Keep open: this is a useful, focused optimization absent from current main and the latest release. The count caps preserve the existing widening and fallback decisions; no blocking defect was found. Priority: P2 Review scores
Verification
How this fits togetherMemory Core searches indexed memory using query embeddings and model/source filters. Its SQLite query worker returns matching snippets or asks the search owner to scan stored embeddings as a fallback. flowchart TD
A[Query embedding and filters] --> B[Memory search]
B --> C[SQLite vector query worker]
C --> D{Enough matches?}
D -->|Yes| G[Ranked memory snippets]
D -->|No| E[Bounded counts and wider query]
E -->|Recall still incomplete beyond cap| F[Embedding fallback scan]
E -->|Recall complete| G
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3, Tests +80. Total +83 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the counting optimization within the existing read-only query owner while preserving result filtering, widening thresholds, and fallback behavior. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug: this preserves search behavior while reducing counting work. Current source confirms the complete-count path; the reported performance measurements were not rerun during this read-only review. Is this the best way to solve the issue? Yes. Limiting the existing count subqueries is a narrow solution that preserves all downstream threshold comparisons without adding an API, migration, or competing implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fe645cd77de7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* commit 'e3d8d0078369b21223c70028c4502c89f1420897': (51 commits) fix: background requests delay opening chats (#147845) chore(i18n): refresh native locales (#147899) feat: start remote sessions without a repository (#147773) fix(slack): retire probe sockets after timeout (#147846) refactor(agents): share theme ANSI color encoding (#147838) improve(memory): bound vector recall decision counts (#147900) improve(browser): narrow dashboard lifetime rechecks (#147892) test(discord): compact lifecycle matrices (#147855) fix(agents): use exact model rows for harness support (#147849) test(agents): compact embedded lifecycle matrices (#147856) test(agents): compact embedded admission matrices (#147853) test(cli): compact node management matrices (#147854) feat(artifacts): select assistant-delivered files by run (#147682) improve: reduce event-loop work when recording prompts (#147876) fix: preserve readable generated image and video filenames (#147833) fix(ci): skip SDK rendering for identical revisions (#147572) fix: prevent false process failures and stalled background waits (#147871) fix(ui): restore live updates when retrying chat history (#147865) fix(ui): preserve text and image order in assistant replies (#147731) refactor(qa-lab): reuse approval result formatter (#147867) ...
Co-authored-by: Peter Steinberger <[email protected]>
Related: #146197
What Problem This Solves
Underfilled vector recall counts complete chunk and vector sets even after it has enough information to choose widening or fallback.
User Impact
Search results and fallback decisions remain unchanged. This bounds count work on large indexes; it is not a general search-speed claim. Small counts add some overhead. No schema or row format changes, migration, rebuild, or operator action is required.
Why This Change Was Made
Count at most the requested number of matching chunks and 4,097 vectors. These thresholds preserve the existing widening and 4,096-vector fallback decisions, statement order and readonly boundaries. Native statement, returned-row and byte counts remain unchanged.
Evidence
Timings use Node 26.8.2, default memory source filtering and the normal 200-candidate window: one warmup plus five alternating pairs, seven diagnostic count pairs. They measure searchVector with the actual KNN owner and locally executed fallback algorithm, excluding process/worker dispatch and manager ranking. Compilers/static guards were active. The unchanged complete-result control moved 2.564 to 3.073 ms while its kernel moved the other way, so small whole-flow differences are not claimed as gains. Singleton flow was 0.489 to 0.526 ms; filtered-small was 1.638 to 1.904 ms. Synthetic two-dimensional data does not establish production prevalence or universal speedup.
The observing-view regression establishes work bounds, not native-table timing. Capped scans can avoid corruption diagnostics beyond the decision prefix; accessed-row validation remains intact, and these readonly counts do not authorize deletion. Initial fixture and syntax failures were retained; the completed fixed run was not rerun to improve medians.