You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
fix: incompatible a2a sdk changes
a. camel case to snake case b. A2ACardResolver moved to different module PiperOrigin-RevId: 789807686
This commit is contained in:
committed by
Copybara-Service
parent
bead607364
commit
faadef167e
+1
-1
@@ -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
|
||||
]
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user