Skip to content

[FEATURE] Configurable HTTP URL for A2A Server #383

@mukitmomin

Description

@mukitmomin

Problem Statement

When deploying A2A agents behind load balancers or in containerized environments, the automatically generated http_url (based on the host and port parameters) doesn't reflect the actual public-facing URL that clients should use to access the agent. This is particularly problematic for the agent card discovery mechanism, which relies on the correct http_url value.

Currently, the http_url is automatically set based on the host and port parameters:
python
self.http_url = f"http://{self.host}:{self.port}/"

When running in a container with host set to 0.0.0.0 and port to 8080, this results in http://0.0.0.0:8080/, which is not accessible from outside the container. In load-balanced environments, the actual URL might be something like http://my-alb-1234.us-west-2.elb.amazonaws.com/agent1.

Users must manually override the http_url property after creating the A2A server:

a2a_agent = A2AServer(agent=agent, port=port, host=host)
a2a_agent.http_url = "http://my-alb-1234.us-west-2.elb.amazonaws.com/agent1"

Proposed Solution

Add a configurable http_url parameter to the A2AServer constructor:

def init(
   self, 
   agent: SAAgent, 
   port: int = 8080, 
   host: str = "0.0.0.0", 
   http_url: Optional[str] = None,
 kwargs
):
   self.host = host
   self.port = port
   
   # Use provided http_url if available, otherwise generate from host and port
   if http_url:
       self.http_url = http_url
   else:
       self.http_url = f"http://{self.host}:{self.port}/"
   
   # Rest of initialization code

Use Case

a2a_agent = A2AServer(
   agent=agent,
   port=8080,
   host="0.0.0.0",
   http_url="http://my-alb-1234.us-west-2.elb.amazonaws.com/agent1"
)

This would correctly set the agent card URL to http://my-alb-1234.us-west-2.elb.amazonaws.com/agent1/.well-known/agent.json without requiring manual override of the http_url property.

Alternatives Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions