Skip to content

Commit 19e24ea

Browse files
authored
Merge pull request #179 from esnible/custom-host-part2
Feature: Allow AGENT_ENDPOINT env var to customize URL on Agent card
2 parents 1db1ac2 + 8d15b8d commit 19e24ea

12 files changed

Lines changed: 29 additions & 12 deletions

File tree

a2a/a2a_contact_extractor/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import logging
7+
import os
78

89
import click
910
import httpx
@@ -95,7 +96,8 @@ def get_agent_card(host: str, port: int):
9596
return AgentCard(
9697
name="Marvin Contact Extractor",
9798
description="Extracts structured contact information from text using Marvin's extraction capabilities",
98-
url=f"http://{host}:{port}/",
99+
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
100+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
99101
version="1.0.0",
100102
defaultInputModes=ExtractorAgent.SUPPORTED_CONTENT_TYPES,
101103
defaultOutputModes=ExtractorAgent.SUPPORTED_CONTENT_TYPES,

a2a/a2a_currency_converter/app/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def main(host, port):
5252
name="Currency Agent",
5353
description="Helps with exchange rates for currencies",
5454
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
55-
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}/"),
55+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
5656
version="1.0.0",
5757
default_input_modes=CurrencyAgent.SUPPORTED_CONTENT_TYPES,
5858
default_output_modes=CurrencyAgent.SUPPORTED_CONTENT_TYPES,

a2a/cheerup_agent/src/cheerup_agent/agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
from textwrap import dedent
34

45
import uvicorn
@@ -48,7 +49,8 @@ def get_agent_card(host: str, port: int):
4849
- Be a positive, supportive friend to chat with
4950
""",
5051
),
51-
url=f"http://{host}:{port}/",
52+
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
53+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
5254
version="1.0.0",
5355
default_input_modes=["text"],
5456
default_output_modes=["text"],

a2a/file_organizer/src/file_organizer/agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def get_agent_card(host: str, port: int):
4848
- **MCP Tool Calling** – uses a MCP tool to organize files.
4949
""",
5050
),
51-
url=f"http://{host}:{port}/",
51+
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
52+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
5253
version="1.0.0",
5354
default_input_modes=["text"],
5455
default_output_modes=["text"],

a2a/generic_agent/src/generic_agent/agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
from textwrap import dedent
34

45
import uvicorn
@@ -49,7 +50,8 @@ def get_agent_card(host: str, port: int) -> AgentCard:
4950
This agent provides assistance for various tasks using different MCP tools.{mcp_section}
5051
""",
5152
),
52-
url=f"http://{host}:{port}/",
53+
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
54+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
5355
version=config.AGENT_VERSION,
5456
default_input_modes=["text"],
5557
default_output_modes=["text"],

a2a/git_issue_agent/a2a_agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import logging
6+
import os
67
import sys
78
import traceback
89

@@ -53,7 +54,8 @@ def get_agent_card(host: str, port: int):
5354
return AgentCard(
5455
name="Github issue agent",
5556
description="Answer queries about Github issues",
56-
url=f"http://{host}:{port}/",
57+
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
58+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
5759
version="1.0.0",
5860
default_input_modes=["text"],
5961
default_output_modes=["text"],

a2a/image_service/src/image_service/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_agent_card(host: str, port: int):
5151
"""
5252
),
5353
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
54-
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}/"),
54+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
5555
version="1.0.0",
5656
default_input_modes=["text"],
5757
default_output_modes=["text"],

a2a/recipe_agent/src/recipe_agent/agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
from textwrap import dedent
34

45
import uvicorn
@@ -46,7 +47,8 @@ def get_agent_card(host: str, port: int):
4647
- Get 2-3 recipe suggestions with instructions
4748
""",
4849
),
49-
url=f"http://{host}:{port}/",
50+
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
51+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
5052
version="1.0.0",
5153
default_input_modes=["text"],
5254
default_output_modes=["text"],

a2a/reservation_service/src/reservation_service/agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def get_agent_card(host: str, port: int):
6060
- **Real-time Availability** – Checks current restaurant availability
6161
""",
6262
),
63-
url=f"http://{host}:{port}/",
63+
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
64+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
6465
version="1.0.0",
6566
default_input_modes=["text"],
6667
default_output_modes=["text"],

a2a/slack_researcher/a2a_agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import logging
6+
import os
67
import sys
78
import traceback
89
from typing import Callable
@@ -54,7 +55,8 @@ def get_agent_card(host: str, port: int):
5455
return AgentCard(
5556
name="Web Research Agent",
5657
description="Answer queries by searching through a given slack server",
57-
url=f"http://{host}:{port}/",
58+
# Allow env var AGENT_ENDPOINT to override the URL in the agent card
59+
url=os.getenv("AGENT_ENDPOINT", f"http://{host}:{port}").rstrip("/") + "/",
5860
version="1.0.0",
5961
default_input_modes=["text"],
6062
default_output_modes=["text"],

0 commit comments

Comments
 (0)