Skip to main content

Audit logging for Claude AI agents — transparent, tamper-evident, OSS

Project description

agentlens

Audit logging for Claude AI agents. Transparent, append-only, OSS.

Why

Anthropic logs API calls for their own safety monitoring — but that log is not yours. When your Claude-powered agent takes an action, you need your own tamper-evident record: for compliance, incident response, and accountability.

agentlens is a drop-in wrapper around the Anthropic SDK that captures every tool_use and tool_result event — without modifying requests or responses.

Design principles

  • Read-only interception — requests and responses are never altered
  • Append-only writes — log entries cannot be edited after creation
  • No AI in the logger — capture logic is deterministic code, not an LLM
  • Your data stays local — FileWriter (default) writes to your own machine; no data leaves your environment

Install

pip install agentlens-io

Usage

from agentlens import AuditedAnthropic

# Drop-in replacement for anthropic.Anthropic()
client = AuditedAnthropic(log_path="./audit.jsonl")

response = client.messages.create(
    model="claude-opus-4-6",
    max_tokens=1024,
    tools=[...],
    messages=[{"role": "user", "content": "..."}],
)
# Every tool_use and tool_result is now in audit.jsonl

Log format (JSONL)

{"event_type": "tool_use", "tool_use_id": "toolu_01xxx", "tool_name": "bash", "tool_input": {"command": "ls -la"}, "model": "claude-opus-4-6", "timestamp": "2026-04-05T10:00:00+00:00", "session_id": "..."}
{"event_type": "tool_result", "tool_use_id": "toolu_01xxx", "result_content": "file1.txt\nfile2.txt", "is_error": false, "timestamp": "2026-04-05T10:00:01+00:00", "session_id": "..."}

Custom writer

from agentlens.writers import BaseWriter

class MyWriter(BaseWriter):
    def write(self, event) -> None:
        # send to your own DB, S3, SIEM, etc.
        my_db.insert(event.to_json())

client = AuditedAnthropic(writer=MyWriter())

Run tests

pip install -e ".[dev]"
pytest tests/

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

agentlens_io-0.3.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

agentlens_io-0.3.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file agentlens_io-0.3.1.tar.gz.

File metadata

  • Download URL: agentlens_io-0.3.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agentlens_io-0.3.1.tar.gz
Algorithm Hash digest
SHA256 1131bfcef0f12811a5d5476cc5ef20f99dde2020c262803c695e751b2b8c0413
MD5 7c88e91fda00d5e094c2eb27fbaf88be
BLAKE2b-256 43e0fb4f5eeb385977c7a915353ead7616ffaa0f3317df0e66a5c40878aad6b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentlens_io-0.3.1.tar.gz:

Publisher: publish.yml on agentlens-io/agentlens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentlens_io-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: agentlens_io-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agentlens_io-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f72b97f3ef63fd54ed25784bc94c95e30d374245334ab912eaefcb5d065c1364
MD5 e00736759beb9752e45087cac0f4b48f
BLAKE2b-256 b963e03f69b1ed27964cd9e6949993efc3c2978c98765bb4bb15e867461469a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentlens_io-0.3.1-py3-none-any.whl:

Publisher: publish.yml on agentlens-io/agentlens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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