feat: Phase 1 B-1 scope-aware BM25 neighbor expansion for reflection slices#3
Closed
feat: Phase 1 B-1 scope-aware BM25 neighbor expansion for reflection slices#3
Conversation
Issue: CortexReach#445 (AliceLJY reviewer feedback) Changes: - Add loadAgentReflectionSlicesWithBm25Expansion() function to src/reflection-slices.ts - This function performs scope-aware BM25 expansion: for each reflection slice entry, it does bm25Search(text, topK=2, scopeFilter=[entry.scope]) instead of global expansion - Uses [entry.scope] instead of undefined to scope neighbors to the same scope as the original entry - Merges and deduplicates original entries with their neighbors Config options: - topK: number of neighbor results per entry (default: 2) - minScore: minimum BM25 score threshold (default: 0.1)
jlin53882
pushed a commit
that referenced
this pull request
Apr 4, 2026
…CortexReach#417) - Fix #1: buildAutoCaptureConversationKeyFromIngress — DM fallback to channelId (fixes pendingIngressTexts never being written for Discord DM) - Fix #2: cumulative counting — autoCaptureSeenTextCount accumulates, not overwrites (fixes eligibleTexts.length always 1 for DM, extractMinMessages never satisfied) - Fix #3: REPLACE vs APPEND — use pendingIngressTexts as-is when present (avoids deduplication issues from text appearing in both sources) - Fix #5: isExplicitRememberCommand guard with lastPending fallback (preserves explicit remember command behavior in DM context) - Fix #6: Math.min cap on extractMinMessages (max 100) — prevents misconfiguration - Fix #7: MAX_MESSAGE_LENGTH=5000 guard in message_received hook - Smart extraction threshold now uses currentCumulativeCount (turn count) instead of cleanTexts.length (per-event message count) - Debug logs updated to show cumulative count context All 29 test suites pass. Based on official latest (5669b08).
jlin53882
pushed a commit
that referenced
this pull request
Apr 4, 2026
…CortexReach#417) - Fix #1: buildAutoCaptureConversationKeyFromIngress — DM fallback to channelId (fixes pendingIngressTexts never being written for Discord DM) - Fix #2: cumulative counting — autoCaptureSeenTextCount accumulates, not overwrites (fixes eligibleTexts.length always 1 for DM, extractMinMessages never satisfied) - Fix #3: REPLACE vs APPEND — use pendingIngressTexts as-is when present (avoids deduplication issues from text appearing in both sources) - Fix #5: isExplicitRememberCommand guard with lastPending fallback (preserves explicit remember command behavior in DM context) - Fix #6: Math.min cap on extractMinMessages (max 100) — prevents misconfiguration - Fix #7: MAX_MESSAGE_LENGTH=5000 guard in message_received hook - Smart extraction threshold now uses currentCumulativeCount (turn count) instead of cleanTexts.length (per-event message count) - Debug logs updated to show cumulative count context All 29 test suites pass. Based on official latest (5669b08).
jlin53882
pushed a commit
that referenced
this pull request
Apr 4, 2026
…turn counting test + changelog - Fix #1: buildAutoCaptureConversationKeyFromIngress DM fallback - Fix #2: currentCumulativeCount (cumulative per-event counting) - Fix #3: REPLACE vs APPEND + cum count threshold for smart extraction - Fix #4: remove pendingIngressTexts.delete() - Fix #5: isExplicitRememberCommand lastPending guard - Fix #6: Math.min extractMinMessages cap (max 100) - Fix #7: MAX_MESSAGE_LENGTH=5000 guard - Add test: 2 sequential agent_end events with extractMinMessages=2 - Add changelog: Unreleased section with issue details
jlin53882
pushed a commit
that referenced
this pull request
Apr 5, 2026
…turn counting test + changelog - Fix #1: buildAutoCaptureConversationKeyFromIngress DM fallback - Fix #2: currentCumulativeCount (cumulative per-event counting) - Fix #3: REPLACE vs APPEND + cum count threshold for smart extraction - Fix #4: remove pendingIngressTexts.delete() - Fix #5: isExplicitRememberCommand lastPending guard - Fix #6: Math.min extractMinMessages cap (max 100) - Fix #7: MAX_MESSAGE_LENGTH=5000 guard - Add test: 2 sequential agent_end events with extractMinMessages=2 - Add changelog: Unreleased section with issue details
jlin53882
pushed a commit
that referenced
this pull request
Apr 7, 2026
…CortexReach#417) - Fix #1: buildAutoCaptureConversationKeyFromIngress — DM fallback to channelId (fixes pendingIngressTexts never being written for Discord DM) - Fix #2: cumulative counting — autoCaptureSeenTextCount accumulates, not overwrites (fixes eligibleTexts.length always 1 for DM, extractMinMessages never satisfied) - Fix #3: REPLACE vs APPEND — use pendingIngressTexts as-is when present (avoids deduplication issues from text appearing in both sources) - Fix #5: isExplicitRememberCommand guard with lastPending fallback (preserves explicit remember command behavior in DM context) - Fix #6: Math.min cap on extractMinMessages (max 100) — prevents misconfiguration - Fix #7: MAX_MESSAGE_LENGTH=5000 guard in message_received hook - Smart extraction threshold now uses currentCumulativeCount (turn count) instead of cleanTexts.length (per-event message count) - Debug logs updated to show cumulative count context All 29 test suites pass. Based on official latest (5669b08).
jlin53882
pushed a commit
that referenced
this pull request
Apr 7, 2026
…turn counting test + changelog - Fix #1: buildAutoCaptureConversationKeyFromIngress DM fallback - Fix #2: currentCumulativeCount (cumulative per-event counting) - Fix #3: REPLACE vs APPEND + cum count threshold for smart extraction - Fix #4: remove pendingIngressTexts.delete() - Fix #5: isExplicitRememberCommand lastPending guard - Fix #6: Math.min extractMinMessages cap (max 100) - Fix #7: MAX_MESSAGE_LENGTH=5000 guard - Add test: 2 sequential agent_end events with extractMinMessages=2 - Add changelog: Unreleased section with issue details
jlin53882
pushed a commit
that referenced
this pull request
Apr 8, 2026
…CortexReach#417) - Fix #1: buildAutoCaptureConversationKeyFromIngress — DM fallback to channelId (fixes pendingIngressTexts never being written for Discord DM) - Fix #2: cumulative counting — autoCaptureSeenTextCount accumulates, not overwrites (fixes eligibleTexts.length always 1 for DM, extractMinMessages never satisfied) - Fix #3: REPLACE vs APPEND — use pendingIngressTexts as-is when present (avoids deduplication issues from text appearing in both sources) - Fix #5: isExplicitRememberCommand guard with lastPending fallback (preserves explicit remember command behavior in DM context) - Fix #6: Math.min cap on extractMinMessages (max 100) — prevents misconfiguration - Fix #7: MAX_MESSAGE_LENGTH=5000 guard in message_received hook - Smart extraction threshold now uses currentCumulativeCount (turn count) instead of cleanTexts.length (per-event message count) - Debug logs updated to show cumulative count context All 29 test suites pass. Based on official latest (5669b08).
jlin53882
pushed a commit
that referenced
this pull request
Apr 8, 2026
…turn counting test + changelog - Fix #1: buildAutoCaptureConversationKeyFromIngress DM fallback - Fix #2: currentCumulativeCount (cumulative per-event counting) - Fix #3: REPLACE vs APPEND + cum count threshold for smart extraction - Fix #4: remove pendingIngressTexts.delete() - Fix #5: isExplicitRememberCommand lastPending guard - Fix #6: Math.min extractMinMessages cap (max 100) - Fix #7: MAX_MESSAGE_LENGTH=5000 guard - Add test: 2 sequential agent_end events with extractMinMessages=2 - Add changelog: Unreleased section with issue details
jlin53882
pushed a commit
that referenced
this pull request
Apr 9, 2026
…CortexReach#417) - Fix #1: buildAutoCaptureConversationKeyFromIngress — DM fallback to channelId (fixes pendingIngressTexts never being written for Discord DM) - Fix #2: cumulative counting — autoCaptureSeenTextCount accumulates, not overwrites (fixes eligibleTexts.length always 1 for DM, extractMinMessages never satisfied) - Fix #3: REPLACE vs APPEND — use pendingIngressTexts as-is when present (avoids deduplication issues from text appearing in both sources) - Fix #5: isExplicitRememberCommand guard with lastPending fallback (preserves explicit remember command behavior in DM context) - Fix #6: Math.min cap on extractMinMessages (max 100) — prevents misconfiguration - Fix #7: MAX_MESSAGE_LENGTH=5000 guard in message_received hook - Smart extraction threshold now uses currentCumulativeCount (turn count) instead of cleanTexts.length (per-event message count) - Debug logs updated to show cumulative count context All 29 test suites pass. Based on official latest (5669b08).
jlin53882
pushed a commit
that referenced
this pull request
Apr 9, 2026
…turn counting test + changelog - Fix #1: buildAutoCaptureConversationKeyFromIngress DM fallback - Fix #2: currentCumulativeCount (cumulative per-event counting) - Fix #3: REPLACE vs APPEND + cum count threshold for smart extraction - Fix #4: remove pendingIngressTexts.delete() - Fix #5: isExplicitRememberCommand lastPending guard - Fix #6: Math.min extractMinMessages cap (max 100) - Fix #7: MAX_MESSAGE_LENGTH=5000 guard - Add test: 2 sequential agent_end events with extractMinMessages=2 - Add changelog: Unreleased section with issue details
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
Implements Phase 1 B-1 from Issue CortexReach#445 (AliceLJY reviewer feedback).
Changes
Adds a new function that performs scope-aware BM25 neighbor expansion for reflection slices:
Config Options
Issue Reference
Testing