-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Forward custom_llm_provider through the Responses API bridge (Fixes #28505) #28575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sameerlite
merged 4 commits into
BerriAI:shin_agent_oss_staging_05_22_2026
from
Cyberfilo:fix/28505-responses-bridge-propagate-custom-llm-provider
Jun 1, 2026
+131
−0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c711540
Forward custom_llm_provider through the Responses API bridge (Fixes #…
Cyberfilo b638892
fix(28505): set custom_llm_provider on request_data instead of as dup…
Cyberfilo 24732c4
chore: trigger shin-agent re-eval on retargeted staging base
Cyberfilo 384a10a
chore: trigger shin-agent re-eval against updated Greptile state
Cyberfilo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
116 changes: 116 additions & 0 deletions
116
tests/test_litellm/completion_extras/test_responses_bridge_provider_propagation.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| """ | ||
| Regression test for https://github.com/BerriAI/litellm/issues/28505 - | ||
| the Responses API bridge double-strips the provider prefix from the | ||
| model name when a Chat Completions request has both `tools` and | ||
| `reasoning_effort`. | ||
|
|
||
| Root cause: the bridge handler called `litellm.responses()` / | ||
| `litellm.aresponses()` without passing the already-resolved | ||
| `custom_llm_provider`. The downstream call then re-invoked | ||
| `get_llm_provider()` with `custom_llm_provider=None`, which stripped | ||
| a second provider prefix from a `provider/provider/model` deployment | ||
| string. | ||
|
|
||
| This test pins both the sync and async bridge handler call sites: | ||
| the resolved `custom_llm_provider` must be forwarded to the underlying | ||
| `responses` / `aresponses` call so the provider isn't re-detected. | ||
| """ | ||
|
|
||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
|
|
||
| from litellm.completion_extras.litellm_responses_transformation.handler import ( | ||
| ResponsesToCompletionBridgeHandler, | ||
| ) | ||
|
|
||
|
|
||
| def _validated_kwargs(): | ||
| return { | ||
| "model": "openai/openai/openai/gpt-5.5", | ||
| "messages": [{"role": "user", "content": "hi"}], | ||
| "optional_params": {}, | ||
| "litellm_params": {}, | ||
| "headers": {}, | ||
| "model_response": MagicMock(), | ||
| "logging_obj": MagicMock(), | ||
| "custom_llm_provider": "openai", | ||
| } | ||
|
|
||
|
|
||
| def test_sync_completion_forwards_custom_llm_provider(): | ||
| handler = ResponsesToCompletionBridgeHandler() | ||
| handler.transformation_handler = MagicMock() | ||
| handler.transformation_handler.transform_request.return_value = { | ||
| "model": "openai/openai/openai/gpt-5.5", | ||
| "input": [], | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| # `_build_sanitized_litellm_params` spreads `custom_llm_provider` from | ||
| # `litellm_params` into request_data on the real bridge path. Seed | ||
| # it here so the test exercises the overwrite (not an explicit kwarg | ||
| # that would TypeError against an already-present key). | ||
| "custom_llm_provider": "should-be-overwritten", | ||
| } | ||
| handler.transformation_handler.transform_response.return_value = ( | ||
| _validated_kwargs()["model_response"] | ||
| ) | ||
| with ( | ||
| patch.object( | ||
| handler, "validate_input_kwargs", return_value=_validated_kwargs() | ||
| ), | ||
| patch( | ||
| "litellm.responses", | ||
| return_value=MagicMock(spec=[]), | ||
| ) as mock_responses, | ||
| ): | ||
| # The handler routes ResponsesAPIResponse through transform_response. | ||
| # We just want to verify the kwargs going INTO responses(). | ||
| try: | ||
| handler.completion(acompletion=False) | ||
| except Exception: | ||
| # Downstream handling (transform_response, type checks) is not | ||
| # the subject of this test. | ||
| pass | ||
| assert mock_responses.called | ||
| kwargs = mock_responses.call_args.kwargs | ||
| assert kwargs.get("custom_llm_provider") == "openai", ( | ||
| "sync bridge must forward custom_llm_provider to litellm.responses() " | ||
| "so the downstream get_llm_provider() call does not re-strip the " | ||
| "provider prefix on a provider/provider/model deployment string" | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_async_completion_forwards_custom_llm_provider(): | ||
| handler = ResponsesToCompletionBridgeHandler() | ||
| handler.transformation_handler = MagicMock() | ||
| handler.transformation_handler.transform_request.return_value = { | ||
| "model": "openai/openai/openai/gpt-5.5", | ||
| "input": [], | ||
| # `_build_sanitized_litellm_params` spreads `custom_llm_provider` from | ||
| # `litellm_params` into request_data on the real bridge path. Seed | ||
| # it here so the test exercises the overwrite (not an explicit kwarg | ||
| # that would TypeError against an already-present key). | ||
| "custom_llm_provider": "should-be-overwritten", | ||
| } | ||
|
|
||
| async def _fake_aresponses(**kwargs): | ||
| _fake_aresponses.kwargs = kwargs | ||
| return MagicMock(spec=[]) | ||
|
|
||
| _fake_aresponses.kwargs = {} | ||
|
|
||
| with ( | ||
| patch.object( | ||
| handler, "validate_input_kwargs", return_value=_validated_kwargs() | ||
| ), | ||
| patch("litellm.aresponses", _fake_aresponses), | ||
| ): | ||
| try: | ||
| await handler.acompletion() | ||
| except Exception: | ||
| pass | ||
| assert _fake_aresponses.kwargs.get("custom_llm_provider") == "openai", ( | ||
| "async bridge must forward custom_llm_provider to litellm.aresponses() " | ||
| "so the downstream get_llm_provider() call does not re-strip the " | ||
| "provider prefix on a provider/provider/model deployment string" | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.