feat: recallMode with adaptive intent routing and tiered injection#313
Open
AliceLJY wants to merge 11 commits intoCortexReach:masterfrom
Open
feat: recallMode with adaptive intent routing and tiered injection#313AliceLJY wants to merge 11 commits intoCortexReach:masterfrom
AliceLJY wants to merge 11 commits intoCortexReach:masterfrom
Conversation
…focus-note-handoff feat(refactor): rework reflection handoff note and drop legacy combined rows
…command-hook-lifecycle fix(reflection): restore /new-/reset trigger reliability after startup hook reset
Co-authored-by: furedericca <263020793+furedericca-lab@users.noreply.github.com>
Co-authored-by: furedericca <263020793+furedericca-lab@users.noreply.github.com>
This was referenced Mar 23, 2026
…ntrol Rebase onto current main with orchestrateDynamicRecall architecture. - Add recallMode: "full" | "summary" | "off" config option - full: existing autoRecall behavior (inject matching memories) - summary: lightweight count hint only (saves context budget) - off: disable auto-recall entirely - Backward compatible: recallMode takes precedence, falls back to autoRecall boolean Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6390513 to
357963a
Compare
… tiered injection Extends the recallMode config with a new "adaptive" option that automatically analyzes query intent to determine which memory categories to prioritize and how much detail to inject into agent context. Intent detection is rule-based (no LLM calls) for zero extra latency: - preference queries → filter to preference category, inject L0 (compact) - decision/fact queries → filter to decision/fact, inject L1 (medium) - event/timeline queries → inject full text for complete context - ambiguous queries → no filter, L0 depth to minimize token cost Includes automatic fallback: if category filtering yields zero results, retries without filter to ensure the agent always gets relevant context. Inspired by OpenViking's hierarchical retrieval intent routing, adapted for memory-lancedb-pro's flat category + scope model. New files: - src/intent-analyzer.ts: analyzeIntent(), applyCategoryBoost(), formatAtDepth() - test/intent-analyzer.test.mjs: 20 tests covering intent detection, category boost, and tiered formatting (all passing) Config: recallMode now accepts "full" | "summary" | "adaptive" | "off" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixes 6 issues identified by Codex code review: 1. [High] Security: add sanitizeForContext() to formatAtDepth() and [UNTRUSTED DATA] wrapper to prevent prompt injection from stored memories 2. [High] Remove "event" from MemoryCategoryIntent — it's not a stored category; event queries now route to entity+decision instead 3. [Medium] Add session dedup to adaptive recall (autoRecallMinRepeated) to prevent spamming same memories every turn 4. [Medium] Narrow entity regex patterns to avoid misclassifying "tool"/"component"/"关于" queries as entity intent 5. [Medium] Tests updated for all fixes + new CJK/sanitize test cases 6. [Low] Fix CJK sentence splitting: recognize 。!? without trailing space Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
recallModeconfig option (full|summary|adaptive|off) for granular control over auto-recall behaviorHow adaptive mode works
preferencedecisionentityeventfactAutomatic fallback: if category filtering yields zero results, retries without filter.
New files
src/intent-analyzer.ts—analyzeIntent(),applyCategoryBoost(),formatAtDepth()test/intent-analyzer.test.mjs— 20 tests (all passing)Config example
{ "recallMode": "adaptive" }Test plan
recallMode: "full"unchangedReferences
openviking/retrieve/hierarchical_retriever.py🤖 Generated with Claude Code