fix(llm): remove max_output_tokens from ChatGPT Subscription payload (#3656)
ChatGPT's Codex API rejects any request that includes max_output_tokens, returning HTTP 400 "Unsupported parameter: max_output_tokens". This caused Deep Research to always fail during the endpoint probe when a ChatGPT Subscription model was selected. Remove the conditional that set payload["max_output_tokens"] in _build_chatgpt_responses_payload(). The parameter is simply not sent. Also update the two affected tests: - Rename test_chatgpt_subscription_payload_uses_max_output_tokens → test_chatgpt_subscription_payload_omits_max_output_tokens - Rename test_chatgpt_subscription_payload_omits_empty_max_output_tokens → test_chatgpt_subscription_payload_omits_max_output_tokens_when_zero - Assert max_output_tokens is absent rather than present Fixes #3650
This commit is contained in:
parent
60d25e0e26
commit
9e74a327f8
2 changed files with 9 additions and 5 deletions
|
|
@ -563,8 +563,9 @@ def _build_chatgpt_responses_payload(
|
|||
}
|
||||
if not _restricts_temperature(model):
|
||||
payload["temperature"] = temperature
|
||||
if max_tokens and max_tokens > 0:
|
||||
payload["max_output_tokens"] = max_tokens
|
||||
# ChatGPT Subscription Codex API does not support max_output_tokens —
|
||||
# passing it returns HTTP 400 "Unsupported parameter: max_output_tokens".
|
||||
# Do not include it in the payload.
|
||||
return payload
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,10 @@ def test_normal_model_payload_keeps_temperature_above_one(monkeypatch):
|
|||
assert payload["temperature"] == 1.2
|
||||
|
||||
|
||||
def test_chatgpt_subscription_payload_uses_max_output_tokens():
|
||||
def test_chatgpt_subscription_payload_omits_max_output_tokens():
|
||||
# ChatGPT Subscription Codex API does not support max_output_tokens —
|
||||
# passing it returns HTTP 400 "Unsupported parameter: max_output_tokens".
|
||||
# The payload should NOT include max_output_tokens regardless of max_tokens.
|
||||
payload = llm_core._build_chatgpt_responses_payload(
|
||||
"gpt-5.1-codex",
|
||||
[{"role": "user", "content": "Say OK"}],
|
||||
|
|
@ -83,10 +86,10 @@ def test_chatgpt_subscription_payload_uses_max_output_tokens():
|
|||
max_tokens=37,
|
||||
)
|
||||
|
||||
assert payload["max_output_tokens"] == 37
|
||||
assert "max_output_tokens" not in payload
|
||||
|
||||
|
||||
def test_chatgpt_subscription_payload_omits_empty_max_output_tokens():
|
||||
def test_chatgpt_subscription_payload_omits_max_output_tokens_when_zero():
|
||||
payload = llm_core._build_chatgpt_responses_payload(
|
||||
"gpt-5.1-codex",
|
||||
[{"role": "user", "content": "Say OK"}],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue