Skip to main content
Every tool call can be recorded to an append-only JSONL audit log — thread-safe for concurrent multi-agent writes.

Quick Start

from praisonaiagents import Agent
from praisonai.security import enable_audit_log, get_audit_log

enable_audit_log()  # default: ~/.praisonai/audit.jsonl

agent = Agent(
    name="AuditedAgent",
    instructions="Every tool call is logged.",
)
agent.start("Summarise today's PRs")

# On shutdown (tests, FastAPI lifespan, etc.)
get_audit_log().close()

What’s Logged

Each JSONL line records:
  • timestamp, session_id, agent_name
  • tool_name, tool_input, execution_time_ms
  • Optional tool_output (when include_output=True)
The hook registers on after_tool automatically when you call enable_audit_log().

Configuration

OptionTypeDefaultDescription
log_pathstr~/.praisonai/audit.jsonlAppend-only JSONL path
include_outputboolFalseInclude truncated tool output
max_output_charsint500Max output chars when include_output=True
enable_audit_log(
    log_path="./my-audit.jsonl",
    include_output=True,
    max_output_chars=1000,
)

Thread Safety (PR #2062)

  • Uses threading.Lock for concurrent multi-agent writes
  • Keeps a long-lived file handle (reopened lazily if rotated)
  • Each write calls fsync for crash durability
  • Call get_audit_log().close() on shutdown to flush and release the handle

Security Overview

Enable audit log with other security features

Protected Paths

Audit log file is itself protected