From bfd53100d9eeeb1deb9ab73362d3f5367e9a4aab Mon Sep 17 00:00:00 2001 From: jenkins Date: Sun, 16 Aug 2026 07:00:50 -0300 Subject: [PATCH] hermes: normalize routed vision messages --- services/hermes/scripts/codex_broker.py | 2 +- testing/tests/test_hermes_chat_quality.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/services/hermes/scripts/codex_broker.py b/services/hermes/scripts/codex_broker.py index bf641603..2320acb5 100644 --- a/services/hermes/scripts/codex_broker.py +++ b/services/hermes/scripts/codex_broker.py @@ -224,7 +224,7 @@ def _upstream_headers(token: str) -> dict[str, str]: def _normalize_input_images(response_input: list[Any]) -> None: """Normalize Chat-Completions image parts for the Codex Responses API.""" for item in response_input: - if not isinstance(item, dict) or item.get("type") != "message": + if not isinstance(item, dict): continue content = item.get("content") if not isinstance(content, list): diff --git a/testing/tests/test_hermes_chat_quality.py b/testing/tests/test_hermes_chat_quality.py index c4914c78..1cfbf12d 100644 --- a/testing/tests/test_hermes_chat_quality.py +++ b/testing/tests/test_hermes_chat_quality.py @@ -779,6 +779,28 @@ def test_codex_broker_auth_and_request_contract(tmp_path: Path, monkeypatch): "image_url": "data:image/png;base64,cHJpdmF0ZQ==", "detail": "high", } + switchyard_image_items = [ + { + "role": "user", + "content": [ + {"type": "input_text", "text": "What color is this?"}, + { + "type": "image_url", + "image_url": { + "url": "data:image/png;base64,cHJpdmF0ZQ==", + "detail": "auto", + }, + }, + ], + } + ] + assert module._validate_payload( + {"model": "gpt-5.6-terra", "input": switchyard_image_items} + )["input"][0]["content"][1] == { + "type": "input_image", + "image_url": "data:image/png;base64,cHJpdmF0ZQ==", + "detail": "auto", + } with pytest.raises(ValueError, match="non-empty Responses image URL"): module._validate_payload( {