Skip to content

The agent that grows with you

fix(agent): reject unsupported Codex video input

fangliquanflq2b7b940046d0
diff --git a/agent/codex_responses_adapter.py b/agent/codex_responses_adapter.py
index bc079c2d322..0dadad59b95 100644
--- a/agent/codex_responses_adapter.py
+++ b/agent/codex_responses_adapter.py
@@ -43,6 +43,7 @@ _FULLWIDTH_PIPE = "\uff5c"
_TEXT_PART_TYPES = {"text", "input_text", "output_text"}
_IMAGE_PART_TYPES = {"image_url", "input_image"}
+_VIDEO_PART_TYPES = {"video", "video_url", "input_video"}
_OUTPUT_TEXT_TYPES = {"output_text", "text"}
_ASSISTANT_IMAGE_PLACEHOLDER = "[Assistant image omitted during replay]"
_INCOMPLETE_STATUSES = {"queued", "in_progress", "incomplete"}
@@ -181,7 +182,13 @@ def _input_image_part(part: Dict[str, Any], role: str = "user", *, keep_empty_ur
def _chat_content_to_responses_parts(content: Any, *, role: str = "user") -> List[Dict[str, Any]]:
"""Chat-style multimodal content → Responses API input parts ([] if not a list). Text is
``input_text`` (user) / ``output_text`` (assistant) — the API rejects the wrong type per role;
- ``input_image`` is only legal on user messages (see :func:`_input_image_part`)."""
+ ``input_image`` is only legal on user messages (see :func:`_input_image_part`). Unsupported
+ video parts fail closed instead of silently turning a video request into a text-only request."""
+ for part in _as_list(content):
+ if isinstance(part, dict) and (ptype := _part_type(part)) in _VIDEO_PART_TYPES:
+ raise ValueError(
+ f"Codex Responses does not support {ptype} input; use a video-capable provider."
+ )
text_type = _text_type_for(role)
converted: List[Dict[str, Any]] = []
for kind, payload in _iter_content_parts(_as_list(content)):
diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py
index 413f1ad3394..3271af60808 100644
--- a/tests/agent/test_auxiliary_client.py
+++ b/tests/agent/test_auxiliary_client.py
@@ -3616,6 +3616,22 @@ class TestCodexAuxiliaryToolMessageConversion:
assert not any(it.get("role") == "tool" for it in input_items)
assert kwargs["instructions"] == "sys"
+ def test_video_input_fails_before_responses_request(self):
+ responses = MagicMock()
+ adapter = _CodexCompletionsAdapter(SimpleNamespace(responses=responses), "gpt-5.5")
+ messages = [{
+ "role": "user",
+ "content": [
+ {"type": "video_url", "video_url": {"url": "data:video/mp4;base64,AAAA"}},
+ {"type": "text", "text": "Describe the video"},
+ ],
+ }]
+
+ with pytest.raises(ValueError, match="does not support video_url input"):
+ adapter.create(messages=messages)
+
+ responses.create.assert_not_called()
+
class TestCodexAuxiliaryAdapterNullOutputRecovery:
def test_recovers_output_item_when_terminal_event_has_null_output(self):
diff --git a/tests/agent/test_codex_responses_adapter.py b/tests/agent/test_codex_responses_adapter.py
index d8da67a67bd..b92145009af 100644
--- a/tests/agent/test_codex_responses_adapter.py
+++ b/tests/agent/test_codex_responses_adapter.py
@@ -48,6 +48,16 @@ def test_chat_content_keeps_images_on_user_role():
}]
+def test_chat_content_rejects_video_instead_of_sending_text_only():
+ content = [
+ {"type": "video_url", "video_url": {"url": "data:video/mp4;base64,AAAA"}},
+ {"type": "text", "text": "Describe the video"},
+ ]
+
+ with pytest.raises(ValueError, match="does not support video_url input"):
+ _chat_messages_to_responses_input([{"role": "user", "content": content}])
+
+
def test_preflight_rewrites_raw_assistant_images_to_text_markers():
raw = [{
"role": "assistant",