fix(a2a): adopt a directly supplied agent card's description
Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 961611760
This commit is contained in:
committed by
Copybara-Service
parent
2bdf4debd0
commit
4f58306477
@@ -248,6 +248,12 @@ class RemoteA2aAgent(BaseAgent):
|
||||
# Validate and store agent card reference
|
||||
if isinstance(agent_card, AgentCard):
|
||||
self._agent_card = agent_card
|
||||
# Update description if empty. A card supplied directly never goes
|
||||
# through the resolution path, so adopt it here instead; a parent agent
|
||||
# reads the description to build its transfer instruction, which happens
|
||||
# before this agent ever runs.
|
||||
if not self.description and agent_card.description:
|
||||
self.description = agent_card.description
|
||||
elif isinstance(agent_card, str):
|
||||
if not agent_card.strip():
|
||||
raise ValueError("agent_card string cannot be empty")
|
||||
|
||||
@@ -215,6 +215,26 @@ class TestRemoteA2aAgentInit:
|
||||
assert agent._httpx_client_needs_cleanup is True
|
||||
assert agent._is_resolved is False
|
||||
|
||||
def test_init_with_agent_card_object_adopts_card_description(self):
|
||||
"""Test description is autopopulated from a directly supplied card."""
|
||||
agent_card = create_test_agent_card(description="Converts currencies")
|
||||
|
||||
agent = RemoteA2aAgent(name="test_agent", agent_card=agent_card)
|
||||
|
||||
assert agent.description == "Converts currencies"
|
||||
|
||||
def test_init_with_agent_card_object_keeps_explicit_description(self):
|
||||
"""Test an explicit description wins over the card's."""
|
||||
agent_card = create_test_agent_card(description="Converts currencies")
|
||||
|
||||
agent = RemoteA2aAgent(
|
||||
name="test_agent",
|
||||
agent_card=agent_card,
|
||||
description="Test description",
|
||||
)
|
||||
|
||||
assert agent.description == "Test description"
|
||||
|
||||
def test_init_with_url_string(self):
|
||||
"""Test initialization with URL string."""
|
||||
agent = RemoteA2aAgent(
|
||||
|
||||
Reference in New Issue
Block a user