Overview
Every agent action is tracked for accountability, debugging, and compliance. The audit trail answers: Who did what, when, why, and what was the result?What Gets Tracked
Execution Records
Every agent run creates an execution record:| Field | Description |
|---|---|
execution_id | Unique identifier |
agent | Agent name (squad/agent) |
trigger | What initiated: manual, scheduled, event, smart |
started_at | Execution start time |
completed_at | Execution end time |
status | success, failed, timeout, cancelled |
tokens_in | Input tokens consumed |
tokens_out | Output tokens generated |
cost | USD cost |
model | Model used (opus, sonnet, haiku) |
Action Records
Within each execution, individual actions are logged:| Field | Description |
|---|---|
action_type | issue.create, pr.merge, file.write, etc. |
target | What was acted upon |
result | success, failed, approved, rejected |
approval_id | Link to approval record if required |
metadata | Additional context |
Attribution Requirements
PolicyORG-001 requires agent PRs include attribution trailers:
Required Trailers
| Trailer | Description |
|---|---|
Agent | Full agent path |
Squad | Squad that owns the agent |
Trigger | How the agent was triggered |
Execution | Execution ID for traceability |
Model | Which model was used |
Viewing Audit Data
CLI Commands
Example Output
Database Schema
Execution records are stored in PostgreSQL:Git History
All file changes by agents are tracked in git with:- Commit messages following Conventional Commits
- Attribution trailers as described above
- PR links to the creating execution
Querying Git History
Memory as Audit
Agent memory provides context for decisions:- What was decided
- Why (reasoning)
- When (timestamp)
- Who (agent or human)
Session Tracking
Claude Code sessions are tracked for debugging:- Start/end times
- Working directory
- Token usage
- Files accessed
Compliance Reports
Weekly Summary
- Goals achieved
- PRs merged
- Issues resolved
- Cost per outcome
Monthly Export
Incident Investigation
When something goes wrong, trace the issue:1. Find the Execution
2. Get Details
3. Check Logs
Retention Policy
| Data Type | Retention |
|---|---|
| Execution records | 90 days |
| Action logs | 90 days |
| Git history | Permanent |
| Memory | Permanent (summarized) |
| Session data | 30 days |
Privacy Considerations
The audit trail does not capture:- Actual file contents (only paths)
- API keys or secrets
- Personal user data
- Full conversation logs
- Anonymize user-identifying data
- Provide data export on request
- Support deletion requests
Best Practices
1. Review Weekly
2. Tag Important Executions
Use metadata for significant runs:3. Document Exceptions
When overriding normal processes, document in:- PR description
- Commit message
- Memory update