Skip to content

Commit 7e2d65f

Browse files
authored
Update healthz to return agent ID for registered agents (#194)
* Update base_acp_server.py * Update base_acp_server.py
1 parent 117849b commit 7e2d65f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def __init__(self):
7878
self.add_middleware(RequestIDMiddleware)
7979
self._handlers: dict[RPCMethod, Callable] = {}
8080

81+
# Agent info to return in healthz
82+
self.agent_id: str | None = None
83+
8184
@classmethod
8285
def create(cls):
8386
"""Create and initialize BaseACPServer instance"""
@@ -96,6 +99,7 @@ async def lifespan_context(app: FastAPI): # noqa: ARG001
9699
env_vars = EnvironmentVariables.refresh()
97100
if env_vars.AGENTEX_BASE_URL:
98101
await register_agent(env_vars)
102+
self.agent_id = env_vars.AGENT_ID
99103
else:
100104
logger.warning("AGENTEX_BASE_URL not set, skipping agent registration")
101105

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

106110
async def _healthz(self):
107111
"""Health check endpoint"""
108-
return {"status": "healthy"}
112+
result = {"status": "healthy"}
113+
if self.agent_id:
114+
result["agent_id"] = self.agent_id
115+
return result
109116

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

0 commit comments

Comments
 (0)