From 6252f1098a3d37fccf2cd6dcc5eee1c2abdb4fbe Mon Sep 17 00:00:00 2001 From: mkzung <103102868+mkzung@users.noreply.github.com> Date: Sun, 19 Jul 2026 18:46:35 +0500 Subject: [PATCH] fix(gigachat): don't claim stop support the provider lacks get_supported_openai_params listed stop, but map_openai_params discarded it with a comment saying GigaChat has no stop sequences. Listing it suppresses the UnsupportedParamsError litellm raises for unsupported params, so the sequences went missing with no error and generation ran on. Dropping stop from the list restores the normal path: an error naming the param, or a quiet drop under drop_params=True. --- litellm/llms/gigachat/chat/transformation.py | 9 +++---- tests/llm_translation/test_gigachat.py | 26 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/litellm/llms/gigachat/chat/transformation.py b/litellm/llms/gigachat/chat/transformation.py index 15a1b463c3f..23847e9b4f0 100644 --- a/litellm/llms/gigachat/chat/transformation.py +++ b/litellm/llms/gigachat/chat/transformation.py @@ -135,14 +135,16 @@ class GigaChatConfig(BaseConfig): return headers def get_supported_openai_params(self, model: str) -> list[str]: # mutable-ok: base class contract returns list - """Return list of supported OpenAI parameters.""" + """Return list of supported OpenAI parameters. + + No stop: the GigaChat request body has no stop field. + """ return [ "stream", "temperature", "top_p", "max_tokens", "max_completion_tokens", - "stop", "tools", "tool_choice", "functions", @@ -171,9 +173,6 @@ class GigaChatConfig(BaseConfig): optional_params["top_p"] = value elif param in ("max_tokens", "max_completion_tokens"): optional_params["max_tokens"] = value - elif param == "stop": - # GigaChat doesn't support stop sequences - pass elif param == "tools": # Convert tools to functions format if isinstance(value, Sequence): diff --git a/tests/llm_translation/test_gigachat.py b/tests/llm_translation/test_gigachat.py index 3c47f692ce0..fbd013e0285 100644 --- a/tests/llm_translation/test_gigachat.py +++ b/tests/llm_translation/test_gigachat.py @@ -359,6 +359,32 @@ class TestGigaChatSupportedParams: assert "response_format" in supported assert "stream" in supported + def test_stop_not_supported(self, config): + """Claiming stop would silence UnsupportedParamsError and drop the sequences.""" + assert "stop" not in config.get_supported_openai_params("GigaChat") + + def test_stop_raises_instead_of_being_dropped(self, config): + """stop raises UnsupportedParamsError.""" + import litellm + from litellm.utils import get_optional_params + + with pytest.raises(litellm.UnsupportedParamsError): + get_optional_params( + model="GigaChat", custom_llm_provider="gigachat", stop=["END"] + ) + + def test_stop_dropped_with_drop_params(self, config): + """drop_params=True drops stop.""" + from litellm.utils import get_optional_params + + params = get_optional_params( + model="GigaChat", + custom_llm_provider="gigachat", + stop=["END"], + drop_params=True, + ) + assert "stop" not in params + class TestGigaChatToolChoiceMapping: """Tests for tool_choice -> function_call mapping"""