The audit log as JSONL
GovernanceAuditLogger writes the audit trail as JSONL: one JSON object per line in a text file, the shape a log collector expects.
Last updated: 14 Oct, 2026 · Agent Governance Toolkit 4.1.0
The flight recorder is a database. Many systems instead ship plain log files to a collector. The JSONL logger writes that format: each decision is one line, so tools like a SIEM can read it without a database driver.
Building the logger
Syntax: the logger starts empty and you attach a backend. The JSONL backend takes the path of the file to append each line to.
import tempfile, os
from agent_os.audit_logger import GovernanceAuditLogger, JsonlFileBackend, AuditEntry
path = os.path.join(tempfile.mkdtemp(), "audit.jsonl")
logger = GovernanceAuditLogger()
logger.add_backend(JsonlFileBackend(path))Writing a decision
A decision is an AuditEntry. The fields name the agent, the action, the verdict and the reason. log records it and flush writes it out.
entry = AuditEntry(event_type="tool_call", agent_id="shop",
action="refund", decision="deny", reason="over limit")
logger.log(entry)
logger.flush()Reading the line back
The file now holds one line of JSON. Reading it as text shows the exact shape; parsing it shows the fields a collector would index. The timestamp is set when the entry is made, so it differs every run.
import json
# the file holds one JSON object per line
line = open(path).read().strip()
record = json.loads(line)
# read the fields a collector would index (timestamp is left out, it changes each run)
for field in ["event_type", "agent_id", "action", "decision", "reason"]:
print(field, "=", record[field])event_type = tool_call agent_id = shop action = refund decision = deny reason = over limit
JSONL vs the flight recorder
| JSONL logger | Flight recorder | |
|---|---|---|
| File | A text file, one line each | A SQLite database |
| Read by | Any log collector | A SQLite query |
| Tamper-evident | No, it is plain text | Yes, a hash chain |
| Use it for | Shipping to a SIEM | A durable local record |
Where you use JSONL
- A log pipeline that tails files and forwards lines to a collector.
- A container that writes decisions to stdout or a file for the platform to pick up.
- A quick grep, when you want to search decisions with text tools.
Related
- Previous: Proving the audit log's integrity
- Next: Merkle proofs and CloudEvents
- Log a second decision and confirm the file now has two lines.
- Print the raw line including its
timestampand note it changes each run. - Add a
metadatadictionary to the entry and read it back from the line.
Slow is fine. Stopping is the only problem.