test(responses): route the bridge regression through real providers instead of patching ProviderConfigManager

Drops the helper docstring and the test docstrings. The passthrough case now
uses together_ai, which has no native Responses config on main, so the test no
longer monkeypatches ProviderConfigManager at the class level

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yassin 2026-09-14 23:27:05 +00:00
parent 04c003c098
commit cc872c760a
2 changed files with 29 additions and 21 deletions

View file

@ -415,7 +415,6 @@ def _bridge_kwargs(
responses_api_provider_config: BaseResponsesAPIConfig | None,
allowed_openai_params: Sequence[str] | None,
) -> Mapping[str, object]:
"""Drop the provider-specific kwargs a native Responses dispatch would never forward, unless explicitly allowed."""
if responses_api_provider_config is None:
return kwargs
forwarded_keys: Final = frozenset(

View file

@ -192,33 +192,44 @@ class TestUseResponsesApiBridgeFlag:
]
@pytest.mark.parametrize(
("provider_config", "allowed_openai_params", "expected_chat_template_kwargs"),
("model", "upstream_url", "use_chat_completions_api", "allowed_openai_params", "expected_chat_template_kwargs"),
[
pytest.param(litellm.OpenAIResponsesAPIConfig(), None, None, id="native-config-drops-unknown-param"),
pytest.param(
litellm.OpenAIResponsesAPIConfig(),
"openai/my-custom-model",
"https://api.openai.com/v1/chat/completions",
True,
None,
None,
id="native-config-drops-unknown-param",
),
pytest.param(
"openai/my-custom-model",
"https://api.openai.com/v1/chat/completions",
True,
["chat_template_kwargs"],
{"thinking": True},
id="native-config-keeps-allowed-param",
),
pytest.param(None, None, {"thinking": True}, id="no-native-config-keeps-passthrough"),
pytest.param(
"together_ai/my-custom-model",
"https://api.together.ai/v1/chat/completions",
False,
None,
{"thinking": True},
id="no-native-config-keeps-passthrough",
),
],
)
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
def test_bridge_forwards_same_params_as_native_dispatch(
self,
mock_get_config,
provider_config,
allowed_openai_params,
expected_chat_template_kwargs,
model: str,
upstream_url: str,
use_chat_completions_api: bool,
allowed_openai_params: list[str] | None,
expected_chat_template_kwargs: dict[str, bool] | None,
respx_mock: respx.MockRouter,
):
"""A deployment-supplied provider-specific kwarg (``chat_template_kwargs``) reaches the
provider through the bridge only when the native Responses path would forward it too:
never for a provider with a native config, unless the caller allowed it explicitly, and
always for a provider without one, whose only Responses path is the bridge."""
mock_get_config.return_value = provider_config
upstream: Final = respx_mock.post("https://api.openai.com/v1/chat/completions").mock(
upstream: Final = respx_mock.post(upstream_url).mock(
return_value=httpx.Response(
status_code=200,
json={
@ -235,13 +246,13 @@ class TestUseResponsesApiBridgeFlag:
)
response: Final = litellm.responses(
model="openai/my-custom-model",
model=model,
input="Hello",
use_chat_completions_api=True,
use_chat_completions_api=use_chat_completions_api,
allowed_openai_params=allowed_openai_params,
chat_template_kwargs={"thinking": True},
drop_params=True,
api_key="fake-openai-api-key",
api_key="fake-provider-api-key",
num_retries=0,
)
@ -252,8 +263,6 @@ class TestUseResponsesApiBridgeFlag:
assert response.output[0].content[0].text == "Answer"
def test_bridge_keeps_deployment_credentials_while_dropping_unknown_params(self, respx_mock: respx.MockRouter):
"""Azure has a native Responses config, so its bridged request drops the unknown param but still
authenticates with the deployment credential, which the native path reads from the same kwargs."""
upstream: Final = respx_mock.post(
"https://example-resource.openai.azure.com/openai/deployments/my-deployment/chat/completions",
params={"api-version": "2024-10-21"},