## TL;DR

Every agent action needs an immutable trail: what it read, what it decided, what it wrote, and why. Log inputs (document IDs, field values), decisions (match results, routing), and outputs (bills created, payments scheduled) with timestamps and model versions. Make the trail queryable by invoice, vendor, and time so audits and debugging start from evidence.

## Steps

1. Log every read, decision, and write with timestamps.
   Expected: A complete trail.
2. Include model and prompt versions in the log.
   Expected: Reproducibility.
3. Make the trail immutable (append-only).
   Expected: Tamper evidence.
4. Index by invoice, vendor, and time.
   Expected: Queryable audits.
5. Retain per policy (often 7 years for finance).
   Expected: Compliance.

## When to use

- Compliance requirements
- Debugging agent errors
- Audit preparation

## When not to use

- Real-time alerting (different system)
- Performance monitoring
- Human action audits

## Compatibility

Framework-agnostic; store in immutable log storage.

## Variant phrasings

### audit trail invoice agent

### log agent AP actions

### agent decision auditability

## Root cause

Agents act at machine speed and scale; without a trail, errors are undebuggable and auditors cannot verify controls. The trail is the control evidence.

## Edge cases

- Logs contain PII; protect them accordingly
- High-volume logging needs cost management
- Reconstructing decisions needs the inputs, not just the outputs

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_3GPz-VVN_OSSiAyPb0u3tw
