Repository navigation
Description
You can query a session's detections over HTTP, but there is no CLI shortcut. A one-liner would be handy for incident triage.
Task
Add a detections subcommand that calls GET /api/v1/audit/detections/{correlation_id} and prints the results as a readable table (rule, severity, summary).
File: apps/orchestrator/agentmetry/cli/__init__.py
Model it on cmd_stats, not cmd_replay. cmd_stats is the one that reads over HTTP and handles the server-not-running case. cmd_replay reads the outbox directly and is the wrong pattern here.
The endpoint
audit_detections in apps/orchestrator/agentmetry/api/routes/audit.py returns:
{
"detections": [ ... ],
"correlation_id": "...",
"count": 0,
"untriaged": 0,
"enabled": true
}Each detection carries rule_id, severity, title, summary, event_ids, tactic_ids, technique_ids, and disposition (null when untriaged). When audit export is disabled the endpoint returns enabled: false with an empty list, which is a different message from "no detections".
untriaged is worth surfacing. An untriaged critical is what turns a dogfood week red, so it is the number an operator acts on.
Acceptance criteria
-
agentmetry detections <id>prints ranked detections, or "no detections" cleanly - Distinguishes "no detections" from "audit export disabled"
- Handles server-not-running with a clear message, the way
cmd_statsdoes - Severity ordering is critical, high, medium, low.
SEVERITY_RANKincore/audit/detection/models.pyalready defines it, so use that rather than a new list - A test in
apps/orchestrator/tests/, mocking the HTTP call the way the existing CLI tests do
Notes
Related to but separate from #100, which adds a disposition command for closing a detection. This issue is read-only. #100 is unassigned if you want both later, but they are independently useful and this one stands alone.
One known wrinkle, not yours to fix: the endpoint is behind require_api_key, which currently returns early when AGENTMETRY_API_KEY is unset. So it works locally with no key. cmd_stats does not send a key either, so match it and do not solve auth here.
Activity
hossainzarif23 commentedon Aug 30, 2026
I would like to work on this one.
blitzcrieg1 commentedon Aug 30, 2026
Assigned, it is yours.
I checked the issue against the code before handing it over and found two things in it that would have cost you your first hour, so I have corrected the body.
The file path was wrong. It said
apps/orchestrator/cli/__init__.py. The CLI actually lives atapps/orchestrator/agentmetry/cli/__init__.py.The suggested model was wrong. It said to mirror how
replayreads from the API.cmd_replaydoes not read from the API at all; it reads the outbox directly.cmd_statsis the one to copy, including its server-not-running handling.I also added the endpoint's actual response shape, since you would otherwise have had to go read the route to find out that it returns
count,untriagedand anenabledflag alongside the detections.Two things worth knowing that are not obvious from the issue:
untriagedis the number an operator actually acts on. An untriaged critical is what turns a dogfood week red, so surfacing it is worth more than a raw count.Severity ordering already exists as
SEVERITY_RANKincore/audit/detection/models.py. Use it rather than writing a new list, because a second ordering is a second thing to drift.No deadline from me. Ask here if anything is unclear, and if you hit something that turns out to be wrong in the codebase rather than in your change, say so. That has been the more common outcome this week.
hossainzarif23 commentedon Aug 31, 2026
Can you please check the PR? The jobs aren't running for some reason even after the CLA signature.
feat(cli): add detections command for triage