AgentLens
Audit trail, authorization, and anomaly detection for AI agents.
Every AI agent your company runs takes actions — reads files, sends emails, calls APIs, moves money. AgentLens makes every action observable, authorized, and auditable. One decorator. Zero infrastructure required to start.
pip install agentlens
Quickstart
import agentlens
@agentlens.trace(agent_id="invoice-agent", action="process_invoice")
def process_invoice(data: dict) -> dict:
# your LLM call here
return result
That's it. Every call is now logged to ~/.agentlens/events.db.
agentlens logs # view audit trail in terminal
agentlens alerts # view anomaly alerts
agentlens stats # summary statistics
Three Modules
1. Audit Trail (agentlens.trace)
Wrap any function. Every call is recorded with timestamp, inputs, outputs, latency, token count, and status.
@agentlens.trace(
agent_id="email-drafter",
action="draft_reply",
tags={"customer_id": "acme-corp"},
)
def draft_reply(thread: str) -> str:
...
Or log manually without the decorator:
agentlens.log_event(
agent_id="pipeline-runner",
action="batch_classify",
inputs={"docs": 142},
outputs={"processed": 142},
latency_ms=4210,
)
2. Authorization Engine (agentlens.auth)
Define what each agent is allowed to do. Check before it acts.
# Register a policy
agentlens.auth.register_policy(
"email-drafter",
agentlens.auth.policy_allowlist(["draft_reply", "read_thread"]),
)
# Check inline
if not agentlens.auth.allow("email-drafter", "send_external_email"):
raise PermissionError("Not authorized")
# Or raise automatically
agentlens.auth.require("email-drafter", "send_external_email") # raises AuthorizationError
Built-in policies: policy_allow_all, policy_deny_all, policy_allowlist(actions). Custom policies are just functions: (agent_id, action) -> AuthDecision.
3. Anomaly Shield (agentlens.shield)
Define an agent's normal behavior. Get alerted when it deviates.
agentlens.shield.configure_agent(
agent_id="email-drafter",
baseline_actions=["read_thread", "draft_reply"],
alert_on=["send_external_email", "delete_thread", "forward_all"],
)
# Register an alert handler (Slack, PagerDuty, Discord, etc.)
agentlens.shield.on_alert(lambda a: slack.send(f"🚨 {a.severity}: {a.reason}"))
# Check before the agent acts
agentlens.shield.scan_and_block("email-drafter", "delete_thread") # raises AnomalyBlockedError
CLI Reference
agentlens logs [--agent AGENT_ID] [--limit N] [--json]
agentlens alerts [--limit N]
agentlens stats
Custom DB Path
agentlens.configure(db_path="/var/log/myapp/agentlens.db")
Roadmap
- Web dashboard (v0.2)
- EU AI Act compliance PDF export
- OpenTelemetry exporter
- Cloud sync (AgentLens Cloud)
- Slack / PagerDuty / Discord integrations
- Multi-agent session tracking
License
MIT — see LICENSE
Built by AgentLens · Questions? hello@agentlens.dev
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 llmsentinel-0.3.0.tar.gz.
File metadata
- Download URL: llmsentinel-0.3.0.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17b7467d868edc3a2c6121da3031e17357e83914c5393cfecd0c27afbb27bfe2
|
|
| MD5 |
75646a4acd64db6973ea4a01583fdc8b
|
|
| BLAKE2b-256 |
f3e83e8de1568512b343e3dbb012e4afc11ce3e752ec1e6aaefa2d0211aff638
|
File details
Details for the file llmsentinel-0.3.0-py3-none-any.whl.
File metadata
- Download URL: llmsentinel-0.3.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
771c210706d5947f37e0f55392a232598cff12f8cb0c631d08468c8a6c6a8dec
|
|
| MD5 |
85b5946ee69b2cb849d3eb91bd44eeec
|
|
| BLAKE2b-256 |
931bed0cb284c15dcf5d0e39b55c189ecf88975ccb7e2b19c12154f64f012c5a
|