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 <alexander@chernov.it>
This commit is contained in:
Alexander Chernov 2026-08-24 16:16:35 +01:00
parent c9117ec6c1
commit 3ee1ccf3fd
No known key found for this signature in database

View file

@ -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",
}