Skip to content

fix(agent): pass 12 full-text candidates to rank fusion in help search - #73

Open
aionel wants to merge 1 commit into
linkcraftstudio:mainfrom
aionel:fix/help-search-fulltext-candidates
Open

aionel wants to merge 1 commit into
linkcraftstudio:mainfrom
aionel:fix/help-search-fulltext-candidates

Conversation

@aionel

@aionel aionel commented Nov 24, 2026

Copy link
Copy Markdown

What this PR does

searchHelpArticles passes 12 vector candidates into rank fusion and only 3 full-text candidates. This PR raises the full-text LIMIT to 12 (CANDIDATES_PER_QUERY). The agent still gets 3 articles per query.

Why

An article can rank 4th in full-text search and 3rd in vector search and still be missing from the 3 results. The new test shows this: it fails on main and passes on this branch.

Fusion scores only the articles in its two lists, and the full-text list stops at 3. So that article gets no full-text score. Qdrant's hybrid search guide describes the same fix, raising a retriever's cutoff: https://qdrant.tech/documentation/search-tuning/hybrid-search/

Nothing in the code or the commit messages says why full-text stops at 3. If that's intentional, let me know and I'll close this.

How to review

  • Start in server/lib/agent/help-search.ts: 1 constant and 2 LIMIT arguments.
  • Run the new test, no database needed: node --import tsx --test --test-name-pattern="full-text candidates beyond" tests/agent-help-search.test.ts
  • Each full-text query returns up to 9 more rows from Postgres, including article bodies (a.content).
  • The output is unchanged when vector search is off.
  • Not measured: latency and retrieval quality. pnpm agent:search-eval needs your cases and data.

Checklist

  • Commits are signed off (git commit -s)
  • Tests pass locally (pnpm build)
  • If schema changed, migration was generated (pnpm generate:migration) and committed (no schema change)
  • If public API or env vars changed, README.md / .env.example / docs/deploy/* updated (none changed)
  • No secrets, internal URLs, or team member names in the diff

I ran the agent tests, pnpm build and the Docker build.

The full-text query was limited to 3 rows, the same as the number of
articles returned per query, while the vector query passes 12. Rank fusion
only reorders the union of both lists, so an article ranked 4th or lower
by full-text got no full-text score, even when vector search ranked it.

Fetch 12 full-text candidates and still return 3 per query.

Signed-off-by: Adrian Ionel <14153397+aionel@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.

1 participant