---
title: "Agent Logs"
description: "Log, query, and analyze agent execution history"
canonical: "https://docs.ainative.studio/docs/zerodb/agent-logs"
last-updated: "2026-10-13T21:42:35.442Z"
---

# Agent Logs

Source: https://docs.ainative.studio/docs/zerodb/agent-logs

> Log, query, and analyze agent execution history

## Agent Logs

ZeroDB agent logs capture every agent execution — inputs, outputs, tool calls, latency, and errors — giving you a full audit trail and performance analytics.

## Log an Agent Execution

```bash
curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/agent-logs \
  -H "x-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "code-reviewer-v2",
    "session_id": "session-abc123",
    "input": {"task": "Review PR #42"},
    "output": {"summary": "2 issues found", "severity": "low"},
    "tool_calls": [
      {"tool": "read_file", "args": {"path": "app/main.py"}, "duration_ms": 12}
    ],
    "duration_ms": 3200,
    "status": "success"
  }'
```

## List Agent Logs

```bash
curl "https://api.ainative.studio/api/v1/projects/{project_id}/database/agent-logs?agent_id=code-reviewer-v2&limit=50" \
  -H "x-api-key: $API_KEY"
```

## Get Stats

```bash
curl "https://api.ainative.studio/api/v1/projects/{project_id}/database/agent-logs/stats" \
  -H "x-api-key: $API_KEY"
```

Returns total executions, success rate, average latency, and per-agent breakdowns.

## Export Logs

```bash
curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/agent-logs/export \
  -H "x-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"start_date": "2026-05-01", "end_date": "2026-05-31", "format": "jsonl"}'
```

## Python SDK

```python
import requests

API_KEY = "your-api-key"
PROJECT_ID = "your-project-id"
BASE = f"https://api.ainative.studio/api/v1/projects/{PROJECT_ID}/database/agent-logs"
headers = {"x-api-key": API_KEY, "Content-Type": "application/json"}

## Log an execution
r = requests.post(BASE, headers=headers, json={
    "agent_id": "my-agent",
    "input": {"query": "summarize the report"},
    "output": {"result": "The report covers Q1 financials..."},
    "duration_ms": 1850,
    "status": "success"
})
log_id = r.json()["log_id"]

## Get performance stats
stats = requests.get(f"{BASE}/stats", headers=headers).json()
print(f"Success rate: {stats['success_rate']}%")
print(f"Avg latency: {stats['avg_duration_ms']}ms")
```

## Endpoints

| Method | Path | Description |
|--------|------|-------------|
| POST | `/database/agent-logs` | Log an agent execution |
| GET | `/database/agent-logs` | List logs (filterable by agent_id, status, date) |
| GET | `/database/agent-logs/{id}` | Get a specific log entry |
| GET | `/database/agent-logs/stats` | Aggregate performance statistics |
| DELETE | `/database/agent-logs/{id}` | Delete a log entry |
| POST | `/database/agent-logs/export` | Export logs to JSONL/CSV |
| GET | `/database/agents/active` | List currently active agents |
| GET | `/database/agents/traces` | Get execution traces |
