diff --git a/src/agentex/lib/environment_variables.py b/src/agentex/lib/environment_variables.py index 43f402e4..a369c867 100644 --- a/src/agentex/lib/environment_variables.py +++ b/src/agentex/lib/environment_variables.py @@ -34,6 +34,8 @@ class EnvVarKeys(str, Enum): WORKFLOW_TASK_QUEUE = "WORKFLOW_TASK_QUEUE" # Auth Configuration AUTH_PRINCIPAL_B64 = "AUTH_PRINCIPAL_B64" + # Build Information + BUILD_INFO_PATH = "BUILD_INFO_PATH" class Environment(str, Enum): @@ -63,6 +65,8 @@ class EnvironmentVariables(BaseModel): WORKFLOW_TASK_QUEUE: str | None = None WORKFLOW_NAME: str | None = None AUTH_PRINCIPAL_B64: str | None = None + # Build Information + BUILD_INFO_PATH: str | None = None @classmethod def refresh(cls) -> EnvironmentVariables: diff --git a/src/agentex/lib/sdk/fastacp/fastacp.py b/src/agentex/lib/sdk/fastacp/fastacp.py index 493e9b49..d66732ce 100644 --- a/src/agentex/lib/sdk/fastacp/fastacp.py +++ b/src/agentex/lib/sdk/fastacp/fastacp.py @@ -1,3 +1,8 @@ +import inspect +import json +import os +from pathlib import Path + from typing import Literal from agentex.lib.sdk.fastacp.base.base_acp_server import BaseACPServer from agentex.lib.sdk.fastacp.impl.agentic_base_acp import AgenticBaseACP @@ -8,6 +13,7 @@ BaseACPConfig, SyncACPConfig, ) +from agentex.lib.utils.logging import make_logger # Add new mappings between ACP types and configs here # Add new mappings between ACP types and implementations here @@ -16,6 +22,7 @@ "base": AgenticBaseACP, } +logger = make_logger(__name__) class FastACP: """Factory for creating FastACP instances @@ -51,6 +58,14 @@ def create_agentic_acp(config: AgenticACPConfig, **kwargs) -> BaseACPServer: else: return implementation_class.create(**kwargs) + @staticmethod + def locate_build_info_path() -> None: + """If a build-info.json file is present, set the BUILD_INFO_PATH environment variable""" + acp_root = Path(inspect.stack()[2].filename).resolve().parents[0] + build_info_path = acp_root / "build-info.json" + if build_info_path.exists(): + os.environ["BUILD_INFO_PATH"] = str(build_info_path) + @staticmethod def create( acp_type: Literal["sync", "agentic"], config: BaseACPConfig | None = None, **kwargs @@ -63,6 +78,8 @@ def create( **kwargs: Additional configuration parameters """ + FastACP.locate_build_info_path() + if acp_type == "sync": sync_config = config if isinstance(config, SyncACPConfig) else None return FastACP.create_sync_acp(sync_config, **kwargs) diff --git a/src/agentex/lib/utils/registration.py b/src/agentex/lib/utils/registration.py index 8b149d46..dfc28448 100644 --- a/src/agentex/lib/utils/registration.py +++ b/src/agentex/lib/utils/registration.py @@ -19,6 +19,16 @@ def get_auth_principal(env_vars: EnvironmentVariables): except Exception: return None +def get_build_info(env_vars: EnvironmentVariables): + logger.info(f"Getting build info from {env_vars.BUILD_INFO_PATH}") + if not env_vars.BUILD_INFO_PATH: + return None + try: + with open(env_vars.BUILD_INFO_PATH, "r") as f: + return json.load(f) + except Exception: + return None + async def register_agent(env_vars: EnvironmentVariables): """Register this agent with the Agentex server""" if not env_vars.AGENTEX_BASE_URL: @@ -38,7 +48,8 @@ async def register_agent(env_vars: EnvironmentVariables): "description": description, "acp_url": full_acp_url, "acp_type": env_vars.ACP_TYPE, - "principal_context": get_auth_principal(env_vars) + "principal_context": get_auth_principal(env_vars), + "registration_metadata": get_build_info(env_vars) } if env_vars.AGENT_ID: