Skip to main content
Langfuse provides observability and evaluation tools for LLM applications with automatic tracing of all agent conversations.

Path Comparison

Quick Start

1

Install and Enable

2

Auto-Detection


How Path A Works — obs.langfuse()


Environment Variables

As of PraisonAI’s wrapper-layer refactor, OTEL_SDK_DISABLED and EC_TELEMETRY are only set on first observability use, not at import. User-set values are preserved (setdefault). If LANGFUSE_PUBLIC_KEY is set or ~/.praisonai/langfuse.env exists, OTEL_SDK_DISABLED=false is set explicitly so Langfuse v4 can use OTel internally.

CLI Observability — --observe langfuse

Enable full agent lifecycle tracing with a single CLI flag:

What Gets Traced

The CLI --observe langfuse captures:
  • Agent lifecycle: agent_start / agent_end spans
  • LLM interactions: llm_request / llm_response with readable content
  • Tool usage: tool_call_start / tool_call_end with args and results
  • Automatic flush: No manual provider.flush() required
As of PR #1461, atexit auto-closes the sink — no manual flush required for CLI runs. See Custom Tracing for the underlying ContextTraceSinkProtocol.

Programmatic — LangfuseSink + Context Bridge

For full control over Langfuse tracing in Python code:
The set_context_emitter(... sink=sink.context_sink() ...) call is required for typical single-agent flows. Without it, only RouterAgent token-usage and PlanningAgent.plan_created events appear in Langfuse — Agent.start() lifecycle is silent.

LangfuseSinkConfig Options


CLI Server Commands


Common Patterns

Multi-Agent Tracing

All agents in a session share the same Langfuse context automatically:

Connection Verification

Configuration File Usage

Credentials from ~/.praisonai/langfuse.env are auto-loaded:

Best Practices

Call provider.flush() to ensure all traces are sent for obs.langfuse():
Path B (--observe langfuse) auto-registers atexit.close since PR #1461.
Prefer obs.auto() for environment-based configuration:
As of PR #1461, llm_response spans contain the assistant message text (or [tool_calls: name1, name2] summary), not the raw ChatCompletion(...) repr. The Langfuse “Output” panel is now human-readable:
  • Before: ChatCompletion(id='chatcmpl-...', choices=[Choice(...)], ...)
  • After: "The capital of France is Paris." or [tool_calls: search_web, calculator]
For programmatic usage, include the context emitter for complete lifecycle tracing:
Without this, only RouterAgent and PlanningAgent events appear — Agent.start() flows are silent.
When an agent runs the same tool concurrently (e.g. two parallel search_web calls), each TOOL_END event is now correlated to the matching TOOL_START via a per-(agent, tool) LIFO stack. Earlier versions could attach a TOOL_END to the wrong in-flight span. No user-facing API change — the fix is automatic.
Use CLI for local development:
  1. praisonai langfuse start
  2. praisonai langfuse config
  3. Test with praisonai langfuse test

Observability Overview

Compare observability providers

Agent Configuration

Configure agent settings