Lightweight Python middleware that wraps any agent framework and logs every tool call. SOC 2 audit trail for small teams.
Project description
Agent Audit Logger
Every agent call logged. SOC 2 ready.
A lightweight Python middleware that wraps any agent framework (LangChain, CrewAI, AutoGen, n8n, Hermes) and logs every tool call — what was invoked, what data passed through, what changed. Output as JSON to file or Google Sheets. Exportable PDF reports for compliance.
Target: startups that need SOC 2 prep but can't afford $10K/mo enterprise stacks.
Features
- Framework-agnostic middleware — wrap any Python callable or agent tool function
- JSON log rotation — daily rolling files with optional gzip compression
- Google Sheets export — real-time audit trail in a shared sheet
- PDF compliance reports — cover page, executive summary, detailed entry table, checksums
- Tamper-evident — each entry includes a SHA-256 checksum
- Session tracking — correlate all calls from a single agent run
Quick Start
pip install agent-audit-logger
Basic usage
from agent_audit_logger import AuditLogger, AuditEntry, AuditMiddleware
from agent_audit_logger.exporters.json_logger import JsonLogExporter
# Create logger and add JSON output
logger = AuditLogger()
logger.add_exporter(JsonLogExporter("audit_logs/"))
# Create middleware
middleware = AuditMiddleware(logger, agent_name="my_agent")
# Use as a decorator
@middleware(tool_name="search_web", tags=["search"])
def search_web(query: str) -> str:
return f"Results for {query}"
# Or wrap existing functions
wrapped_func = middleware.wrap(
my_existing_tool,
agent_name="worker",
tool_name="my_tool",
)
# Log manually
entry = AuditEntry(
agent_name="my_agent",
tool_name="web_search",
tool_input={"query": "SOC 2 compliance"},
tool_output="Results...",
duration_ms=1200.5,
)
logger.log(entry)
LangChain integration
from langchain.tools import Tool
from agent_audit_logger import AuditLogger, AuditMiddleware
logger = AuditLogger()
logger.add_exporter(JsonLogExporter("audit_logs/"))
middleware = AuditMiddleware(logger, agent_name="langchain-agent")
wrapped_tools = AuditMiddleware.wrap_langchain_tools(middleware, tools_list)
CrewAI integration
middleware = AuditMiddleware(logger, agent_name="crewai-agent")
AuditMiddleware.wrap_crewai_tools(middleware, crew_tools_list)
Generate PDF report
report_path = logger.generate_report(
"compliance_report.pdf",
title="Q3 SOC 2 Audit Log",
date_range=("2025-01-01", "2025-03-31"),
)
Log rotation
# Manual rotation (happens automatically on file size threshold)
summary = logger.rotate(archive=True)
Configuration
| Setting | Default | Description |
|---|---|---|
AGENT_AUDIT_LOG_DIR |
audit_logs/ |
Directory for JSON log files |
AGENT_AUDIT_MAX_FILE_MB |
10 |
Rotate when log file exceeds this size |
AGENT_AUDIT_COMPRESS |
False |
Gzip old rotated files |
GOOGLE_SERVICE_ACCOUNT_PATH |
~/.hermes/secrets/client_secret.json |
Path to Google service account JSON |
Pricing
- $49/mo — Up to 3 agents, 10K logs/month
- $99/mo — Unlimited agents, 50K logs/month, PDF exports
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_audit_logger-0.1.0.tar.gz.
File metadata
- Download URL: agent_audit_logger-0.1.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d13b058587d7514b0150587d3393fb94fe4875d0c5961c0e20c5788d1ef1bd36
|
|
| MD5 |
82679c4e87cabf69a2e3474b55217caa
|
|
| BLAKE2b-256 |
9021491ca27efd461cd4e9b467972b14a3d722fe3309e1d1bb4cebb917588c17
|
File details
Details for the file agent_audit_logger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_audit_logger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d5779bc81bc6ca57a90e39466460ae813dac4dd174d99fdf1867bbab7f52307
|
|
| MD5 |
aefe1254e42a18b62e7895dbab187764
|
|
| BLAKE2b-256 |
f533ccc8397c667ad94eaeba73dfab9d2bcc8fc2a94969a69a44f1c33b0b8a69
|