Skip to content

LCORE-1560: Output vector stores in user-facing format#1385

Merged
tisnik merged 1 commit intolightspeed-core:mainfrom
asimurka:conversation_management
Mar 26, 2026
Merged

LCORE-1560: Output vector stores in user-facing format#1385
tisnik merged 1 commit intolightspeed-core:mainfrom
asimurka:conversation_management

Conversation

@asimurka
Copy link
Copy Markdown
Contributor

@asimurka asimurka commented Mar 24, 2026

Description

Currently, LCORE users specify vector store IDs in user-facing format that is internally translated into LLS format. POST v1/responses endpoint echoes configured tools in tools attribute that currently contains vector store IDs in LLS format.
This PR introduces reverse translation to user-facing format during response processing.

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: Cursor

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

  • 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

    • Vector store IDs are translated automatically in requests and responses so user-facing IDs are accepted and returned consistently for file search tools.
  • Documentation

    • Clarified that file search accepts LCORE-format IDs and that the system performs internal translation to/from the internal format; added a dedicated "Vector store IDs" note explaining request/response behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 24, 2026

Walkthrough

Adds LCORE↔Llama Stack vector-store-ID translation: new utility to remap file_search.vector_store_ids, integrated into request echoing and both streaming and non‑streaming response generation; docs updated and unit tests added. (46 words)

Changes

Cohort / File(s) Summary
Documentation
docs/responses.md
Clarified that file_search.vector_store_ids are accepted/returned in LCORE format and translated internally to/from Llama Stack format.
Translation Utility
src/utils/tool_formatter.py
Added translate_vector_store_ids_to_user_facing(tools, rag_id_mapping) to remap file_search vector_store_ids using a provided mapping; preserves unmapped IDs and non-file_search tools.
Request Echoing
src/models/requests.py
ResponsesRequest.echoed_params() now applies translate_vector_store_ids_to_user_facing(..., configuration.rag_id_mapping) when emitting the tools field for synthetic/OpenAI-style echoed params.
Response Handling
src/app/endpoints/responses.py
During streaming and non‑streaming response assembly, response tools are rewritten via translate_vector_store_ids_to_user_facing(...) using configuration.rag_id_mapping before sending to clients.
Tests
tests/unit/utils/test_tool_formatter.py
New unit tests covering empty mapping, mapped/unmapped IDs, non-file_search tool preservation, input immutability for file_search entries, and mixed-list ordering/behavior.

Sequence Diagram

sequenceDiagram
    participant Client
    participant RequestHandler as Request Handler
    participant Translator as ID Translator
    participant CoreLogic as Core Logic
    participant ResponseGen as Response Generator

    Client->>RequestHandler: Send request with LCORE `vector_store_ids`
    RequestHandler->>Translator: echoed_params(tools, rag_id_mapping)
    Translator->>RequestHandler: Return tools with Llama Stack IDs
    RequestHandler->>CoreLogic: Invoke core logic using Llama Stack IDs
    CoreLogic->>ResponseGen: Produce response containing tools (Llama Stack IDs)
    ResponseGen->>Translator: translate_vector_store_ids_to_user_facing(tools, rag_id_mapping)
    Translator->>ResponseGen: Return tools with LCORE IDs
    ResponseGen->>Client: Stream/return response with LCORE `vector_store_ids`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title 'LCORE-1560: Output vector stores in user-facing format' directly summarizes the main change—translating vector store IDs to user-facing format in response outputs, which is the core objective across all modified files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown
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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/endpoints/responses.py`:
- Around line 486-493: The response currently only translates top-level
response["tools"] but misses translating response["tool_choice"] when
tool_choice.type == "allowed_tools", leaving internal vector DB IDs in the
echoed payload; update the code that handles chunk_dict["response"] (and the
similar block at the other response path) to call
translate_vector_store_ids_to_user_facing for both response["tools"] and
response["tool_choice"]["tools"] (when tool_choice is a dict and type ==
"allowed_tools"), using configuration.rag_id_mapping and preserving other
tool_choice fields (i.e., replace tool_choice.tools with the translated list
while keeping the rest of tool_choice intact) so both streaming and
non-streaming responses return user-facing IDs.

In `@src/models/requests.py`:
- Around line 768-780: The response currently translates data["tools"] but not
data["tool_choice"], so internal llama-stack vector IDs can be echoed; after you
assign data["tools"] using translate_vector_store_ids_to_user_facing, also
translate the echoed tool choice(s) using the same helper and mapping: locate
the code around model_dump / tools handling (symbols: model_dump, tools,
OutputToolMCP, translate_vector_store_ids_to_user_facing,
configuration.rag_id_mapping) and, if data contains "tool_choice", call
translate_vector_store_ids_to_user_facing on that value (or map its contained
IDs) to replace internal vector_store IDs with user-facing IDs before returning
data.

In `@src/utils/tool_formatter.py`:
- Around line 151-152: The function currently returns the original tools list
when rag_id_mapping is falsy, violating the "return new list" contract; change
the early return to return a shallow copy of tools (e.g., tools.copy() or
list(tools)) so the caller receives a new list object while preserving the same
tool dict identities—modify the return at the rag_id_mapping falsy check in
tool_formatter (the block containing "if not rag_id.mapping: return tools")
accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 893fc8d4-2cd3-4fda-9d54-0258a71049a8

📥 Commits

Reviewing files that changed from the base of the PR and between 39116c7 and c03bec1.

📒 Files selected for processing (5)
  • docs/responses.md
  • src/app/endpoints/responses.py
  • src/models/requests.py
  • src/utils/tool_formatter.py
  • tests/unit/utils/test_tool_formatter.py

@asimurka asimurka force-pushed the conversation_management branch from c03bec1 to 6ff6acb Compare March 24, 2026 08:24
@asimurka asimurka changed the title [WIP] Output vector stores in user-facing format LCORE-1560: Output vector stores in user-facing format Mar 24, 2026
@asimurka asimurka requested review from are-ces and tisnik March 24, 2026 08:57
Copy link
Copy Markdown
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

@are-ces
Copy link
Copy Markdown
Contributor

are-ces commented Mar 25, 2026

LGTM

@tisnik tisnik merged commit 1ee31fc into lightspeed-core:main Mar 26, 2026
24 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.

3 participants