Skip to content

Commit e50809c

Browse files
authored
Send build info with registration metadata (#103)
* init * send registration metadata
1 parent 58c7b04 commit e50809c

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/agentex/lib/environment_variables.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ 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+
BUILD_INFO_PATH = "BUILD_INFO_PATH"
3739

3840

3941
class Environment(str, Enum):
@@ -63,6 +65,8 @@ class EnvironmentVariables(BaseModel):
6365
WORKFLOW_TASK_QUEUE: str | None = None
6466
WORKFLOW_NAME: str | None = None
6567
AUTH_PRINCIPAL_B64: str | None = None
68+
# Build Information
69+
BUILD_INFO_PATH: str | None = None
6670

6771
@classmethod
6872
def refresh(cls) -> EnvironmentVariables:

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

Lines changed: 17 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,14 @@ def create_agentic_acp(config: AgenticACPConfig, **kwargs) -> BaseACPServer:
5158
else:
5259
return implementation_class.create(**kwargs)
5360

61+
@staticmethod
62+
def locate_build_info_path() -> None:
63+
"""If a build-info.json file is present, set the BUILD_INFO_PATH environment variable"""
64+
acp_root = Path(inspect.stack()[2].filename).resolve().parents[0]
65+
build_info_path = acp_root / "build-info.json"
66+
if build_info_path.exists():
67+
os.environ["BUILD_INFO_PATH"] = str(build_info_path)
68+
5469
@staticmethod
5570
def create(
5671
acp_type: Literal["sync", "agentic"], config: BaseACPConfig | None = None, **kwargs
@@ -63,6 +78,8 @@ def create(
6378
**kwargs: Additional configuration parameters
6479
"""
6580

81+
FastACP.locate_build_info_path()
82+
6683
if acp_type == "sync":
6784
sync_config = config if isinstance(config, SyncACPConfig) else None
6885
return FastACP.create_sync_acp(sync_config, **kwargs)

src/agentex/lib/utils/registration.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ def get_auth_principal(env_vars: EnvironmentVariables):
1919
except Exception:
2020
return None
2121

22+
def get_build_info(env_vars: EnvironmentVariables):
23+
logger.info(f"Getting build info from {env_vars.BUILD_INFO_PATH}")
24+
if not env_vars.BUILD_INFO_PATH:
25+
return None
26+
try:
27+
with open(env_vars.BUILD_INFO_PATH, "r") as f:
28+
return json.load(f)
29+
except Exception:
30+
return None
31+
2232
async def register_agent(env_vars: EnvironmentVariables):
2333
"""Register this agent with the Agentex server"""
2434
if not env_vars.AGENTEX_BASE_URL:
@@ -38,7 +48,8 @@ async def register_agent(env_vars: EnvironmentVariables):
3848
"description": description,
3949
"acp_url": full_acp_url,
4050
"acp_type": env_vars.ACP_TYPE,
41-
"principal_context": get_auth_principal(env_vars)
51+
"principal_context": get_auth_principal(env_vars),
52+
"registration_metadata": get_build_info(env_vars)
4253
}
4354

4455
if env_vars.AGENT_ID:

0 commit comments

Comments
 (0)