Python: quiet A2AExecutor logging for unmapped content types (#7034)
* Python: quiet A2AExecutor logging for unmapped content types Tool-use responses include function_call/function_result content that the A2A executor does not surface, causing a WARNING per tool call. Log these at DEBUG and skip instead, matching the outbound content-conversion convention used across the Python chat clients. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ee74cc55-44df-4fcf-b38f-1f79f2600dfc * Address PR review: assert debug log args and drop redundant cast Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ee74cc55-44df-4fcf-b38f-1f79f2600dfc
This commit is contained in:
@@ -273,8 +273,10 @@ class A2AExecutor(AgentExecutor):
|
||||
elif content.type == "uri" and content.uri:
|
||||
parts.append(Part(url=content.uri, media_type=content.media_type or ""))
|
||||
else:
|
||||
# Silently skip unsupported content types
|
||||
logger.warning("A2AExecutor does not yet support content type: %s. Omitted.", content.type)
|
||||
# Content that doesn't map to an A2A part (e.g. intermediate function_call /
|
||||
# function_result from tool use) is skipped; only final user-facing output
|
||||
# (text/data/uri) is surfaced.
|
||||
logger.debug("Skipping unsupported content type for A2A: %s", content.type)
|
||||
|
||||
if parts:
|
||||
if isinstance(item, AgentResponseUpdate):
|
||||
|
||||
@@ -842,7 +842,7 @@ class TestA2AExecutorHandleEvents:
|
||||
assert call_kwargs["append"] is True
|
||||
|
||||
async def test_handle_unsupported_content_type(self, executor: A2AExecutor, mock_updater: MagicMock) -> None:
|
||||
"""Test handling messages with unsupported content types."""
|
||||
"""Test that unsupported content types are skipped quietly (debug, not warning)."""
|
||||
# Arrange
|
||||
message = Message(
|
||||
contents=[Content(type=cast(Any, "unknown"), text="Some text")], # type: ignore[arg-type]
|
||||
@@ -854,7 +854,25 @@ class TestA2AExecutorHandleEvents:
|
||||
await executor.handle_events(message, mock_updater)
|
||||
|
||||
# Assert
|
||||
mock_logger.warning.assert_called_once()
|
||||
mock_logger.warning.assert_not_called()
|
||||
mock_logger.debug.assert_called_once_with("Skipping unsupported content type for A2A: %s", "unknown")
|
||||
mock_updater.update_status.assert_not_called()
|
||||
|
||||
async def test_handle_intermediate_content_type(self, executor: A2AExecutor, mock_updater: MagicMock) -> None:
|
||||
"""Test that intermediate tool content (e.g. function_call) is skipped quietly (debug, not warning)."""
|
||||
# Arrange
|
||||
message = Message(
|
||||
contents=[Content(type="function_call")],
|
||||
role="assistant",
|
||||
)
|
||||
|
||||
# Act
|
||||
with patch("agent_framework_a2a._a2a_executor.logger") as mock_logger:
|
||||
await executor.handle_events(message, mock_updater)
|
||||
|
||||
# Assert
|
||||
mock_logger.warning.assert_not_called()
|
||||
mock_logger.debug.assert_called_once_with("Skipping unsupported content type for A2A: %s", "function_call")
|
||||
mock_updater.update_status.assert_not_called()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user