Skip to content

Commit 40c0b88

Browse files
committed
init
1 parent 1074a2a commit 40c0b88

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/agentex/lib/environment_variables.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class EnvVarKeys(str, Enum):
3434
WORKFLOW_TASK_QUEUE = "WORKFLOW_TASK_QUEUE"
3535
# Auth Configuration
3636
AUTH_PRINCIPAL_B64 = "AUTH_PRINCIPAL_B64"
37+
# Build Information
38+
AGENT_COMMIT = "AGENT_COMMIT"
39+
# The URL of the agent's source code
40+
AGENT_CODE_URL = "AGENT_CODE_URL"
3741

3842

3943
class Environment(str, Enum):
@@ -63,6 +67,9 @@ class EnvironmentVariables(BaseModel):
6367
WORKFLOW_TASK_QUEUE: str | None = None
6468
WORKFLOW_NAME: str | None = None
6569
AUTH_PRINCIPAL_B64: str | None = None
70+
# Build Information
71+
AGENT_COMMIT: str | None = None
72+
AGENT_CODE_URL: str | None = None
6673

6774
@classmethod
6875
def refresh(cls) -> EnvironmentVariables:

src/agentex/lib/sdk/fastacp/fastacp.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import inspect
2+
import json
3+
import os
4+
from pathlib import Path
5+
16
from typing import Literal
27
from agentex.lib.sdk.fastacp.base.base_acp_server import BaseACPServer
38
from agentex.lib.sdk.fastacp.impl.agentic_base_acp import AgenticBaseACP
@@ -8,6 +13,7 @@
813
BaseACPConfig,
914
SyncACPConfig,
1015
)
16+
from agentex.lib.utils.logging import make_logger
1117

1218
# Add new mappings between ACP types and configs here
1319
# Add new mappings between ACP types and implementations here
@@ -16,6 +22,7 @@
1622
"base": AgenticBaseACP,
1723
}
1824

25+
logger = make_logger(__name__)
1926

2027
class FastACP:
2128
"""Factory for creating FastACP instances
@@ -51,6 +58,22 @@ def create_agentic_acp(config: AgenticACPConfig, **kwargs) -> BaseACPServer:
5158
else:
5259
return implementation_class.create(**kwargs)
5360

61+
@staticmethod
62+
def maybe_get_build_info() -> None:
63+
"""If a build-info.json file is present, load it and set the AGENT_COMMIT and AGENT_CODE_URL environment variables"""
64+
acp_root = Path(inspect.stack()[1].filename).resolve().parents[0]
65+
build_info_path = acp_root / "build-info.json"
66+
if build_info_path.exists():
67+
try:
68+
with open(build_info_path, "r") as f:
69+
build_info = json.load(f)
70+
if build_info.get("agent_commit"):
71+
os.environ["AGENT_COMMIT"] = build_info.get("agent_commit")
72+
if build_info.get("agent_repo") and build_info.get("agent_path"):
73+
os.environ["AGENT_CODE_URL"] = build_info.get("agent_repo") + "/" + build_info.get("agent_path")
74+
except Exception as e:
75+
logger.error(f"Error loading build info: {e}")
76+
5477
@staticmethod
5578
def create(
5679
acp_type: Literal["sync", "agentic"], config: BaseACPConfig | None = None, **kwargs
@@ -63,6 +86,8 @@ def create(
6386
**kwargs: Additional configuration parameters
6487
"""
6588

89+
FastACP.maybe_get_build_info()
90+
6691
if acp_type == "sync":
6792
sync_config = config if isinstance(config, SyncACPConfig) else None
6893
return FastACP.create_sync_acp(sync_config, **kwargs)

src/agentex/lib/utils/registration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ async def register_agent(env_vars: EnvironmentVariables):
4444
if env_vars.AGENT_ID:
4545
registration_data["agent_id"] = env_vars.AGENT_ID
4646

47+
if env_vars.AGENT_COMMIT:
48+
registration_data["commit_hash"] = env_vars.AGENT_COMMIT
49+
if env_vars.AGENT_CODE_URL:
50+
registration_data["code_url"] = env_vars.AGENT_CODE_URL
51+
4752
# Make the registration request
4853
registration_url = f"{env_vars.AGENTEX_BASE_URL.rstrip('/')}/agents/register"
4954
# Retry logic with configurable attempts and delay

0 commit comments

Comments
 (0)