Skip to content

LCORE-1470: Inline BYOK uses user-facing ids for LLS RAG db filtering#1325

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
are-ces:fix-rag-filter
Mar 16, 2026
Merged

LCORE-1470: Inline BYOK uses user-facing ids for LLS RAG db filtering#1325
tisnik merged 1 commit into
lightspeed-core:mainfrom
are-ces:fix-rag-filter

Conversation

@are-ces

@are-ces are-ces commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Description

In the method _fetch_byok_rag which is called when performing inline BYOK, we pass the user facing rag_ids (vector_store_ids field in request) which should be translated to llama-stack vector_store_ids.

This last step is missing, which leads to filtering not working using the user facing rag_ids.

The PR fixes this issue.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: Claude Code

Related Tickets & Documents

  • Related Issue # LCORE-1470
  • Closes # LCORE-1470

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

Added unit tests

Summary by CodeRabbit

  • Bug Fixes

    • Improved BYOK RAG query processing with unified ID resolution and proper vector store filtering for inline queries.
  • Tests

    • Added unit tests validating that user-facing BYOK RAG identifiers are correctly translated to internal IDs during query operations.

@coderabbitai

coderabbitai Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The _fetch_byok_rag function in vector search utilities is refactored to use a unified resolution path for vector_store_ids, replacing separate branch logic for provided vs. configured IDs. Solr is consistently filtered after resolution. Two unit tests validate that user-facing BYOK rag_ids are correctly translated to internal vector_store_ids.

Changes

Cohort / File(s) Summary
Vector Search Logic Refactor
src/utils/vector_search.py
Simplified _fetch_byok_rag function with unified rag_ids resolution path, removed branch-based conditional logic, added Solr filtering post-resolution, and documented the vector_store_ids parameter.
Vector Search Unit Tests
tests/unit/utils/test_vector_search.py
Added two new tests validating translation of user-facing BYOK rag_ids to internal vector_store_ids: single ID translation and multiple IDs translation scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing inline BYOK to use user-facing IDs for RAG database filtering, which aligns with the core objective of translating user-facing rag_ids to internal vector_store_ids.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

@are-ces are-ces requested review from asimurka and tisnik March 16, 2026 11:49

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
src/utils/vector_search.py (2)

353-354: Misleading comment: Solr exclusion now applies to all cases, not just request-level overrides.

The comment "Request-level override: filter out Solr store" is outdated. With the unified resolution path, this filter is applied regardless of whether IDs came from vector_store_ids or config. Consider updating to reflect the actual behavior.

📝 Suggested comment fix
-    # Request-level override: filter out Solr store, use the rest
+    # Exclude Solr store from BYOK RAG queries (Solr is handled separately by _fetch_solr_rag)
     vector_store_ids_to_query = [
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/vector_search.py` around lines 353 - 354, The comment above the
vector_store_ids_to_query assignment is misleading—update it to state that the
Solr store is always excluded (applies to both request-level vector_store_ids
and config-derived IDs) rather than saying "Request-level override"; locate the
vector_store_ids_to_query declaration in src/utils/vector_search.py and replace
the comment to clearly describe the unified resolution path and that Solr is
filtered out for all cases.

320-330: Docstring could clarify that vector_store_ids are user-facing IDs that get translated.

The inline comment # User-facing is helpful, but the docstring (lines 328-330) doesn't mention the translation behavior. Future maintainers may not realize these IDs are resolved to internal llama-stack IDs.

📝 Suggested docstring update
     Args:
         client: The AsyncLlamaStackClient to use for the request
         query: The search query
-        configuration: Application configuration
-        vector_store_ids: Optional list of vector store IDs to query.
-            If provided, only these stores will be queried. If None, all stores
-            (excluding Solr) will be queried.
+        vector_store_ids: Optional list of user-facing rag_ids to query.
+            These are translated to internal llama-stack vector_db_ids before
+            querying. If provided, only these stores will be queried. If None,
+            configured inline stores (excluding Solr) will be queried.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/vector_search.py` around lines 320 - 330, Update the docstring for
the function that returns tuple[list[RAGChunk], list[ReferencedDocument]] to
explicitly state that the vector_store_ids parameter is a user-facing list of
IDs which will be resolved/translated into internal llama-stack vector-store IDs
before querying; clarify that when vector_store_ids is provided only those
user-facing stores (after translation) are queried and when None all stores
except Solr are queried. Mention the translation step and its purpose so
maintainers understand that vector_store_ids are not raw internal IDs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/utils/vector_search.py`:
- Around line 353-354: The comment above the vector_store_ids_to_query
assignment is misleading—update it to state that the Solr store is always
excluded (applies to both request-level vector_store_ids and config-derived IDs)
rather than saying "Request-level override"; locate the
vector_store_ids_to_query declaration in src/utils/vector_search.py and replace
the comment to clearly describe the unified resolution path and that Solr is
filtered out for all cases.
- Around line 320-330: Update the docstring for the function that returns
tuple[list[RAGChunk], list[ReferencedDocument]] to explicitly state that the
vector_store_ids parameter is a user-facing list of IDs which will be
resolved/translated into internal llama-stack vector-store IDs before querying;
clarify that when vector_store_ids is provided only those user-facing stores
(after translation) are queried and when None all stores except Solr are
queried. Mention the translation step and its purpose so maintainers understand
that vector_store_ids are not raw internal IDs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ffe5e818-ef89-4e59-bc94-cfd202376d31

📥 Commits

Reviewing files that changed from the base of the PR and between 620837e and 5375422.

📒 Files selected for processing (2)
  • src/utils/vector_search.py
  • tests/unit/utils/test_vector_search.py

@are-ces are-ces marked this pull request as draft March 16, 2026 11:58
@are-ces are-ces marked this pull request as ready for review March 16, 2026 12:00

@asimurka asimurka 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.

LGTM

@tisnik tisnik 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.

LGTM

@tisnik tisnik merged commit 3350016 into lightspeed-core:main Mar 16, 2026
25 of 26 checks passed
@are-ces are-ces deleted the fix-rag-filter branch June 9, 2026 08:07
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.

3 participants