Reading the Activity Log

The activity_log table structure (actor, action, entity_type, entity_id, metadata, created_at), filtering by company/agent/date, and the dashboard's real-time activity feed.

Reading Agent Activity Logs

What you'll learn

Navigate the Activity feed in the UI, query heartbeat_runs and cost_events directly, and build a picture of what your agents have been doing.

The Activity Feed in the UI

Open Company Dashboard → Activity. The feed shows:

Click any run to expand it and see which agent handled which issue.

Querying heartbeat_runs

-- Last 20 runs with duration
SELECT
  id,
  status,
  agents_invoked,
  issues_resolved,
  total_cost_usd,
  EXTRACT(epoch FROM (finished_at - started_at))::int AS seconds,
  started_at
FROM heartbeat_runs
WHERE company_id = 'your-company-id'
ORDER BY started_at DESC
LIMIT 20;

Status Values

Status Meaning
running Heartbeat currently in progress
completed All agents invoked, run finished cleanly
failed Unhandled error during execution
skipped Company paused or no open issues

Querying cost_events

Every adapter invocation that incurs a cost records a row:

SELECT
  ce.agent_id,
  a.name AS agent_name,
  ce.model,
  ce.input_tokens,
  ce.output_tokens,
  ce.cost_usd,
  ce.created_at
FROM cost_events ce
JOIN agents a ON a.id = ce.agent_id
WHERE ce.company_id = 'your-company-id'
ORDER BY ce.created_at DESC
LIMIT 20;

Monthly Spend by Agent

SELECT
  a.name,
  SUM(ce.cost_usd) AS month_total_usd,
  SUM(ce.input_tokens + ce.output_tokens) AS total_tokens
FROM cost_events ce
JOIN agents a ON a.id = ce.agent_id
WHERE ce.company_id = 'your-company-id'
  AND ce.created_at >= date_trunc('month', now())
GROUP BY a.name
ORDER BY month_total_usd DESC;

Reading Issue History

SELECT
  i.title,
  i.status,
  i.priority,
  a.name AS agent,
  i.created_at,
  i.resolved_at,
  LEFT(i.result, 200) AS result_preview
FROM issues i
LEFT JOIN agents a ON a.id = i.assigned_agent_id
WHERE i.company_id = 'your-company-id'
ORDER BY i.created_at DESC
LIMIT 20;

Exporting Activity as CSV

psql $DATABASE_URL -c "\COPY (
  SELECT hr.id, hr.status, hr.total_cost_usd, hr.started_at
  FROM heartbeat_runs hr
  WHERE hr.company_id = 'your-company-id'
) TO '/tmp/activity.csv' CSV HEADER"

Checkpoint ✓

Sign in for progress tracking & Q&A →