Skip to content

LCORE-1427: Normalize Tool and Inline RAG default behavior#2146

Draft
Jazzcort wants to merge 2 commits into
lightspeed-core:mainfrom
Jazzcort:normalize-tool-and-inlice-rag
Draft

LCORE-1427: Normalize Tool and Inline RAG default behavior#2146
Jazzcort wants to merge 2 commits into
lightspeed-core:mainfrom
Jazzcort:normalize-tool-and-inlice-rag

Conversation

@Jazzcort

@Jazzcort Jazzcort commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

Remove fallback to all registered vector stores when tool RAG is unconfigured.

Previously, when neither rag.tool nor rag.inline were configured, prepare_tools would fetch and register all vector stores from llama-stack as a backward-compatibility fallback. This implicit behavior is removed — tool RAG now requires explicit configuration via rag.tool. Updated docs, config model, example YAML, and tests to reflect the new behavior.

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: (e.g., Claude, CodeRabbit, Ollama, etc., N/A if not used)
  • Generated by: (e.g., tool name and version; N/A if not used)

Related Tickets & Documents

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

  1. Set rag.tool to an empty list or simply omit it.
  2. Check that there is no tool rag enabled even if there are some manually registered vector stores from llama-stack side.

Summary by CodeRabbit

  • Behavior Changes

    • Tool-based RAG is now disabled unless explicitly configured.
    • Inline and tool RAG strategies default to disabled when omitted.
    • The previous fallback that automatically used all available vector stores has been removed.
  • Documentation

    • Updated configuration guides, API documentation, model references, and examples to reflect the new RAG configuration behavior.
  • Tests

    • Updated coverage to verify that unconfigured tool RAG remains disabled and does not list vector stores.

Jazzcort added 2 commits July 14, 2026 14:54
…nfigured

Previously, when neither rag.tool nor rag.inline were configured,
prepare_tools would fetch and register all vector stores from
llama-stack as a backward-compatibility fallback. This implicit
behavior is removed — tool RAG now requires explicit configuration
via rag.tool. Updated docs, config model, example YAML, and tests
to reflect the new behavior.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

RAG documentation now states that inline and Tool RAG are disabled unless explicitly configured. Tool preparation no longer implicitly registers all vector stores, while direct vector-store listing remains supported and tests reflect the updated behavior.

Changes

RAG strategy behavior

Layer / File(s) Summary
RAG configuration contract
docs/..., src/models/config.py, examples/lightspeed-stack-byok-okp-rag.yaml
RAG strategy documentation and configuration descriptions now state that inline and tool default to empty arrays and that omitted Tool RAG is disabled.
Tool vector-store resolution
src/utils/responses.py, tests/unit/utils/test_responses.py
prepare_tools no longer falls back to all stores when Tool RAG is unconfigured; get_vector_store_ids always lists available stores, with tests updated for the revised interface and behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: tisnik, tisnik

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: normalizing default Tool and Inline RAG behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Performance And Algorithmic Complexity ✅ Passed No new N+1, quadratic, or unbounded work: prepare_tools resolves IDs once and skips fallback fetches; get_vector_store_ids is unused in production and remains a single list call.
Security And Secret Handling ✅ Passed PASS: Diff only removes RAG fallback/docs/tests; no plaintext secrets, auth/authz, injection, sensitive-response logging, or K8s Secret changes found.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

@Jazzcort Jazzcort marked this pull request as draft July 14, 2026 19:48

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/unit/utils/test_responses.py (1)

3062-3065: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename test to reflect the updated function signature.

Since get_vector_store_ids no longer accepts a vector_store_ids parameter, the "when_no_ids_provided" suffix is obsolete. Consider renaming the test for clarity.

