Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 1 min read

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

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

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

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.