Skip to content

The agent that grows with you

refactor(agent): move _without_structured_output_format to auxiliary_structured_output

Tekniumdb010cdf95e2
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index c0814ebf32d..c33c0b2c4c7 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -32,7 +32,7 @@ from agent.error_classifier import (
is_reasoning_required_rejection,
)
from agent.auxiliary_reasoning_floor import remember_reasoning_floor, with_reasoning_floor
-from agent.auxiliary_structured_output import remember_structured_output_rejection
+from agent.auxiliary_structured_output import _without_structured_output_format, remember_structured_output_rejection
from agent.codex_headers import (
CODEX_AUX_BASE_URL as _CODEX_AUX_BASE_URL,
apply_required_codex_headers as _apply_required_codex_headers,
@@ -3413,22 +3413,6 @@ def _is_structured_output_rejection(exc: Exception) -> bool:
return _is_unsupported_parameter_error(exc, "response_format") or _is_unsupported_parameter_error(exc, "output_config")
-def _without_structured_output_format(kwargs: dict) -> Optional[dict]:
- """Copy *kwargs* without ``response_format`` (top-level and ``extra_body``); None when nothing was
- removed, so call sites don't retry an unchanged request."""
- retry_kwargs = dict(kwargs)
- changed = retry_kwargs.pop("response_format", None) is not None
- extra_body = retry_kwargs.get("extra_body")
- if isinstance(extra_body, dict) and "response_format" in extra_body:
- remaining = {k: v for k, v in extra_body.items() if k != "response_format"}
- if remaining:
- retry_kwargs["extra_body"] = remaining
- else:
- retry_kwargs.pop("extra_body", None)
- changed = True
- return retry_kwargs if changed else None
-
-
def _is_reasoning_field_rejection(exc: Exception) -> bool:
"""Provider 400 rejecting a reasoning wire control by name (``reasoning_effort``, ``reasoning``,
``thinking``/``think``). Chat-only models behind OpenAI-compatible relays reject the top-level
diff --git a/agent/auxiliary_structured_output.py b/agent/auxiliary_structured_output.py
index d67057efb40..dc55012d4cd 100644
--- a/agent/auxiliary_structured_output.py
+++ b/agent/auxiliary_structured_output.py
@@ -109,3 +109,19 @@ def without_unsupported_response_format(
task or "call", _route_key(provider, base_url) or "provider", model or "model", format_type,
)
return {k: v for k, v in extra_body.items() if k != "response_format"}
+
+
+def _without_structured_output_format(kwargs: dict) -> Optional[dict]:
+ """Copy *kwargs* without ``response_format`` (top-level and ``extra_body``); None when nothing was
+ removed, so call sites don't retry an unchanged request."""
+ retry_kwargs = dict(kwargs)
+ changed = retry_kwargs.pop("response_format", None) is not None
+ extra_body = retry_kwargs.get("extra_body")
+ if isinstance(extra_body, dict) and "response_format" in extra_body:
+ remaining = {k: v for k, v in extra_body.items() if k != "response_format"}
+ if remaining:
+ retry_kwargs["extra_body"] = remaining
+ else:
+ retry_kwargs.pop("extra_body", None)
+ changed = True
+ return retry_kwargs if changed else None