diff --git a/contributing/samples/a2a_auth/remote_a2a/bigquery_agent/agent.json b/contributing/samples/a2a_auth/remote_a2a/bigquery_agent/agent-card.json similarity index 100% rename from contributing/samples/a2a_auth/remote_a2a/bigquery_agent/agent.json rename to contributing/samples/a2a_auth/remote_a2a/bigquery_agent/agent-card.json diff --git a/contributing/samples/a2a_basic/remote_a2a/check_prime_agent/agent.json b/contributing/samples/a2a_basic/remote_a2a/check_prime_agent/agent-card.json similarity index 100% rename from contributing/samples/a2a_basic/remote_a2a/check_prime_agent/agent.json rename to contributing/samples/a2a_basic/remote_a2a/check_prime_agent/agent-card.json diff --git a/contributing/samples/a2a_human_in_loop/remote_a2a/human_in_loop/agent.json b/contributing/samples/a2a_human_in_loop/remote_a2a/human_in_loop/agent-card.json similarity index 100% rename from contributing/samples/a2a_human_in_loop/remote_a2a/human_in_loop/agent.json rename to contributing/samples/a2a_human_in_loop/remote_a2a/human_in_loop/agent-card.json diff --git a/src/google/adk/cli/fast_api.py b/src/google/adk/cli/fast_api.py index 7ff10c5414..b59601a076 100644 --- a/src/google/adk/cli/fast_api.py +++ b/src/google/adk/cli/fast_api.py @@ -350,15 +350,17 @@ async def _get_a2a_runner_async() -> Runner: return _get_a2a_runner_async for p in base_path.iterdir(): - # only folders with an agent.json file representing agent card are valid + # only folders with an agent-card.json or agent.json file representing agent card are valid # a2a agents - if ( - p.is_file() - or p.name.startswith((".", "__pycache__")) - or not (p / "agent.json").is_file() - ): + if p.is_file() or p.name.startswith(('.', '__pycache__')): continue + json_file = p / 'agent-card.json' + if not json_file.is_file(): + json_file = p / 'agent.json' + if not json_file.is_file(): + continue + app_name = p.name logger.info("Setting up A2A agent: %s", app_name) @@ -370,8 +372,7 @@ async def _get_a2a_runner_async() -> Runner: request_handler = DefaultRequestHandler( agent_executor=agent_executor, task_store=a2a_task_store ) - - with (p / "agent.json").open("r", encoding="utf-8") as f: + with json_file.open("r", encoding="utf-8") as f: data = json.load(f) agent_card = AgentCard(**data) diff --git a/tests/unittests/agents/test_remote_a2a_agent.py b/tests/unittests/agents/test_remote_a2a_agent.py index fc93e8dd5d..500017f5b2 100644 --- a/tests/unittests/agents/test_remote_a2a_agent.py +++ b/tests/unittests/agents/test_remote_a2a_agent.py @@ -126,27 +126,29 @@ def test_init_with_agent_card_object(self): def test_init_with_url_string(self): """Test initialization with URL string.""" agent = RemoteA2aAgent( - name="test_agent", agent_card="https://example.com/agent.json" + name="test_agent", agent_card="https://example.com/agent-card.json" ) assert agent.name == "test_agent" assert agent._agent_card is None - assert agent._agent_card_source == "https://example.com/agent.json" + assert agent._agent_card_source == "https://example.com/agent-card.json" def test_init_with_file_path(self): """Test initialization with file path.""" - agent = RemoteA2aAgent(name="test_agent", agent_card="/path/to/agent.json") + agent = RemoteA2aAgent( + name="test_agent", agent_card="/path/to/agent-card.json" + ) assert agent.name == "test_agent" assert agent._agent_card is None - assert agent._agent_card_source == "/path/to/agent.json" + assert agent._agent_card_source == "/path/to/agent-card.json" def test_init_with_shared_httpx_client(self): """Test initialization with shared httpx client.""" httpx_client = httpx.AsyncClient() agent = RemoteA2aAgent( name="test_agent", - agent_card="https://example.com/agent.json", + agent_card="https://example.com/agent-card.json", httpx_client=httpx_client, ) @@ -184,7 +186,7 @@ def test_init_with_custom_timeout(self): """Test initialization with custom timeout.""" agent = RemoteA2aAgent( name="test_agent", - agent_card="https://example.com/agent.json", + agent_card="https://example.com/agent-card.json", timeout=300.0, ) @@ -306,7 +308,7 @@ async def test_ensure_httpx_client_reregisters_transports_with_new_client( async def test_resolve_agent_card_from_url_success(self): """Test successful agent card resolution from URL.""" agent = RemoteA2aAgent( - name="test_agent", agent_card="https://example.com/agent.json" + name="test_agent", agent_card="https://example.com/agent-card.json" ) with patch.object(agent, "_ensure_httpx_client") as mock_ensure_client: @@ -321,7 +323,7 @@ async def test_resolve_agent_card_from_url_success(self): mock_resolver_class.return_value = mock_resolver result = await agent._resolve_agent_card_from_url( - "https://example.com/agent.json" + "https://example.com/agent-card.json" ) assert result == self.agent_card @@ -329,7 +331,7 @@ async def test_resolve_agent_card_from_url_success(self): httpx_client=mock_client, base_url="https://example.com" ) mock_resolver.get_agent_card.assert_called_once_with( - relative_card_path="/agent.json" + relative_card_path="/agent-card.json" ) @pytest.mark.asyncio @@ -343,7 +345,9 @@ async def test_resolve_agent_card_from_url_invalid_url(self): @pytest.mark.asyncio async def test_resolve_agent_card_from_file_success(self): """Test successful agent card resolution from file.""" - agent = RemoteA2aAgent(name="test_agent", agent_card="/path/to/agent.json") + agent = RemoteA2aAgent( + name="test_agent", agent_card="/path/to/agent-card.json" + ) with tempfile.NamedTemporaryFile( mode="w", suffix=".json", delete=False @@ -373,7 +377,9 @@ async def test_resolve_agent_card_from_file_not_found(self): @pytest.mark.asyncio async def test_resolve_agent_card_from_file_invalid_json(self): """Test agent card resolution from file with invalid JSON raises error.""" - agent = RemoteA2aAgent(name="test_agent", agent_card="/path/to/agent.json") + agent = RemoteA2aAgent( + name="test_agent", agent_card="/path/to/agent-card.json" + ) with tempfile.NamedTemporaryFile( mode="w", suffix=".json", delete=False @@ -510,7 +516,7 @@ async def test_ensure_resolved_with_direct_agent_card_with_factory(self): async def test_ensure_resolved_with_url_source(self): """Test _ensure_resolved with URL source.""" agent = RemoteA2aAgent( - name="test_agent", agent_card="https://example.com/agent.json" + name="test_agent", agent_card="https://example.com/agent-card.json" ) agent_card = create_test_agent_card() diff --git a/tests/unittests/cli/test_fast_api.py b/tests/unittests/cli/test_fast_api.py index f4a84179be..1b0953c725 100755 --- a/tests/unittests/cli/test_fast_api.py +++ b/tests/unittests/cli/test_fast_api.py @@ -420,7 +420,7 @@ def temp_agents_dir_with_a2a(): agent_dir = Path(temp_dir) / "test_a2a_agent" agent_dir.mkdir() - # Create agent.json file + # Create agent-card.json file agent_card = { "name": "test_a2a_agent", "description": "Test A2A agent", @@ -429,7 +429,7 @@ def temp_agents_dir_with_a2a(): "capabilities": ["text"], } - with open(agent_dir / "agent.json", "w") as f: + with open(agent_dir / "agent-card.json", "w") as f: json.dump(agent_card, f) # Create a simple agent.py file