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
Metadata
Release files for llmsentinel 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llmsentinel-0.3.0.tar.gz | 20.6 kB | Without provenance | Details for llmsentinel-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llmsentinel-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for llmsentinel-0.3.0-py3-none-any.whl |
Total release size: 43.2 kB
Release files / llmsentinel-0.3.0.tar.gz
| Download URL | llmsentinel-0.3.0.tar.gz |
|---|---|
| Size | 20.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17b7467d868edc3a2c6121da3031e17357e83914c5393cfecd0c27afbb27bfe2
|
|
BLAKE2b-256 checksum How to use checksums |
f3e83e8de1568512b343e3dbb012e4afc11ce3e752ec1e6aaefa2d0211aff638
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / llmsentinel-0.3.0-py3-none-any.whl
| Download URL | llmsentinel-0.3.0-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
771c210706d5947f37e0f55392a232598cff12f8cb0c631d08468c8a6c6a8dec
|
|
BLAKE2b-256 checksum How to use checksums |
931bed0cb284c15dcf5d0e39b55c189ecf88975ccb7e2b19c12154f64f012c5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for llmsentinel 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.