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).
This commit is contained in:
teknium1
2026-09-17 01:51:19 -07:00
committed by Teknium
parent 7f03867523
commit cbe2413b54

View File

@@ -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: