Skip to main content

Automatic compliance logging for AI agents. One line install, vendor-agnostic, audit-ready.

Project description

AgentLog

License: MIT Python 3.9+ PyPI

Audit trail for AI agents. One decorator, zero dependencies.

pip install auditlog-ai

The problem

Your agents call models, execute tools, make decisions. If something goes wrong — or an auditor asks what happened — you have nothing. No logs, no trail, no proof.

AgentLog fixes that. Every agent action gets a structured event: who did what, when, which model, who authorized it. Append-only JSONL, SHA-256 hashed I/O, ready to ship to any backend.

30 seconds to production

Decorator — wrap any function, done:

from agentlog import log_agent

@log_agent(agent_id="support-bot", model_id="gpt-4")
def answer(prompt: str) -> str:
    return call_my_model(prompt)

answer("How do I reset my password?")
# → agentlog.jsonl gets a new line

Context manager — when you need timing:

from agentlog import AgentLogger

with AgentLogger(agent_id="support-bot", model_id="gpt-4") as logger:
    result = call_my_model("How do I reset my password?")
    logger.set_output(result)
# → logged with latency_ms

Direct call — full control:

from agentlog import AgentLogger

logger = AgentLogger(agent_id="support-bot", model_id="gpt-4")
logger.log(input_text="Hello", output_text="Hi there")

What gets logged

{
  "event_id": "a1b2c3d4-...",
  "agent_id": "support-bot",
  "session_id": "e5f6g7h8-...",
  "timestamp": "2026-03-30T12:00:00+00:00",
  "input_hash": "2cf24b72...",
  "output_hash": "486ea46...",
  "model_id": "gpt-4",
  "authorized_by": "system",
  "latency_ms": 423
}

Inputs and outputs are SHA-256 hashed. The actual content never touches the log unless you opt in with store_raw=True.

v0.2 — Async, PostgreSQL, raw storage

Async support — for async agents:

from agentlog import alog_agent

@alog_agent(agent_id="async-bot", model_id="claude-3")
async def answer(prompt: str) -> str:
    return await call_my_model(prompt)
pip install auditlog-ai[async]

Store raw content — when you need the full text, not just hashes:

logger.log(input_text="Hello", output_text="Hi there", store_raw=True)
# → input_raw and output_raw fields included in the event

Bring your own backend

JSONL by default. Supabase, PostgreSQL, or build your own:

from agentlog import AgentLogger, SupabaseBackend, PostgresBackend

# Supabase
backend = SupabaseBackend(url="https://xxx.supabase.co", key="your-key")

# PostgreSQL
backend = PostgresBackend(dsn="postgresql://user:pass@localhost/mydb")

logger = AgentLogger(agent_id="my-agent", model_id="gpt-4", backend=backend)
pip install auditlog-ai[supabase]
pip install auditlog-ai[postgres]
pip install auditlog-ai[all]        # everything

Writing your own backend is one method: save(event: AgentEvent).

Design decisions

  • Zero dependencies. Core uses only the standard library. No vendor lock-in.
  • Hashed by default. Input/output never stored in plaintext unless you opt in with store_raw=True.
  • Append-only JSONL. Grep it, stream it, pipe it. No database required.
  • Vendor-agnostic. Works with OpenAI, Anthropic, LangChain, your custom stack.
  • Async-native. Full async support for non-blocking agent pipelines.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auditlog_ai-0.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auditlog_ai-0.2.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file auditlog_ai-0.2.0.tar.gz.

File metadata

  • Download URL: auditlog_ai-0.2.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for auditlog_ai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3e882009cb55298371ca127c857c635e6a5508a049fe3f7a24d5ccdac43fe242
MD5 c8adcb4eb4dfab25eefb9a075f3bb321
BLAKE2b-256 527ed93fba7e44da29d5e2ff9cf7d99f25fb459c3a0bdf0b5063507a3c0965e3

See more details on using hashes here.

File details

Details for the file auditlog_ai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: auditlog_ai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for auditlog_ai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8c3f45e474439434c4b63909950920ba98edcb0ca25368a6e53f8cb623642be
MD5 e5a2034d3ed36e09dd3351d9a8e4b7c3
BLAKE2b-256 9327ec9e7f30650e86deb87e483d34e7bbc9a194a823b76bc606b6c154f6c984

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page