diff --git a/pyproject.toml b/pyproject.toml index e64149db..2d1414af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ dev = [ a2a = [ # go/keep-sorted start - "a2a-sdk>=0.2.16,<0.3.0;python_version>='3.10'", + "a2a-sdk>=0.3.0,<0.4.0;python_version>='3.10'", # go/keep-sorted end ] diff --git a/src/google/adk/a2a/logs/log_utils.py b/src/google/adk/a2a/logs/log_utils.py index 901cd631..78ca4371 100644 --- a/src/google/adk/a2a/logs/log_utils.py +++ b/src/google/adk/a2a/logs/log_utils.py @@ -136,11 +136,11 @@ def build_a2a_request_log(req: SendMessageRequest) -> str: config_log = "None" if req.params.configuration: config_data = { - "acceptedOutputModes": req.params.configuration.acceptedOutputModes, + "accepted_output_modes": req.params.configuration.accepted_output_modes, "blocking": req.params.configuration.blocking, - "historyLength": req.params.configuration.historyLength, - "pushNotificationConfig": bool( - req.params.configuration.pushNotificationConfig + "history_length": req.params.configuration.history_length, + "push_notification_config": bool( + req.params.configuration.push_notification_config ), } config_log = json.dumps(config_data, indent=2) diff --git a/src/google/adk/agents/remote_a2a_agent.py b/src/google/adk/agents/remote_a2a_agent.py index 02d06a1b..cc9fb75a 100644 --- a/src/google/adk/agents/remote_a2a_agent.py +++ b/src/google/adk/agents/remote_a2a_agent.py @@ -26,7 +26,7 @@ import uuid try: from a2a.client import A2AClient - from a2a.client.client import A2ACardResolver + from a2a.client.card_resolver import A2ACardResolver from a2a.types import AgentCard from a2a.types import Message as A2AMessage from a2a.types import MessageSendParams as A2AMessageSendParams diff --git a/tests/unittests/a2a/logs/test_log_utils.py b/tests/unittests/a2a/logs/test_log_utils.py index 2ca432cc..9673dab4 100644 --- a/tests/unittests/a2a/logs/test_log_utils.py +++ b/tests/unittests/a2a/logs/test_log_utils.py @@ -184,7 +184,7 @@ class TestBuildA2ARequestLog: assert "Part 0:" in result assert "Part 1:" in result assert '"blocking": true' in result - assert '"historyLength": 10' in result + assert '"history_length": 10' in result assert '"key1": "value1"' in result def test_request_without_parts(self): diff --git a/tests/unittests/agents/test_remote_a2a_agent.py b/tests/unittests/agents/test_remote_a2a_agent.py index fa1a20fe..7ef32de6 100644 --- a/tests/unittests/agents/test_remote_a2a_agent.py +++ b/tests/unittests/agents/test_remote_a2a_agent.py @@ -20,7 +20,10 @@ from unittest.mock import AsyncMock from unittest.mock import Mock from unittest.mock import patch -# Try to import a2a library - will fail on Python < 3.10 +import pytest + +# Check if A2A dependencies are available +A2A_AVAILABLE = True try: from a2a.types import AgentCapabilities from a2a.types import AgentCard @@ -32,32 +35,34 @@ try: from google.adk.agents.remote_a2a_agent import A2A_METADATA_PREFIX from google.adk.agents.remote_a2a_agent import AgentCardResolutionError from google.adk.agents.remote_a2a_agent import RemoteA2aAgent - - A2A_AVAILABLE = True except ImportError: A2A_AVAILABLE = False + # Create dummy classes to prevent NameError during test collection - AgentCapabilities = type("AgentCapabilities", (), {}) - AgentCard = type("AgentCard", (), {}) - AgentSkill = type("AgentSkill", (), {}) - A2AMessage = type("A2AMessage", (), {}) - SendMessageSuccessResponse = type("SendMessageSuccessResponse", (), {}) - A2ATask = type("A2ATask", (), {}) + class DummyTypes: + pass + + AgentCapabilities = DummyTypes() + AgentCard = DummyTypes() + AgentSkill = DummyTypes() + A2AMessage = DummyTypes() + SendMessageSuccessResponse = DummyTypes() + A2ATask = DummyTypes() + InvocationContext = DummyTypes() + RemoteA2aAgent = DummyTypes() + AgentCardResolutionError = Exception + A2A_METADATA_PREFIX = "" + +# Skip all tests in this module if Python < 3.10 or A2A dependencies are not available +pytestmark = pytest.mark.skipif( + sys.version_info < (3, 10) or not A2A_AVAILABLE, + reason="A2A requires Python 3.10+ and A2A dependencies must be available", +) from google.adk.events.event import Event from google.adk.sessions.session import Session import httpx -import pytest - -# Skip all tests in this module if Python < 3.10 or a2a library is not available -pytestmark = pytest.mark.skipif( - sys.version_info < (3, 10) or not A2A_AVAILABLE, - reason=( - "a2a library requires Python 3.10+ and is not available, skipping" - " RemoteA2aAgent tests" - ), -) # Helper function to create a proper AgentCard for testing