Registry Mirror
Skip to content

Conversation

@bhushan4work

Copy link
Copy Markdown
Collaborator

What does this change?

Closes #598

plan() in packages/core/src/retrieval/retrievers.ts now falls back to DEFAULT_TOP_K when query.topK or options.candidates is not a finite number (NaN, Infinity, -Infinity), so finish() no longer calls chunks.slice(0, NaN) and silently returns no sources. Finite values keep the existing Math.floor + minimum of 1 behavior, including 0, negatives, and fractions. Added regression tests for both vectorRetriever and hybridRetriever, plus a patch changeset for @chatcops/core.

How I tested this

  • Added tests in packages/core/tests/retrieval/retrievers.test.ts covering topK: NaN, topK: Infinity, and candidates: NaN for both retrievers. Each asserts the store receives a finite topK and sources are returned. Confirmed these fail on dev.
  • Confirmed existing behavior for topK: 0, negative numbers, and fractions is unchanged.
  • Ran pnpm -r build, pnpm test, and pnpm -r typecheck.

AI assistance

none

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • pnpm api run and api/ committed if an exported type or option changed
  • Docs updated if behavior or options changed

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @bhushan4work. plan() now uses the defaults when topK or candidates isn't finite, so topK: NaN asks the store for 20 candidates and sources come back instead of slice(0, NaN). Finite values still get the Math.floor and the minimum of 1. The tests cover NaN and Infinity for topK and NaN for candidates, in both retrievers. All checks pass, including e2e.

@anurag629
anurag629 merged commit 105bf39 into codercops:dev Nov 13, 2026
@anurag629

Copy link
Copy Markdown
Member

Merged, thanks @bhushan4work.

@github-actions github-actions Bot added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core: a topK of NaN makes the built-in retrievers return no sources

2 participants