diff --git a/src/strands/multiagent/a2a/server.py b/src/strands/multiagent/a2a/server.py index 35ea5b2e3..bbfbc824d 100644 --- a/src/strands/multiagent/a2a/server.py +++ b/src/strands/multiagent/a2a/server.py @@ -31,7 +31,7 @@ def __init__( agent: SAAgent, *, # AgentCard - host: str = "0.0.0.0", + host: str = "127.0.0.1", port: int = 9000, http_url: str | None = None, serve_at_root: bool = False, @@ -42,13 +42,12 @@ def __init__( queue_manager: QueueManager | None = None, push_config_store: PushNotificationConfigStore | None = None, push_sender: PushNotificationSender | None = None, - ): """Initialize an A2A-compatible server from a Strands agent. Args: agent: The Strands Agent to wrap with A2A compatibility. - host: The hostname or IP address to bind the A2A server to. Defaults to "0.0.0.0". + host: The hostname or IP address to bind the A2A server to. Defaults to "127.0.0.1". port: The port to bind the A2A server to. Defaults to 9000. http_url: The public HTTP URL where this agent will be accessible. If provided, this overrides the generated URL from host/port and enables automatic diff --git a/tests/strands/multiagent/a2a/test_server.py b/tests/strands/multiagent/a2a/test_server.py index a3b47581c..00dd164b5 100644 --- a/tests/strands/multiagent/a2a/test_server.py +++ b/tests/strands/multiagent/a2a/test_server.py @@ -22,9 +22,9 @@ def test_a2a_agent_initialization(mock_strands_agent): assert a2a_agent.strands_agent == mock_strands_agent assert a2a_agent.name == "Test Agent" assert a2a_agent.description == "A test agent for unit testing" - assert a2a_agent.host == "0.0.0.0" + assert a2a_agent.host == "127.0.0.1" assert a2a_agent.port == 9000 - assert a2a_agent.http_url == "http://0.0.0.0:9000/" + assert a2a_agent.http_url == "http://127.0.0.1:9000/" assert a2a_agent.version == "0.0.1" assert isinstance(a2a_agent.capabilities, AgentCapabilities) assert len(a2a_agent.agent_skills) == 1 @@ -85,7 +85,7 @@ def test_public_agent_card(mock_strands_agent): assert isinstance(card, AgentCard) assert card.name == "Test Agent" assert card.description == "A test agent for unit testing" - assert card.url == "http://0.0.0.0:9000/" + assert card.url == "http://127.0.0.1:9000/" assert card.version == "0.0.1" assert card.default_input_modes == ["text"] assert card.default_output_modes == ["text"] @@ -448,7 +448,7 @@ def test_serve_with_starlette(mock_run, mock_strands_agent): mock_run.assert_called_once() args, kwargs = mock_run.call_args assert isinstance(args[0], Starlette) - assert kwargs["host"] == "0.0.0.0" + assert kwargs["host"] == "127.0.0.1" assert kwargs["port"] == 9000 @@ -462,7 +462,7 @@ def test_serve_with_fastapi(mock_run, mock_strands_agent): mock_run.assert_called_once() args, kwargs = mock_run.call_args assert isinstance(args[0], FastAPI) - assert kwargs["host"] == "0.0.0.0" + assert kwargs["host"] == "127.0.0.1" assert kwargs["port"] == 9000