The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(auxiliary): recognise Gemini's structured-output 400 wording
teknium1236aab3e8f13
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex f16ef1529e4..c075858bb20 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -3346,6 +3346,12 @@ def _is_structured_output_rejection(exc: Exception) -> bool:# without it is the same remedy, so treat the shape error as a rejection too.if "response_format" in err_lower and "json_schema" in err_lower:return True+ # Gemini native names its own generationConfig keys, never ours: "Function calling with a response+ # mime type: 'application/json' is unsupported" (pre-Gemini-3 + tools via a proxy), or an+ # "Unknown name"/"Invalid value" 400 on response_schema / response_json_schema for a schema the+ # surface cannot express. Same remedy: one retry without the format.+ if _contains_any(err_lower, ("response mime type", "response_schema", "response_json_schema")):+ return Truereturn _is_unsupported_parameter_error(exc, "response_format") or _is_unsupported_parameter_error(exc, "output_config")diff --git a/tests/agent/test_structured_output_rejection_retry.py b/tests/agent/test_structured_output_rejection_retry.pyindex 397f40c9984..ee726711346 100644--- a/tests/agent/test_structured_output_rejection_retry.py+++ b/tests/agent/test_structured_output_rejection_retry.py@@ -76,6 +76,10 @@ class TestIsStructuredOutputRejection:# (422, verbatim body from the gateway) -- no unsupported-parameter wording'HTTP 422: {"detail":[{"loc":["body","response_format","json_schema"],''"msg":"str type expected","type":"type_error.str"}]}',+ # Gemini native generationConfig wording (verbatim 400s from generativelanguage)+ "Gemini HTTP 400 (INVALID_ARGUMENT): Function calling with a response mime type: 'application/json' is unsupported",+ "Gemini HTTP 400 (INVALID_ARGUMENT): Invalid JSON payload received. Unknown name \"response_json_schema\" at 'generation_config'",+ "Gemini HTTP 400 (INVALID_ARGUMENT): Invalid value at 'generation_config.response_schema.properties[0].value.type'",])def test_matches_real_provider_messages(self, message):assert _is_structured_output_rejection(RuntimeError(message)) is True