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
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 agentlens_io-0.3.0.tar.gz.
File metadata
- Download URL: agentlens_io-0.3.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25af02da6885a88786a6e96a6f37248c51949cc472f92bbf366aa8f3da6cbc07
|
|
| MD5 |
ac18aedd806af7b59445b673560b51b1
|
|
| BLAKE2b-256 |
273e27b86e83098ba279cba8fe1d322b897abb03905b378d2abf7640c5b02a5f
|
Provenance
The following attestation bundles were made for agentlens_io-0.3.0.tar.gz:
Publisher:
publish.yml on agentlens-io/agentlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentlens_io-0.3.0.tar.gz -
Subject digest:
25af02da6885a88786a6e96a6f37248c51949cc472f92bbf366aa8f3da6cbc07 - Sigstore transparency entry: 1242506065
- Sigstore integration time:
-
Permalink:
agentlens-io/agentlens@32ca29b0017e2b7a689c0b488998cc21f88ffa84 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/agentlens-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@32ca29b0017e2b7a689c0b488998cc21f88ffa84 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentlens_io-0.3.0-py3-none-any.whl.
File metadata
- Download URL: agentlens_io-0.3.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a06d3a6c86cc004bbf81848a3c81ea12df81fd93c7748c042b54997b98710b6e
|
|
| MD5 |
15e4234458b756f63148f0068a0aafd3
|
|
| BLAKE2b-256 |
fa6c0b6aa7e99976c69566ceaef9399097c1a4904cefcf7118a1ab0070757f43
|
Provenance
The following attestation bundles were made for agentlens_io-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on agentlens-io/agentlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentlens_io-0.3.0-py3-none-any.whl -
Subject digest:
a06d3a6c86cc004bbf81848a3c81ea12df81fd93c7748c042b54997b98710b6e - Sigstore transparency entry: 1242506072
- Sigstore integration time:
-
Permalink:
agentlens-io/agentlens@32ca29b0017e2b7a689c0b488998cc21f88ffa84 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/agentlens-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@32ca29b0017e2b7a689c0b488998cc21f88ffa84 -
Trigger Event:
push
-
Statement type: