DEV Community

Cover image for I Built AgentLens: Open-Source Observability for AI Agents (2-Line Setup)
Kunal Parmar
Kunal Parmar

Posted on

I Built AgentLens: Open-Source Observability for AI Agents (2-Line Setup)

I spent weeks debugging AI agents using nothing but logs and print statements.

Every time an agent failed or gave wrong output, I had no idea whether the issue was in the prompt, the LLM, a tool call, or growing context. It felt like debugging in the dark.

So I built AgentLens — a clean, self-hosted observability platform made specifically for AI agents.

What is AgentLens?

AgentLens gives you full visibility into your agent runs with beautiful traces, just like Chrome DevTools for your AI agents.

Key Highlights

  • 2-line setup — works with your existing OpenAI & Anthropic code
  • Full prompt & response capture
  • Token usage and cost tracking per call
  • Live dashboard with nested traces
  • Supports multi-step agents, loops, and tool calls
  • Completely open source (MIT) and self-hostable

Setup (Literally 2 lines)

pip install agentlens

python

import agentlens as al

al.init(api_key="your-agentlens-key")
al.instrument_openai()   # also supports Anthropic
Enter fullscreen mode Exit fullscreen mode

That’s it. All your LLM calls are now automatically traced.Screenshots(Upload your best screenshots here: Span Tree, Inspector view, Trace list, etc.)Tech StackBackend: FastAPI + PostgreSQL + Redis
Frontend: Next.js 15
Self-host with one docker compose up

GitHub Repository https://github.com/kp183/AgentlensI built this because I was tired of guessing why my agents were failing. Now I can see exactly what happened at every step.If you're building agents with LangChain, CrewAI, LlamaIndex, or custom frameworks — I’d love your feedback.What’s the biggest debugging pain you face with AI agents today?

🖼️ See It In Action

Hierarchical Span Tree Timeline

Token & Cost Inspector

Top comments (0)