From 3ee1ccf3fdf19ceb51def767dbed48e52b13e709 Mon Sep 17 00:00:00 2001 From: Alexander Chernov Date: Mon, 24 Aug 2026 16:16:35 +0100 Subject: [PATCH] refactor(chatgpt): bind the coerced input instead of rebinding the parameter Greptile flagged the parameter rebinding and the explanatory comments against the repo conventions in CLAUDE.md, which bans rebinding a function parameter (LIT011) and keeps comments to suppressions, TODOs and genuinely complex logic Bind a Final local for the coerced input rather than reassigning `input`, and drop both prose comments; the rationale lives in the commit and the PR body rather than duplicated at the call site. The mutable-ok suppression stays, since it is the allowed kind and the list is still constructed Behaviour is unchanged: 24 tests pass, and the same 4 fail with only the provider file reverted to base Signed-off-by: Alexander Chernov --- litellm/llms/chatgpt/responses/transformation.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/litellm/llms/chatgpt/responses/transformation.py b/litellm/llms/chatgpt/responses/transformation.py index c5f67b78654..2fbbffde1ef 100644 --- a/litellm/llms/chatgpt/responses/transformation.py +++ b/litellm/llms/chatgpt/responses/transformation.py @@ -66,13 +66,14 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig): litellm_params: GenericLiteLLMParams, headers: dict, ) -> dict: - # The Responses API accepts a string or a list, but this backend - # rejects a string with {"detail": "Input must be a list"}. - if isinstance(input, str): - input = [{"role": "user", "content": input}] # mutable-ok: the wire payload this backend requires + coerced_input: Final = ( + [{"role": "user", "content": input}] # mutable-ok: the wire shape this backend accepts + if isinstance(input, str) + else input + ) request: Final = super().transform_responses_api_request( model, - input, + coerced_input, response_api_optional_request_params, litellm_params, headers, @@ -103,8 +104,6 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig): "reasoning", "previous_response_id", "truncation", - # The chat-to-responses bridge translates response_format into - # "text"; dropping it here discards strict schemas silently. "text", }