Skip to content
Merged
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
9 changes: 8 additions & 1 deletion src/agentex/lib/sdk/fastacp/base/base_acp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def __init__(self):
self.add_middleware(RequestIDMiddleware)
self._handlers: dict[RPCMethod, Callable] = {}

# Agent info to return in healthz
self.agent_id: str | None = None

@classmethod
def create(cls):
"""Create and initialize BaseACPServer instance"""
Expand All @@ -96,6 +99,7 @@ async def lifespan_context(app: FastAPI): # noqa: ARG001
env_vars = EnvironmentVariables.refresh()
if env_vars.AGENTEX_BASE_URL:
await register_agent(env_vars)
self.agent_id = env_vars.AGENT_ID
else:
logger.warning("AGENTEX_BASE_URL not set, skipping agent registration")

Expand All @@ -105,7 +109,10 @@ async def lifespan_context(app: FastAPI): # noqa: ARG001

async def _healthz(self):
"""Health check endpoint"""
return {"status": "healthy"}
result = {"status": "healthy"}
if self.agent_id:
result["agent_id"] = self.agent_id
return result

def _wrap_handler(self, fn: Callable[..., Awaitable[Any]]):
"""Wraps handler functions to provide JSON-RPC 2.0 response format"""
Expand Down