Skip to content

feat(vector-stores): support Bedrock retrievalConfiguration passthrough#26685

Open
Sameerlite wants to merge 5 commits intolitellm_internal_stagingfrom
litellm_bedrock_retrievalconfig_passthrough2
Open

feat(vector-stores): support Bedrock retrievalConfiguration passthrough#26685
Sameerlite wants to merge 5 commits intolitellm_internal_stagingfrom
litellm_bedrock_retrievalconfig_passthrough2

Conversation

@Sameerlite
Copy link
Copy Markdown
Collaborator

@Sameerlite Sameerlite commented Apr 28, 2026

Route vector store search extra_body into provider transformers and handle Bedrock retrievalConfiguration explicitly so only intended provider-specific fields are forwarded.

Fixes LIT-2482

Relevant issues

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Screenshots / Proof of Fix

Type

🆕 New Feature
🐛 Bug Fix

Changes

image image

Route vector store search `extra_body` into provider transformers and handle Bedrock `retrievalConfiguration` explicitly so only intended provider-specific fields are forwarded.

Made-with: Cursor
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR threads extra_body through to all vector store provider transformers and adds explicit handling in the Bedrock transformer to extract and deep-copy retrievalConfiguration (supporting both camelCase and snake_case keys), merge it with standard params, and cast the result for the request body. All other providers accept the new parameter for interface compliance but ignore it. The previously flagged shallow-copy mutation and undocumented override behaviors are fully addressed: deepcopy prevents caller mutation, verbose_logger.debug logs any conflict between extra_body and standard params, and three new tests verify the non-mutation and override semantics end-to-end.

Confidence Score: 5/5

Safe to merge — no P0/P1 issues; all previously flagged concerns (shallow copy mutation, silent override) have been addressed with deepcopy, debug logging, and targeted tests.

The deep copy correctly prevents caller mutation, standard-params-win override is explicitly logged and covered by tests, the interface change is consistent across all 12 provider files, and new tests exercise all three key scenarios. No regressions for non-Bedrock providers since extra_body was never forwarded to transformers before this PR.

No files require special attention.

Important Files Changed

Filename Overview
litellm/llms/bedrock/vector_stores/transformation.py Core Bedrock transformer: uses deepcopy to safely extract retrievalConfiguration from extra_body, logs conflicts, and passes the full config through to Bedrock via cast(). All previous concerns (shallow copy mutation, silent override) are addressed.
litellm/llms/base_llm/vector_store/transformation.py Adds extra_body parameter to abstract and default implementations of transform_search_vector_store_request; interface change is consistent across the class hierarchy.
litellm/llms/custom_httpx/llm_http_handler.py Threads extra_body through to both sync and async transform_search_vector_store_request call sites; straightforward plumbing change.
tests/test_litellm/llms/bedrock/vector_stores/test_bedrock_vector_store_transformation.py Adds three new tests covering: extra_body passthrough with irrelevant fields excluded, no mutation of caller's extra_body when max_num_results overrides, and no mutation when filters override. Good coverage of previously flagged concerns.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant llm_http_handler
    participant BedrockTransformer
    participant BedrockAPI

    Caller->>llm_http_handler: vector_store_search(query, extra_body, optional_params)
    llm_http_handler->>BedrockTransformer: transform_search_vector_store_request(query, optional_params, extra_body)
    Note over BedrockTransformer: deepcopy(extra_body["retrievalConfiguration"])
    Note over BedrockTransformer: Merge max_num_results → numberOfResults (standard param wins)
    Note over BedrockTransformer: Merge filters → filter (standard param wins)
    Note over BedrockTransformer: cast(BedrockKBRetrievalConfiguration, retrieval_config)
    BedrockTransformer-->>llm_http_handler: (url, request_body)
    llm_http_handler->>BedrockAPI: POST /knowledgebases/{id}/retrieve
    BedrockAPI-->>llm_http_handler: retrievalResults
    llm_http_handler-->>Caller: VectorStoreSearchResponse
Loading

Reviews (3): Last reviewed commit: "Fix tests" | Re-trigger Greptile

Comment thread litellm/llms/bedrock/vector_stores/transformation.py Outdated
Comment thread litellm/llms/bedrock/vector_stores/transformation.py
Comment thread litellm/llms/bedrock/vector_stores/transformation.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri mateo-berri self-requested a review April 29, 2026 04:40
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