From e244b63231bf056a276b1ec37afd6fa093517a78 Mon Sep 17 00:00:00 2001 From: Arun Mittal Date: Tue, 9 Jun 2026 17:18:54 -0400 Subject: [PATCH] fix(cerebras): include max_retries in supported OpenAI params allowlist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``max_retries`` is a standard parameter exposed by both the OpenAI Python client and LiteLLM's ``litellm.completion()`` API. The Cerebras inference endpoint accepts it without issue, but ``CerebrasConfig.get_supported_openai_params`` was omitting it from the allowlist, so LiteLLM was silently stripping the value before forwarding the call. Callers passing ``max_retries=N`` on Cerebras requests therefore had no way to override the default retry behaviour — the request flowed through unchanged but the override was dropped without warning. Adding ``"max_retries"`` to the allowlist lets the value reach the underlying HTTP client and lets per-call retry overrides work as documented. Tests (tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.py): - test_max_retries_in_supported_params — guards against future regressions removing the entry. - test_core_openai_params_still_supported — regression guard ensuring no existing allowlist entries are accidentally dropped by the change. --- litellm/llms/cerebras/chat.py | 1 + .../test_cerebras_chat_transformation.py | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.py diff --git a/litellm/llms/cerebras/chat.py b/litellm/llms/cerebras/chat.py index 9929e2ab9a2..308fdd6d529 100644 --- a/litellm/llms/cerebras/chat.py +++ b/litellm/llms/cerebras/chat.py @@ -68,6 +68,7 @@ class CerebrasConfig(OpenAIGPTConfig): "tool_choice", "tools", "user", + "max_retries", ] # Only add reasoning_effort for models that support it diff --git a/tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.py b/tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.py new file mode 100644 index 00000000000..6c4255bf4bd --- /dev/null +++ b/tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.py @@ -0,0 +1,53 @@ +""" +Unit tests for Cerebras chat configuration. +""" + +import os +import sys + +sys.path.insert( + 0, os.path.abspath("../../../../..") +) # project root for ``litellm`` import + +from litellm.llms.cerebras.chat import CerebrasConfig + + +class TestCerebrasGetSupportedOpenAIParams: + """Validates the OpenAI-param allowlist exposed by ``CerebrasConfig``.""" + + def test_max_retries_in_supported_params(self): + """``max_retries`` is a standard OpenAI client parameter that Cerebras + accepts. It must appear in the supported-param allowlist so callers + can override the default retry count per request without LiteLLM + stripping the value silently. + """ + config = CerebrasConfig() + params = config.get_supported_openai_params(model="llama3.1-8b") + assert "max_retries" in params, ( + f"max_retries should be in the Cerebras supported_params allowlist; " + f"got: {params!r}" + ) + + def test_core_openai_params_still_supported(self): + """Regression guard: the standard OpenAI params Cerebras has always + accepted must remain in the allowlist after the ``max_retries`` + addition (no accidental removals).""" + config = CerebrasConfig() + params = config.get_supported_openai_params(model="llama3.1-8b") + for expected in ( + "max_tokens", + "max_completion_tokens", + "response_format", + "seed", + "stop", + "stream", + "temperature", + "top_p", + "tool_choice", + "tools", + "user", + ): + assert expected in params, ( + f"{expected!r} unexpectedly missing from Cerebras supported_params: " + f"{params!r}" + )