Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions python/packages/a2a/tests/test_a2a_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,13 +1284,11 @@ async def test_streaming_artifact_update_event_does_not_duplicate_terminal_task_
final=True,
)

mock_a2a_client.responses.extend(
[
(working_task, first_chunk),
(working_task, second_chunk),
(terminal_task, terminal_event),
]
)
mock_a2a_client.responses.extend([
(working_task, first_chunk),
(working_task, second_chunk),
(terminal_task, terminal_event),
])

stream = a2a_agent.run("Hello", stream=True)
updates: list[AgentResponseUpdate] = []
Expand Down Expand Up @@ -1371,12 +1369,10 @@ async def test_streaming_terminal_task_only_emits_unstreamed_artifacts(
final=True,
)

mock_a2a_client.responses.extend(
[
(working_task, streamed_chunk),
(terminal_task, terminal_event),
]
)
mock_a2a_client.responses.extend([
(working_task, streamed_chunk),
(terminal_task, terminal_event),
])

stream = a2a_agent.run("Hello", stream=True)
updates: list[AgentResponseUpdate] = []
Expand Down
9 changes: 5 additions & 4 deletions python/packages/openai/agent_framework_openai/_chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,16 +1353,17 @@ def _prepare_content_for_openai(
return ret
case "data" | "uri":
if content.has_top_level_media_type("image"):
return {
image_item: dict[str, Any] = {
"type": "input_image",
"image_url": content.uri,
"detail": content.additional_properties.get("detail", "auto")
if content.additional_properties
else "auto",
"file_id": content.additional_properties.get("file_id", None)
if content.additional_properties
else None,
}
file_id = content.additional_properties.get("file_id") if content.additional_properties else None
if file_id is not None:
image_item["file_id"] = file_id
return image_item
if content.has_top_level_media_type("audio"):
if content.media_type and "wav" in content.media_type:
format = "wav"
Expand Down
13 changes: 12 additions & 1 deletion python/packages/openai/tests/openai/test_openai_chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,18 @@ def test_prepare_content_for_openai_image_content() -> None:
result = client._prepare_content_for_openai("user", image_content_basic)
assert result["type"] == "input_image"
assert result["detail"] == "auto"
assert result["file_id"] is None
assert "file_id" not in result

# Test image content with additional_properties present but no file_id key
image_content_detail_only = Content.from_uri(
uri="https://example.com/basic.png",
media_type="image/png",
additional_properties={"detail": "high"},
)
result = client._prepare_content_for_openai("user", image_content_detail_only)
assert result["type"] == "input_image"
assert result["detail"] == "high"
assert "file_id" not in result


def test_prepare_content_for_openai_audio_content() -> None:
Expand Down
Loading