Skip to content

Conversation

@asimurka
Copy link
Contributor

@asimurka asimurka commented Jan 21, 2026

Description

This PR restores the original rag_chunks attribute in query response and marks it as deprecated. It also fixes source attribute parsing in rag chunk object.

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

Tools used to create PR

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

  • Assisted-by: N/A

Related Tickets & Documents

  • Related Issue #
  • Closes #

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

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • New Features
    • Added rag_chunks field to API responses (marked deprecated; use tool_results instead).
    • Added tool_results field to query responses for improved tool interaction transparency.
    • Enhanced RAG chunk source information to display actual file names instead of generic labels.
    • Refined API schema structure for tool calls and results fields for better consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Walkthrough

The pull request adds RAG chunk metadata to API responses by introducing a new RAGChunk schema and expanding QueryResponse to include rag_chunks and tool_results fields. It changes the RAG chunk source from a generic "file_search" label to actual filenames and restructures tool_calls and tool_results fields to be strict arrays instead of union types.

Changes

Cohort / File(s) Summary
OpenAPI Schema Definition
docs/openapi.json
Added new RAGChunk public schema with content, source, and score fields. Updated QueryResponse to include rag_chunks (array of RAGChunk, marked deprecated) and restructured tool_calls/tool_results from union types to strict arrays.
Response Models
src/models/responses.py
Added RAGChunk import, new rag_chunks: list[RAGChunk] field (deprecated) and tool_results: list[ToolResultSummary] field to QueryResponse class with defaults and descriptions.
Query Endpoints
src/app/endpoints/query.py
Updated query_endpoint_handler_base to pass rag_chunks=summary.rag_chunks when constructing final QueryResponse.
Query V2 Handler
src/app/endpoints/query_v2.py
Modified extract_rag_chunks_from_file_search_item to use actual item.filename as source instead of constant "file_search" string.
Unit Tests
tests/unit/app/endpoints/test_query_v2.py
Updated test expectations for RAG chunk source fields to reflect actual filenames ("file2.pdf", "file3.docx") instead of generic "file_search" label.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • are-ces
  • tisnik
  • asamal4
🚥 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 PR title accurately and concisely describes the main change: restoring the rag_chunks attribute in the query response, which is the primary objective of the changeset.
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 docstrings

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@docs/openapi.json`:
- Around line 7651-7658: The OpenAPI schema for the property "rag_chunks" is
marked deprecated only in its description; update the schema to include explicit
OpenAPI deprecation metadata by adding "deprecated": true to the rag_chunks
array schema (the property named "rag_chunks" that references
"#/components/schemas/RAGChunk"); apply the same change to the other occurrence
of the rag_chunks property found elsewhere in the document so tooling recognizes
it as deprecated.
🧹 Nitpick comments (1)
docs/openapi.json (1)

7976-8014: Consider locking down RAGChunk shape.
Most schemas here use additionalProperties: false; adding it would keep the contract consistent and prevent silent payload drift.

♻️ Suggested tweak
 "RAGChunk": {
+  "additionalProperties": false,
   "properties": {
     "content": {
       "type": "string",
       "title": "Content",
       "description": "The content of the chunk"
     },

Copy link
Contributor

@tisnik tisnik left a comment

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 bc59b98 into lightspeed-core:main Jan 21, 2026
20 of 22 checks passed
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.

2 participants