Skip to content

Commit ec5304c

Browse files
jer96jer
andauthored
chore(a2a): update host per AppSec recommendation (#619)
Co-authored-by: jer <[email protected]>
1 parent 297ec5c commit ec5304c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/strands/multiagent/a2a/server.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(
3131
agent: SAAgent,
3232
*,
3333
# AgentCard
34-
host: str = "0.0.0.0",
34+
host: str = "127.0.0.1",
3535
port: int = 9000,
3636
http_url: str | None = None,
3737
serve_at_root: bool = False,
@@ -42,13 +42,12 @@ def __init__(
4242
queue_manager: QueueManager | None = None,
4343
push_config_store: PushNotificationConfigStore | None = None,
4444
push_sender: PushNotificationSender | None = None,
45-
4645
):
4746
"""Initialize an A2A-compatible server from a Strands agent.
4847
4948
Args:
5049
agent: The Strands Agent to wrap with A2A compatibility.
51-
host: The hostname or IP address to bind the A2A server to. Defaults to "0.0.0.0".
50+
host: The hostname or IP address to bind the A2A server to. Defaults to "127.0.0.1".
5251
port: The port to bind the A2A server to. Defaults to 9000.
5352
http_url: The public HTTP URL where this agent will be accessible. If provided,
5453
this overrides the generated URL from host/port and enables automatic

tests/strands/multiagent/a2a/test_server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def test_a2a_agent_initialization(mock_strands_agent):
2222
assert a2a_agent.strands_agent == mock_strands_agent
2323
assert a2a_agent.name == "Test Agent"
2424
assert a2a_agent.description == "A test agent for unit testing"
25-
assert a2a_agent.host == "0.0.0.0"
25+
assert a2a_agent.host == "127.0.0.1"
2626
assert a2a_agent.port == 9000
27-
assert a2a_agent.http_url == "http://0.0.0.0:9000/"
27+
assert a2a_agent.http_url == "http://127.0.0.1:9000/"
2828
assert a2a_agent.version == "0.0.1"
2929
assert isinstance(a2a_agent.capabilities, AgentCapabilities)
3030
assert len(a2a_agent.agent_skills) == 1
@@ -85,7 +85,7 @@ def test_public_agent_card(mock_strands_agent):
8585
assert isinstance(card, AgentCard)
8686
assert card.name == "Test Agent"
8787
assert card.description == "A test agent for unit testing"
88-
assert card.url == "http://0.0.0.0:9000/"
88+
assert card.url == "http://127.0.0.1:9000/"
8989
assert card.version == "0.0.1"
9090
assert card.default_input_modes == ["text"]
9191
assert card.default_output_modes == ["text"]
@@ -448,7 +448,7 @@ def test_serve_with_starlette(mock_run, mock_strands_agent):
448448
mock_run.assert_called_once()
449449
args, kwargs = mock_run.call_args
450450
assert isinstance(args[0], Starlette)
451-
assert kwargs["host"] == "0.0.0.0"
451+
assert kwargs["host"] == "127.0.0.1"
452452
assert kwargs["port"] == 9000
453453

454454

@@ -462,7 +462,7 @@ def test_serve_with_fastapi(mock_run, mock_strands_agent):
462462
mock_run.assert_called_once()
463463
args, kwargs = mock_run.call_args
464464
assert isinstance(args[0], FastAPI)
465-
assert kwargs["host"] == "0.0.0.0"
465+
assert kwargs["host"] == "127.0.0.1"
466466
assert kwargs["port"] == 9000
467467

468468

0 commit comments

Comments
 (0)