Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/agentex/lib/environment_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions src/agentex/lib/sdk/fastacp/fastacp.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -16,6 +22,7 @@
"base": AgenticBaseACP,
}

logger = make_logger(__name__)

class FastACP:
"""Factory for creating FastACP instances
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion src/agentex/lib/utils/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Loading