Skip to content

fix(recall): normalize scores across knowledge sources - #891

Merged
jeff-r2026 merged 2 commits into
Tencent:mainfrom
ydflow:fix/recall-cross-scale-ranking
Sep 29, 2026
Merged

jeff-r2026 merged 2 commits into
Tencent:mainfrom
ydflow:fix/recall-cross-scale-ranking

Conversation

@ydflow

@ydflow ydflow commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Problem

Recall currently sorts learnings TF-IDF scores directly against code-graph scores that are already compressed to a bounded 0–10 range. As the learnings corpus grows, its raw scores rise with IDF and can crowd stronger code-graph hits out of the top results.

Change

  • Normalize learnings scores against the existing corpus-aware relevance threshold and map that threshold to the code-graph relevance boundary.
  • Use the bounded normalized value only for merged ordering; keep each result's existing score for --check, quality tracking, and output.
  • Preserve the date tie-breaker and update the English and Chinese recall descriptions.

Validation

  • npx vitest run src/__tests__/recall-*.test.ts — 11 files, 103 tests passed.
  • npm run typecheck, npm run lint, and npm run build passed.
  • Real CLI check: node dist/index.js recall "agent session recovery" ranked the graph hit (score 8.8) before a less relevant learning hit (raw score 30.3) in an isolated project fixture.

@jeff-r2026 jeff-r2026 self-assigned this Sep 28, 2026
@github-actions

Copy link
Copy Markdown

Findings

  • [P1 blocking] src/recall.ts:632 normalizes every learning with the largest scope’s IDF baseline. With inheritUserScope: true, a 1-entry project score of 8 should normalize to 6, but a 1,000-entry user index raises the shared threshold and reduces it to about 3.4, allowing a merely threshold-level graph hit (4.0) to outrank the stronger project result. Carry each index’s baseline onto its results and normalize per scope.

Testing

  • The PR description includes a representative real-CLI verification, so its runtime-testing record satisfies the review requirement.

@github-actions

Copy link
Copy Markdown

Findings

  • No findings.

Resolved

  • The earlier [P1 blocking] scope-normalization issue is fixed. Results now retain their originating scope’s IDF baseline and use it for ranking and --check evaluation at src/recall.ts:582, src/recall.ts:592, and src/recall.ts:633.

Testing

  • The PR description includes unit, typecheck, lint, build, and a representative real-CLI verification. This satisfies the runtime-testing requirement.

@jeff-r2026
jeff-r2026 merged commit 479f811 into Tencent:main Sep 29, 2026
13 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 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