Skip to content

fix(lessons): apply recall filters before the candidate limit - #1721

Merged
rohitg00 merged 2 commits into
rohitg00:mainfrom
Mike-Animal-Counseling:fix/lesson-recall-scope
Nov 16, 2026
Merged

rohitg00 merged 2 commits into
rohitg00:mainfrom
Mike-Animal-Counseling:fix/lesson-recall-scope

Conversation

@Mike-Animal-Counseling

@Mike-Animal-Counseling Mike-Animal-Counseling commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A lesson search filtered by project or minimum confidence can return an empty list even when a matching lesson exists. Higher-ranked, ineligible lessons can fill the candidate limit. Apply the filters before that limit so eligible matches are still returned.

Validation

  • Both regression cases fail on the original code and pass with this change.
  • npm test -- --maxWorkers=2 passed 4,765 tests with 8 skipped.

Summary by CodeRabbit

  • Bug Fixes
    • Lesson recall applies deletion, confidence, and project filters before the result limit, helping eligible lessons appear even when many non-matching lessons score higher.
  • Tests
    • Added coverage confirming project and confidence filters still return matching lessons when more than 100 non-matching lessons are present.

Signed-off-by: March <183773531+Mike-Animal-Counseling@users.noreply.github.com>
@vercel

vercel Bot commented Nov 9, 2026

Copy link
Copy Markdown

@Mike-Animal-Counseling is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Lesson recall now filters search candidates for missing, deleted, low-confidence, or wrong-project lessons before applying the result limit. Confidence-and-recency scoring and the final result limit remain unchanged.

Changes: Lesson recall filtering

Layer / File(s) Summary
Search filtering predicate
src/state/search-index.ts
SearchIndex.search accepts an optional predicate and removes rejected observation IDs before sorting and limiting results.
Lesson recall integration and tests
src/functions/lessons.ts, test/lesson-index-recall.test.ts
Lesson recall filters candidates by cached-record presence, deletion status, confidence, and project. Tests verify that a matching lesson is returned when 101 nonmatching lessons precede it.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • rohitg00/agentmemory#1704: Filters search candidates before the result limit so ineligible records do not crowd out eligible matches.

Suggested reviewers: rohitg00

Merge Risk: Minimal · up to eb2ee

Lesson recall now filters candidates before limiting them. No merge-blocking issue was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: applying lesson recall filters before the candidate limit.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d7acfc9-fb1a-4702-a3b5-012e8b57bc43
Commits

Reviewing files that changed from the base of the PR and between aadd4d1 and eb2eecf.

Files selected for processing: 1

  • src/functions/lessons.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread src/functions/lessons.ts Resolved
coderabbitai[bot]

This comment was marked as resolved.

Signed-off-by: March <183773531+Mike-Animal-Counseling@users.noreply.github.com>
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