Conversation
## Problem When generating answers to questionnaire questions, the AI tool returns an excessive number of policy sources, many completely unrelated to the question. Users must manually remove irrelevant citations, significantly increasing remediation time. Some questions also go unanswered when relevant policies exist. ## Root cause The server-side vector store retrieval (find-similar.ts in the API) uses a very low similarity threshold (0.2) with no hard limit on results, causing nearly all published policies to be included in the dedup'd source list. The client-side implementation correctly caps results to top-5, but the API path has no such constraint. ## Fix Reinstate a top-K limit on policy retrieval in the questionnaire-AI vector store path. Cap results to 5 most-relevant policies (matching the app-side behavior) and raise the minimum similarity threshold to filter out marginal matches. This is a localized change to the retrieval logic with no impact on auth, RBAC, schema, org scoping, or billing. ## Explicitly NOT touched Organization filtering remains intact. No changes to authentication, role-based access control, database schema, or secret handling. ## Verification ✅ Similarity threshold and top-K limit applied to API retrieval path ✅ Policy source lists now limited to relevant results ✅ Organization ID filter preserved ✅ Existing test coverage passes
…e-ai-tool-excessive fix(questionnaire-ai): cap source retrieval to top-k relevant policies
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Contributor
|
🎉 This PR is included in version 3.92.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
This is an automated pull request to release the candidate branch into production, which will trigger a deployment.
It was created by the [Production PR] action.
Summary by cubic
Caps vector-store retrieval to the top 5 most relevant chunks for questionnaire answer generation, reducing noisy sources and aligning API with app behavior (CS-594).
findSimilarContentandfindSimilarContentBatch.Written for commit 11d91e2. Summary will update on new commits.