Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions python/agent-framework/sample-agent/host_agent_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,20 @@ async def anonymous_claims(request, handler):
if s.connect_ex(("127.0.0.1", desired_port)) == 0:
port = desired_port + 1

# Detect production environment (Azure App Service sets WEBSITE_SITE_NAME)
is_production = os.getenv("WEBSITE_SITE_NAME") is not None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we even need this variable? We should judge if the app is in prod vs dev based on environment variable like "ENVIRONMENT" or "ASP_ENVIRONMENT" or port number, not based on website name. I think this website name itself is causing a lot of confusion and we cannot set it prod vs development in E2E. Let me know if you think otherwise

host = "0.0.0.0" if is_production else "localhost"

print("=" * 80)
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: {host}:{port}")
print(f"📚 Endpoint: http://localhost:{port}/api/messages")
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 [CRM-001] Inconsistent Log Output

The print statements for Endpoint and Health URLs still display http://localhost:{port} even when the server binds to 0.0.0.0 in production. This creates misleading log output for operators monitoring Azure deployments.

Suggestion: Update to use {host} for consistency, or clarify these are local reference URLs. Note: This matches the reference implementation (Google ADK) behavior, so it's acceptable but could be improved.

print(f"❤️ Health: http://localhost:{port}/api/health\n")
Comment on lines 318 to 319
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The endpoint URLs in the print statements still show "http://localhost:{port}" even when the server is bound to "0.0.0.0" in production. In production environments, these URLs won't accurately reflect how the service is accessed. Consider either using the actual host variable in the URLs or adding a clarifying comment that these are example local URLs for development reference only.

Copilot uses AI. Check for mistakes.

try:
run_app(app, host="localhost", port=port, handle_signals=True)
run_app(app, host=host, port=port, handle_signals=True)
except KeyboardInterrupt:
print("\n👋 Server stopped")

Expand Down
8 changes: 6 additions & 2 deletions python/claude/sample-agent/host_agent_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ async def anonymous_claims(request, handler):
)
port = desired_port + 1

# Detect production environment (Azure App Service sets WEBSITE_SITE_NAME)
is_production = os.getenv("WEBSITE_SITE_NAME") is not None
host = "0.0.0.0" if is_production else "localhost"

print("=" * 80)
print(f"🏢 Generic Agent Host - {self.agent_class.__name__}")
print("=" * 80)
Expand All @@ -442,13 +446,13 @@ async def anonymous_claims(request, handler):
print("🎯 Compatible with Agents Playground")
if port != desired_port:
print(f"⚠️ Requested port {desired_port} busy; using fallback {port}")
print(f"\n🚀 Starting server on localhost:{port}")
print(f"\n🚀 Starting server on {host}:{port}")
print(f"📚 Bot Framework endpoint: http://localhost:{port}/api/messages")
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 [CRM-002] Inconsistent Log Output

Same issue as CRM-001 - endpoint and health URLs still reference localhost even when binding to 0.0.0.0.

Suggestion: Update for consistency with actual host binding.

print(f"❤️ Health: http://localhost:{port}/api/health")
Comment on lines 450 to 451
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The endpoint URLs in the print statements still show "http://localhost:{port}" even when the server is bound to "0.0.0.0" in production. In production environments, these URLs won't accurately reflect how the service is accessed. Consider either using the actual host variable in the URLs or adding a clarifying comment that these are example local URLs for development reference only.

Suggested change
print(f"📚 Bot Framework endpoint: http://localhost:{port}/api/messages")
print(f"❤️ Health: http://localhost:{port}/api/health")
print(f"📚 Bot Framework endpoint: http://{host}:{port}/api/messages")
print(f"❤️ Health: http://{host}:{port}/api/health")

Copilot uses AI. Check for mistakes.
print("🎯 Ready for testing!\n")

try:
run_app(app, host="localhost", port=port)
run_app(app, host=host, port=port)
except KeyboardInterrupt:
print("\n👋 Server stopped")
except Exception as error:
Expand Down
8 changes: 6 additions & 2 deletions python/crewai/sample_agent/host_agent_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,20 +316,24 @@ async def anonymous_claims(request, handler):
)
port = desired_port + 1

