From cbe2413b54c1f85ef377cc79e7ea99818527a9a1 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Thu, 17 Sep 2026 01:51:19 -0700 Subject: [PATCH] fix(aux): max_tokens rung retries even when the wire kwargs no longer carry the cap The rung table refused to re-send an unchanged request, but the Codex Responses route translates the caller cap away and gateways inject their own: the 400 names max_tokens while the kwargs show none, and the identical retry is what completes (tests/agent/test_injected_param_strip_retry_registry.py, red in CI on 99ff3b9). --- agent/auxiliary_client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index a7550e2a5f..8c09d193fd 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -7052,10 +7052,12 @@ def _without_temperature(kwargs: dict) -> Optional[dict]: return {k: v for k, v in kwargs.items() if k != "temperature"} if "temperature" in kwargs else None -def _without_max_tokens(kwargs: dict) -> Optional[dict]: - """Copy *kwargs* without either output cap; None when neither was sent.""" - retry_kwargs = {k: v for k, v in kwargs.items() if k not in ("max_tokens", "max_completion_tokens")} - return retry_kwargs if len(retry_kwargs) != len(kwargs) else None +def _without_max_tokens(kwargs: dict) -> dict: + """Copy *kwargs* without either output cap. Unlike the other strips this never returns None: a + route can translate the caller's cap into a field the wire kwargs no longer show (Codex + Responses), and the provider's own gateway may inject one — the 400 still names ``max_tokens`` + and the identical request completes on retry (registry class #89897/#90257).""" + return {k: v for k, v in kwargs.items() if k not in ("max_tokens", "max_completion_tokens")} def _is_max_tokens_rejection(exc: Exception, client: Any) -> bool: