What went wrong
The agent detail endpoint /api/agents/{agent_id} returns event_count = 0
and worst_mad = "" even when the same agent is shown with non-zero event
activity and a populated worst MAD value in /api/agents.
This makes the backend response inconsistent across two endpoints describing
the same agent.
The current agent detail page does not visibly render these two top-level
fields yet, so this is primarily an API/data-consistency issue at the moment.
However, it is already frontend-facing through the detail endpoint response
and could surface directly in the UI if those fields are used there later.
Reproduction steps
- Start Adrian locally and sign in to the dashboard.
- Ensure there is an agent with at least one event and one verdict.
- Query
/api/agents and note the event_count and worst_mad values for
that agent.
- Query
/api/agents/{agent_id} for the same agent.
- Observe that the detail response returns
event_count = 0 and worst_mad = "" even though the list response returned populated values.
Expected behaviour
The agent detail endpoint should return the same top-level agent stats as the
agents list for the same agent, including:
Actual behaviour
For the same agent:
/api/agents returns populated event_count and worst_mad
/api/agents/{agent_id} returns event_count = 0 and worst_mad = ""
Environment
- Adrian version / commit:
stub-local-dev-mode locally for reproduction
- OS: macOS arm64
- Docker version: Docker version 29.4.3, build 055a478
- GPU model (if relevant): not relevant
Logs
Click to expand
GET /api/agents
{
"data": {
"agents": [
{
"id": "agent-row-test-1",
"agent_id": "agent-test",
"agent_profile_id": "",
"agent_profile_name": "",
"first_seen": "2026-05-16T10:00:00.000Z",
"last_seen": "0001-01-01T00:00:00.000Z",
"event_count": 1,
"worst_mad": "M3.a"
}
],
"total": 1,
"page": 1,
"per_page": 20
}
}
GET /api/agents/agent-test
{
"data": {
"id": "agent-row-test-1",
"agent_id": "agent-test",
"agent_profile_id": "",
"agent_profile_name": "",
"first_seen": "2026-05-16T10:00:00.000Z",
"last_seen": "0001-01-01T00:00:00.000Z",
"event_count": 0,
"worst_mad": "",
"sessions": [
{
"session_id": "sess-test-1",
"started_at": "2026-05-16T10:05:00.000Z",
"ended_at": "2026-05-16T10:05:00.000Z",
"event_count": 1
}
]
}
}
Relevant code paths
backend/internal/store/agents.go
The list query used by ListAgents(...) computes both:
The single-agent query used by GetAgent(...) does not select either of those
fields.
backend/internal/api/handlers_agents.go
The detail handler still serializes the result through agentRowToEntry(...),
which includes event_count and worst_mad in the response shape. Because
GetAgent(...) never populated them, they are returned with zero values.
frontend/app/(dashboard)/agents/page.tsx
The agents list uses the populated values from /api/agents.
frontend/app/(dashboard)/agents/[agent_id]/page.tsx
The detail page currently consumes /api/agents/{agent_id}. It does not
currently render event_count or worst_mad, which is why this is presently an
API/data-consistency issue rather than a direct visible rendering bug.
Likely fix
Update GetAgent(...) to compute and return the same top-level aggregate fields
as ListAgents(...), so the detail endpoint stays consistent with the list
endpoint for the same agent.
Offer to contribute
I’d be happy to open a PR for this if that approach sounds right.
What went wrong
The agent detail endpoint
/api/agents/{agent_id}returnsevent_count = 0and
worst_mad = ""even when the same agent is shown with non-zero eventactivity and a populated worst MAD value in
/api/agents.This makes the backend response inconsistent across two endpoints describing
the same agent.
The current agent detail page does not visibly render these two top-level
fields yet, so this is primarily an API/data-consistency issue at the moment.
However, it is already frontend-facing through the detail endpoint response
and could surface directly in the UI if those fields are used there later.
Reproduction steps
/api/agentsand note theevent_countandworst_madvalues forthat agent.
/api/agents/{agent_id}for the same agent.event_count = 0andworst_mad = ""even though the list response returned populated values.Expected behaviour
The agent detail endpoint should return the same top-level agent stats as the
agents list for the same agent, including:
event_countworst_madActual behaviour
For the same agent:
/api/agentsreturns populatedevent_countandworst_mad/api/agents/{agent_id}returnsevent_count = 0andworst_mad = ""Environment
stub-local-dev-modelocally for reproductionLogs
Click to expand
Relevant code paths
backend/internal/store/agents.goThe list query used by ListAgents(...) computes both:
The single-agent query used by GetAgent(...) does not select either of those
fields.
backend/internal/api/handlers_agents.goThe detail handler still serializes the result through agentRowToEntry(...),
which includes event_count and worst_mad in the response shape. Because
GetAgent(...) never populated them, they are returned with zero values.
frontend/app/(dashboard)/agents/page.tsxThe agents list uses the populated values from /api/agents.
frontend/app/(dashboard)/agents/[agent_id]/page.tsxThe detail page currently consumes /api/agents/{agent_id}. It does not
currently render event_count or worst_mad, which is why this is presently an
API/data-consistency issue rather than a direct visible rendering bug.
Likely fix
Update GetAgent(...) to compute and return the same top-level aggregate fields
as ListAgents(...), so the detail endpoint stays consistent with the list
endpoint for the same agent.
Offer to contribute
I’d be happy to open a PR for this if that approach sounds right.