# Detect production environment (Azure App Service sets WEBSITE_SITE_NAME)
is_production = os.getenv("WEBSITE_SITE_NAME") is not None
host = "0.0.0.0" if is_production else "localhost"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should decide if it's prod vs local based on ip address, not the otherway around, no?


print("=" * 80)
print(f"Generic Agent Host - {self.agent_class.__name__}")
print("=" * 80)
print(f"\nAuthentication: {'Enabled' if auth_configuration else 'Anonymous'}")
print("Using Microsoft Agents SDK patterns")
if port != desired_port:
print(f"Requested port {desired_port} busy; using fallback {port}")
print(f"\nStarting server on localhost:{port}")
print(f"\nStarting server on {host}:{port}")
print(f"Bot Framework endpoint: http://localhost:{port}/api/messages")
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 [CRM-003] Inconsistent Log Output

Same issue as CRM-001 - endpoint and health URLs still reference localhost even when binding to 0.0.0.0.

Suggestion: Update for consistency with actual host binding.

print(f"Health: http://localhost:{port}/api/health")
Comment on lines 331 to 332
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The endpoint URLs in the print statements still show "http://localhost:{port}" even when the server is bound to "0.0.0.0" in production. In production environments, these URLs won't accurately reflect how the service is accessed. Consider either using the actual host variable in the URLs or adding a clarifying comment that these are example local URLs for development reference only.

Suggested change
print(f"Bot Framework endpoint: http://localhost:{port}/api/messages")
print(f"Health: http://localhost:{port}/api/health")
print(f"Bot Framework endpoint: http://{host}:{port}/api/messages")
print(f"Health: http://{host}:{port}/api/health")
if is_production:
print(
"Note: In production, replace '0.0.0.0' with the externally accessible host name or IP."
)

Copilot uses AI. Check for mistakes.
print("Ready for testing!\n")

try:
run_app(app, host="localhost", port=port)
run_app(app, host=host, port=port)
except KeyboardInterrupt:
print("\nServer stopped")
except Exception as error:
Expand Down
8 changes: 6 additions & 2 deletions python/openai/sample-agent/host_agent_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ async def anonymous_claims(request, handler):
)
port = desired_port + 1

# Detect production environment (Azure App Service sets WEBSITE_SITE_NAME)
is_production = os.getenv("WEBSITE_SITE_NAME") is not None
host = "0.0.0.0" if is_production else "localhost"

print("=" * 80)
print(f"🏢 Generic Agent Host - {self.agent_class.__name__}")
print("=" * 80)
Expand All @@ -306,13 +310,13 @@ async def anonymous_claims(request, handler):
print("🎯 Compatible with Agents Playground")
if port != desired_port:
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 [CRM-004] Inconsistent Log Output

Same issue as CRM-001 - endpoint and health URLs still reference localhost even when binding to 0.0.0.0.

Suggestion: Update for consistency with actual host binding.

print(f"⚠️ Requested port {desired_port} busy; using fallback {port}")
print(f"\n🚀 Starting server on localhost:{port}")
print(f"\n🚀 Starting server on {host}:{port}")
print(f"📚 Bot Framework endpoint: http://localhost:{port}/api/messages")
print(f"❤️ Health: http://localhost:{port}/api/health")
Comment on lines 314 to 315
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The endpoint URLs in the print statements still show "http://localhost:{port}" even when the server is bound to "0.0.0.0" in production. In production environments, these URLs won't accurately reflect how the service is accessed. Consider either using the actual host variable in the URLs or adding a clarifying comment that these are example local URLs for development reference only.

Suggested change
print(f"📚 Bot Framework endpoint: http://localhost:{port}/api/messages")
print(f"❤️ Health: http://localhost:{port}/api/health")
print(f"📚 Bot Framework endpoint: http://{host}:{port}/api/messages")
print(f"❤️ Health: http://{host}:{port}/api/health")

Copilot uses AI. Check for mistakes.
print("🎯 Ready for testing!\n")

try:
run_app(app, host="localhost", port=port)
run_app(app, host=host, port=port)
except KeyboardInterrupt:
print("\n👋 Server stopped")
except Exception as error:
Expand Down
Loading