feat: update agent heartbeat endpoint to require no request payload
This commit is contained in:
@@ -27,7 +27,6 @@ from app.models.tasks import Task
|
|||||||
from app.schemas.agents import (
|
from app.schemas.agents import (
|
||||||
AgentCreate,
|
AgentCreate,
|
||||||
AgentHeartbeat,
|
AgentHeartbeat,
|
||||||
AgentHeartbeatCreate,
|
|
||||||
AgentNudge,
|
AgentNudge,
|
||||||
AgentRead,
|
AgentRead,
|
||||||
)
|
)
|
||||||
@@ -1323,8 +1322,8 @@ async def nudge_agent(
|
|||||||
tags=AGENT_ALL_ROLE_TAGS,
|
tags=AGENT_ALL_ROLE_TAGS,
|
||||||
summary="Upsert agent heartbeat",
|
summary="Upsert agent heartbeat",
|
||||||
description=(
|
description=(
|
||||||
"Record liveness for the authenticated agent's current status.\n\n"
|
"Record liveness for the authenticated agent.\n\n"
|
||||||
"Use this when the agent heartbeat loop reports status changes."
|
"Use this when the agent heartbeat loop checks in."
|
||||||
),
|
),
|
||||||
openapi_extra={
|
openapi_extra={
|
||||||
"x-llm-intent": "agent_heartbeat",
|
"x-llm-intent": "agent_heartbeat",
|
||||||
@@ -1339,7 +1338,7 @@ async def nudge_agent(
|
|||||||
"x-required-actor": "any_agent",
|
"x-required-actor": "any_agent",
|
||||||
"x-prerequisites": [
|
"x-prerequisites": [
|
||||||
"Authenticated agent token",
|
"Authenticated agent token",
|
||||||
"Valid AgentHeartbeatCreate payload",
|
"No request payload required",
|
||||||
],
|
],
|
||||||
"x-side-effects": [
|
"x-side-effects": [
|
||||||
"Updates agent heartbeat and status metadata",
|
"Updates agent heartbeat and status metadata",
|
||||||
@@ -1372,7 +1371,6 @@ async def nudge_agent(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
async def agent_heartbeat(
|
async def agent_heartbeat(
|
||||||
payload: AgentHeartbeatCreate,
|
|
||||||
session: AsyncSession = SESSION_DEP,
|
session: AsyncSession = SESSION_DEP,
|
||||||
agent_ctx: AgentAuthContext = AGENT_CTX_DEP,
|
agent_ctx: AgentAuthContext = AGENT_CTX_DEP,
|
||||||
) -> AgentRead:
|
) -> AgentRead:
|
||||||
@@ -1383,7 +1381,7 @@ async def agent_heartbeat(
|
|||||||
# Heartbeats must apply to the authenticated agent; agent names are not unique.
|
# Heartbeats must apply to the authenticated agent; agent names are not unique.
|
||||||
return await agents_api.heartbeat_agent(
|
return await agents_api.heartbeat_agent(
|
||||||
agent_id=str(agent_ctx.agent.id),
|
agent_id=str(agent_ctx.agent.id),
|
||||||
payload=AgentHeartbeat(status=payload.status),
|
payload=AgentHeartbeat(),
|
||||||
session=session,
|
session=session,
|
||||||
actor=_actor(agent_ctx),
|
actor=_actor(agent_ctx),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ def test_openapi_agent_role_endpoint_descriptions_exist() -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_openapi_agent_heartbeat_requires_no_request_body() -> None:
|
||||||
|
"""Authenticated heartbeats should infer identity from token without payload."""
|
||||||
|
schema = app.openapi()
|
||||||
|
op = schema["paths"]["/api/v1/agent/heartbeat"]["post"]
|
||||||
|
assert "requestBody" not in op
|
||||||
|
|
||||||
|
|
||||||
def test_openapi_agent_tool_endpoints_include_llm_hints() -> None:
|
def test_openapi_agent_tool_endpoints_include_llm_hints() -> None:
|
||||||
"""Tool-facing agent endpoints should expose structured usage hints and operation IDs."""
|
"""Tool-facing agent endpoints should expose structured usage hints and operation IDs."""
|
||||||
schema = app.openapi()
|
schema = app.openapi()
|
||||||
|
|||||||
Reference in New Issue
Block a user