Self-hosted AI workspace.
Python
fix(llm): remove max_output_tokens from ChatGPT Subscription payload (#3656)
Sid82a1d4c23953
diff --git a/src/llm_core.py b/src/llm_core.pyindex b012638fa..8da2c46e0 100644--- a/src/llm_core.py+++ b/src/llm_core.py@@ -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 payloaddiff --git a/tests/test_llm_core_temperature.py b/tests/test_llm_core_temperature.pyindex f49d3dba0..121a7ff4b 100644--- a/tests/test_llm_core_temperature.py+++ b/tests/test_llm_core_temperature.py@@ -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"}],