Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/agent-framework/sample-agent/host_agent_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ async def anonymous_claims(request, handler):
print(f"🏢 {self.agent_class.__name__}")
print("=" * 80)
print(f"🔒 Auth: {'Enabled' if auth_configuration else 'Anonymous'}")
print(f"🚀 Server: localhost:{port}")
print(f"🚀 Server: Listening on 0.0.0.0:{port} (all interfaces)")
print(f"📚 Endpoint: http://localhost:{port}/api/messages")
print(f"❤️ Health: http://localhost:{port}/api/health\n")
Comment on lines 336 to 337
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log messages on lines 336-337 still reference "http://localhost:{port}" for the endpoint and health URLs, which is inconsistent with the server now listening on 0.0.0.0. When the server binds to 0.0.0.0, clients should connect using the actual hostname or IP address, not localhost. Consider updating these messages to reflect the actual accessible URLs, or if following the conditional binding pattern suggested above, display the appropriate URL based on whether the server is running in production or local development mode.

Suggested change
print(f"📚 Endpoint: http://localhost:{port}/api/messages")
print(f"❤️ Health: http://localhost:{port}/api/health\n")
print(f"📚 Endpoint: http://<host>:{port}/api/messages")
print(f"❤️ Health: http://<host>:{port}/api/health\n")

Copilot uses AI. Check for mistakes.

try:
run_app(app, host="localhost", port=port, handle_signals=True)
run_app(app, host="0.0.0.0", port=port, handle_signals=True)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binding to 0.0.0.0 unconditionally exposes the server to all network interfaces, which may pose a security risk for local development. Other samples in this repository (python/openai/sample-agent/host_agent_server.py:303-304 and python/google-adk/sample-agent/main.py:61) use conditional binding based on environment detection (e.g., checking for WEBSITE_HOSTNAME or WEBSITE_SITE_NAME environment variables to determine if running in Azure). Consider adopting the same pattern to bind to 0.0.0.0 only when deployed to production environments, and use localhost for local development.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change deviates from the established pattern used in other Python samples in the codebase. Specifically, python/openai/sample-agent/host_agent_server.py:303-304 uses conditional binding with "bind_host = '0.0.0.0' if host else 'localhost'" where host is determined by the WEBSITE_HOSTNAME environment variable, and python/google-adk/sample-agent/main.py:61 uses "host = '0.0.0.0' if isProduction else 'localhost'" where isProduction checks for WEBSITE_SITE_NAME. Consider aligning with this pattern for consistency across the repository.

Copilot uses AI. Check for mistakes.
except KeyboardInterrupt:
print("\n👋 Server stopped")

Expand Down
Loading