♻️ Proposed fix
-    async def test_fetches_all_when_no_ids_provided(
+    async def test_fetches_all_vector_stores(
         self, mocker: MockerFixture
     ) -> None:
-        """Test that all vector stores are fetched when no IDs provided."""
+        """Test that all available vector stores are fetched."""
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/utils/test_responses.py` around lines 3062 - 3065, Rename the test
method test_fetches_all_when_no_ids_provided to reflect that
get_vector_store_ids no longer accepts a vector_store_ids argument, removing the
obsolete “when_no_ids_provided” wording while preserving the test behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/unit/utils/test_responses.py`:
- Around line 3062-3065: Rename the test method
test_fetches_all_when_no_ids_provided to reflect that get_vector_store_ids no
longer accepts a vector_store_ids argument, removing the obsolete
“when_no_ids_provided” wording while preserving the test behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c8e521c5-292b-4e00-a6df-6ba018037946

📥 Commits

Reviewing files that changed from the base of the PR and between 216426e and 649cc20.

📒 Files selected for processing (8)
  • docs/byok_guide.md
  • docs/config.md
  • docs/models/responses_succ.md
  • docs/openapi.md
  • examples/lightspeed-stack-byok-okp-rag.yaml
  • src/models/config.py
  • src/utils/responses.py
  • tests/unit/utils/test_responses.py
📜 Review details
⏰ Context from checks skipped due to timeout. (15)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: Pylinter
  • GitHub Check: build-pr
  • GitHub Check: mypy
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-7-on-pull-request
⚠️ CI failures not shown inline (3)

GitHub Actions: OpenAPI (Spectral) / 0_spectral.txt: LCORE-1427: Normalize Tool and Inline RAG default behavior

Conclusion: failure

View job details

##[group]Run set -euo pipefail
 �[36;1mset -euo pipefail�[0m
 �[36;1muv run python scripts/generate_openapi_schema.py /tmp/openapi-generated.json�[0m
 �[36;1mif ! diff -u docs/openapi.json /tmp/openapi-generated.json; then�[0m
 �[36;1m  echo "::error::docs/openapi.json is out of date. Regenerate with: uv run scripts/generate_openapi_schema.py docs/openapi.json"�[0m

GitHub Actions: Pydocstyle / 0_pydocstyle.txt: LCORE-1427: Normalize Tool and Inline RAG default behavior

Conclusion: failure

View job details

##[group]Run uv tool run pydocstyle -v src tests
 �[36;1muv tool run pydocstyle -v src tests�[0m
 shell: /usr/bin/bash -e {0}
 env:
   UV_PYTHON: 3.12
   VIRTUAL_ENV: /home/runner/work/lightspeed-stack/lightspeed-stack/.venv
   UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
 ##[endgroup]
 Installed 2 packages in 3ms
 Checking file src/configuration.py.
 Checking file src/__init__.py.
 Checking file src/version.py.
 Checking file src/sentry.py.
 Checking file src/lightspeed_stack.py.
 Checking file src/client.py.
 Checking file src/constants.py.
 Checking file src/log.py.
 Checking file src/llama_stack_configuration.py.
 Checking file src/quota/quota_exceed_error.py.
 Checking file src/quota/sql.py.
 Checking file src/quota/__init__.py.
 Checking file src/quota/user_quota_limiter.py.
 Checking file src/quota/connect_pg.py.
 Checking file src/quota/revokable_quota_limiter.py.
 Checking file src/quota/quota_limiter.py.
 Checking file src/quota/quota_limiter_factory.py.
 Checking file src/quota/connect_sqlite.py.
 Checking file src/quota/token_usage_history.py.
 Checking file src/quota/cluster_quota_limiter.py.
 Checking file src/utils/vector_search.py.
 Checking file src/utils/stream_interrupts.py.
 Checking file src/utils/prompts.py.
 Checking file src/utils/__init__.py.
 Checking file src/utils/mcp_oauth_probe.py.
 Checking file src/utils/checks.py.
 Checking file src/utils/config_dumper.py.
 Checking file src/utils/openapi_schema_dumper.py.
 Checking file src/utils/quota_utils.py.
 Checking file src/utils/endpoints.py.
 Checking file src/utils/responses.py.
 Checking file src/utils/rh_identity.py.
 Checking file src/utils/reranker.py.
 Checking file src/utils/token_counter.py.
 Checking file src/utils/pydantic_ai_helpers.py.
 Checking file src/utils/mcp_auth_headers.py.
 Checking file src/utils/degraded_mode.py.
 Checking file src/utils/json_schema_updater.py.
 Checking file src/utils/llama_stack_version.py.
 Checking file src/utils/mcp_headers.py.
 Checkin...

GitHub Actions: OpenAPI (Spectral) / spectral: LCORE-1427: Normalize Tool and Inline RAG default behavior

Conclusion: failure

View job details

##[group]Run set -euo pipefail
 �[36;1mset -euo pipefail�[0m
 �[36;1muv run python scripts/generate_openapi_schema.py /tmp/openapi-generated.json�[0m
 �[36;1mif ! diff -u docs/openapi.json /tmp/openapi-generated.json; then�[0m
 �[36;1m  echo "::error::docs/openapi.json is out of date. Regenerate with: uv run scripts/generate_openapi_schema.py docs/openapi.json"�[0m
🧰 Additional context used
📓 Path-based instructions (5)
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: Flag meaningful O(n^2)+ algorithms on non-trivial inputs, including handlers and Kubernetes list operations.
Flag N+1 patterns that list items and then query once per item, including Kubernetes API and database access.
Flag expensive work inside loops, including API calls, JSON parsing, and regex compilation.
Flag unbounded growth in caches, watchers, or buffers when eviction or limits are missing.
Flag missing pagination or limits on list operations and API endpoints.
Flag secrets or tokens logged in plaintext or hardcoded in source.
Flag API endpoints missing authentication or authorization.
Flag injection vulnerabilities, including SQL injection, command injection, and path traversal.
Flag sensitive data leaked in API responses, WebSocket messages, or logs.
Flag Kubernetes Secrets and Red Hat secrets missing OwnerReferences.

Files:

  • examples/lightspeed-stack-byok-okp-rag.yaml
  • docs/byok_guide.md
  • docs/models/responses_succ.md
  • docs/config.md
  • docs/openapi.md
  • src/utils/responses.py
  • src/models/config.py
  • tests/unit/utils/test_responses.py
**/*.{py,toml,yaml,yml,json}

📄 CodeRabbit inference engine (AGENTS.md)

Run and satisfy the project's configured quality checks, including Black, Pylint, Pyright, Ruff, pydocstyle, type checks, and Bandit security scanning.

Files:

  • examples/lightspeed-stack-byok-okp-rag.yaml
  • src/utils/responses.py
  • src/models/config.py
  • tests/unit/utils/test_responses.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use absolute imports for internal Python modules and check pyproject.toml for existing dependencies and versions before adding dependencies.
All Python modules must begin with descriptive docstrings; package __init__.py files must contain brief package descriptions.
Use logger = get_logger(__name__) from log.py for module logging.
Use Final[type] for constants and check constants.py for shared constants before defining new ones.
Define type aliases at module level for clarity.
All functions must have Google-style docstrings and complete parameter and return type annotations.
Use typing_extensions.Self for model validators, modern union syntax such as str | int, and Optional[Type] for optional values.
Use descriptive, action-oriented snake_case names for functions, such as get_, validate_, and check_.
Do not modify parameter objects in place when producing results; return a new data structure instead.
Use async def for I/O operations and external API calls.
Handle APIConnectionError from Llama Stack integrations.
Use standard logger levels appropriately: debug for diagnostics, info for normal execution, warning for unexpected or potentially problematic conditions, and error for serious failures.
All classes must have descriptive Google-style docstrings, complete attribute type annotations, and specific types instead of Any.
Use PascalCase for classes with descriptive suffixes, including Configuration, Error/Exception, Resolver, and Interface where applicable.
Use ABC and @abstractmethod for abstract interfaces.
Follow Google Python docstring conventions and include Parameters, Returns, Raises, and Attributes sections when applicable.

Files:

  • src/utils/responses.py
  • src/models/config.py
  • tests/unit/utils/test_responses.py
src/models/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use BaseModel for data models, ConfigurationBase for configuration models, and Pydantic @model_validator and @field_validator for validation.

Files:

  • src/models/config.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use pytest for all unit tests; do not use unittest. Put shared fixtures in conftest.py, use pytest-mock for mocks, mark async tests with pytest.mark.asyncio, and maintain at least 60% unit-test coverage.

Files:

  • tests/unit/utils/test_responses.py
🧠 Learnings (6)
📚 Learning: 2026-05-20T08:09:30.641Z
Learnt from: max-svistunov
Repo: lightspeed-core/lightspeed-stack PR: 1580
File: docs/design/llama-stack-config-merge/poc-results/library-mode/synthesized-run.yaml:107-110
Timestamp: 2026-05-20T08:09:30.641Z
Learning: In Llama-stack config YAMLs, when defining a Llama Guard safety shield entry, set `provider_shield_id` to the *guard model identifier* (e.g., `meta-llama/Llama-Guard-3-8B`). Do not use a chat/generative model id (e.g., `openai/gpt-4o-mini`): a chat-model id (or `native_override`) indicates only an override landed and does **not** mean the safety shield is actually gating queries. Ensure any E2E coverage for the related implementation (JIRA/E2E tests) exercises a real Llama Guard model to verify that the shield is effective.

Applied to files:

  • examples/lightspeed-stack-byok-okp-rag.yaml
📚 Learning: 2026-02-23T14:56:59.186Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1198
File: src/utils/responses.py:184-192
Timestamp: 2026-02-23T14:56:59.186Z
Learning: In the lightspeed-stack codebase (lightspeed-core/lightspeed-stack), do not enforce de-duplication of duplicate client.models.list() calls in model selection flows (e.g., in src/utils/responses.py prepare_responses_params). These calls are considered relatively cheap and removing duplicates could add unnecessary complexity to the flow. Apply this guideline specifically to this file/context unless similar performance characteristics and design decisions are documented elsewhere.

Applied to files:

  • src/utils/responses.py
📚 Learning: 2026-06-24T13:45:37.249Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 1971
File: src/utils/markdown_repair.py:31-36
Timestamp: 2026-06-24T13:45:37.249Z
Learning: In the lightspeed-stack repository, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments, even if the project references Google Python docstring conventions. Ensure docstrings follow the project’s established "Parameters:" header format for any documented function parameters.

Applied to files:

  • src/utils/responses.py
  • src/models/config.py
  • tests/unit/utils/test_responses.py
📚 Learning: 2026-07-06T15:26:18.398Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 2071
File: src/models/config.py:2416-2422
Timestamp: 2026-07-06T15:26:18.398Z
Learning: In this repo’s Python code under src/**, don’t treat differences in string concatenation style as a style inconsistency when Black has effectively forced (or made clearer) use of explicit `+` string concatenation in multi-line logger/string expressions. If adjacent-literal implicit concatenation is avoided/changed specifically to accommodate Black’s formatting in these call sites, accept the `+` usage and don’t recommend converting it solely for consistency with nearby blocks that use implicit concatenation.

Applied to files:

  • src/utils/responses.py
  • src/models/config.py
📚 Learning: 2026-01-12T10:58:40.230Z
Learnt from: blublinsky
Repo: lightspeed-core/lightspeed-stack PR: 972
File: src/models/config.py:459-513
Timestamp: 2026-01-12T10:58:40.230Z
Learning: In lightspeed-core/lightspeed-stack, for Python files under src/models, when a user claims a fix is done but the issue persists, verify the current code state before accepting the fix. Steps: review the diff, fetch the latest changes, run relevant tests, reproduce the issue, search the codebase for lingering references to the original problem, confirm the fix is applied and not undone by subsequent commits, and validate with local checks to ensure the issue is resolved.

Applied to files:

  • src/models/config.py
📚 Learning: 2026-02-25T07:46:33.545Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1211
File: src/models/responses.py:8-16
Timestamp: 2026-02-25T07:46:33.545Z
Learning: In the Python codebase, requests.py should use OpenAIResponseInputTool as Tool while responses.py uses OpenAIResponseTool as Tool. This difference is intentional due to differing schemas for input vs output tools in llama-stack-api. Apply this distinction consistently to other models under src/models (e.g., ensure request-related tools use the InputTool variant and response-related tools use the ResponseTool variant). If adding new tools, choose the corresponding InputTool or Tool class based on whether the tool represents input or output, and document the rationale in code comments.

Applied to files:

  • src/models/config.py
🪛 GitHub Actions: Pydocstyle / 0_pydocstyle.txt
src/utils/responses.py

[error] 133-133: pydocstyle: D401: First line should be in imperative mood (perhaps 'Fetch', not 'Fetche')

🪛 GitHub Actions: Pydocstyle / pydocstyle
src/utils/responses.py

[error] 133-133: pydocstyle: D401 violation in public function get_vector_store_ids: First line should be in imperative mood (perhaps 'Fetch', not 'Fetche').

🔇 Additional comments (6)
docs/byok_guide.md (1)

264-268: LGTM!

docs/config.md (1)

609-616: LGTM!

docs/models/responses_succ.md (1)

1843-1850: LGTM!

docs/openapi.md (1)

8158-8165: LGTM!

examples/lightspeed-stack-byok-okp-rag.yaml (1)

63-63: LGTM!

src/models/config.py (1)

2261-2262: LGTM!

Also applies to: 2277-2277

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