Skip to main content

👁️ AgentLens

PyPI Version Python Versions License: MIT

⚡️ AgentLens is an ultra-lightweight, zero-config, local-first observability and execution trace visualizer built specifically for multi-agent autonomous frameworks (CrewAI, LangGraph, AutoGen, and custom LLM workflows).


💡 Why AgentLens?

Cloud telemetry platforms (LangSmith, Phoenix, Datadog) require external API keys, introduce network latency, and store your agent thoughts and prompts on third-party servers.

AgentLens runs 100% locally on your machine:

  • 0 ms Network Overhead: Traces write locally to an embedded SQLite database using WAL (Write-Ahead Logging) mode.
  • Async & Thread-Safe: Built on Python contextvars to reliably reconstruct nested parent-child call trees across coroutines and worker threads.
  • Zero Serialization Crashes: Features a bulletproof fallback serialization barrier that gracefully handles non-serializable objects (generators, Pydantic models, binary blobs).
  • Embedded Web UI: Single-command local dashboard (agentlens ui) with live polling, waterfall call trees, latency metrics, and syntax-highlighted JSON forensic inspection.

🚀 Quickstart

1. Installation

Install the engine via pip:

pip install agentlens-ui

2. Instrument Your Multi-Agent Code

Add the @trace decorator to your agents, tools, or task functions:

from agentlens_ui.core import trace

# Trace standalone tools
@trace("Web_Search_Tool")
def search_web(query: str):
    return f"Latest results for: {query}"

# Trace async or sync agent executions
@trace("Researcher_Agent")
async def run_agent(task_description: str):
    results = search_web("AI multi-agent orchestration")
    return f"Completed analysis with {results}"

For programmatic logging (e.g. CrewAI step callbacks, LangChain event hooks):

from agentlens_ui.core import log_trace

def step_callback(step_output):
    log_trace(
        agent_name="CrewAI_Orchestrator",
        step_type="THOUGHT",
        content="Agent finished reasoning step.",
        details={"thought": step_output.thought}
    )

3. Launch the Dashboard

Run the global CLI command in your project terminal:

agentlens ui

Open your browser at http://localhost:8000 to view live waterfall traces, execution latency, and step-by-step agent reasoning!


🧩 Framework Integrations

CrewAI Integration Example

from crewai import Agent, Task, Crew, Process, LLM
from crewai.tools import tool
from agentlens_ui.core import trace, log_trace

# 1. Trace Custom Tools
@tool("Search_Tool")
@trace("Search_Tool")
def search(query: str) -> str:
    return "Fetched live trend data."

# 2. Trace Thought Callbacks
def agent_callback(step_output):
    log_trace(
        agent_name="CrewAI_Manager",
        step_type="THOUGHT",
        content="Agent completed thought step",
        details={"output": step_output.thought}
    )

# 3. Trace Full Execution
@trace("Crew_Execution")
def kickoff_crew():
    crew = Crew(
        agents=[...],
        tasks=[...],
        process=Process.sequential,
        step_callback=agent_callback
    )
    return crew.kickoff()

if __name__ == "__main__":
    kickoff_crew()

⚙️ Configuration & Environment Variables

Variable Default Description
AGENTLENS_DB_PATH ./agentlens.db Absolute or relative path to the SQLite telemetry database file.

To store telemetry in a centralized location across multiple projects:

export AGENTLENS_DB_PATH=~/.agentlens/traces.db

🏛️ Deep Technical Architecture

For an exhaustive technical audit of how AgentLens operates under the hood, read the Staff Software Engineer Architectural Review:

  • Lineage Mechanics: Causal parent-child call graph resolution via contextvars.
  • Concurrency & WAL Mode: Lockless readers, busy timeout queuing (timeout=10.0), and descriptor cleanup (contextlib.closing).
  • Serialization Boundary: Two-tier safety mechanisms intercepting un-serializable models.
  • Comparative Analysis: Performance benchmarks against cloud telemetry collectors.

📄 License

Distributed under the MIT License.

Metadata

Release files for agentlens-ui 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentlens-ui 0.1.0
File Size Uploaded Provenance Actions
agentlens_ui-0.1.0.tar.gz 13.6 kB Without provenance Details for agentlens_ui-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agentlens-ui 0.1.0
File Interpreter ABI Platform Actions
agentlens_ui-0.1.0-py3-none-any.whl Python 3 none any Details for agentlens_ui-0.1.0-py3-none-any.whl

Total release size: 25.7 kB

Release files / agentlens_ui-0.1.0.tar.gz

Download URL agentlens_ui-0.1.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
89d12ad9cc1bb0af296e0ae208ff0d9f9556d23ca910d3af5b001f01bb5df27c
BLAKE2b-256 checksum
How to use checksums
e7334def4bf7b810304060dddb897c10277dec55ad6164f0bf2692fdd4b829be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / agentlens_ui-0.1.0-py3-none-any.whl

Download URL agentlens_ui-0.1.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
818cc18d4c78105a902f8060b2e581099515189edb07169971af8fd4e79765c9
BLAKE2b-256 checksum
How to use checksums
c4791e4b3b617c18bf6ceef90f1db4a019aed14043a3f6063a22785478740f16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Security for agentlens-ui 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page