Agency Swarm uses Langchain callbacks to connect with third party observability tools.

Although we strongly discourage using Langchain for agent development due to its numerous unnecessary abstractions, it currently has the widest support among third-party observability tools. For this reason, we have adopted its callback structure. However, no Langchain code is used within Agency Swarm.

Supported Observability Platforms

When it comes to choosing your observability platform, there are a few options. You can use one or multiple trackers simultaneously for comprehensive monitoring:

Getting Started

We currently recommend Langfuse because it is fully open source, easy to use, and offers the most comprehensive set of features and support. You can also combine it with other trackers for enhanced observability.

1

Install Package

pip install langfuse==2.60.2
2

Set Environment Variables

export LANGFUSE_SECRET_KEY=<your-secret-key>
export LANGFUSE_PUBLIC_KEY=<your-public-key>
3

Initialize Tracking

from agency_swarm import init_tracking

# Initialize single tracker
init_tracking("langfuse")

# Or initialize multiple trackers
init_tracking("langfuse")
init_tracking("local")  # Add local tracking alongside Langfuse

For more information, see the Langfuse Documentation.

How It Works

Agency Swarm uses a simple but powerful tracking system that captures every interaction in your agent’s lifecycle:

  1. Event Tracking: Every message, tool call, and error is automatically tracked with unique IDs and timestamps.
  2. Hierarchical Structure: Events are organized in a tree structure, showing how different parts of your agent interact.
  3. Multiple Platforms: You can send this data to different platforms (Langfuse, AgentOps, or local SQLite) for analysis.

The tracking system is built on top of Langchain’s callback interface, which means it can work with any observability tool that supports Langchain. This gives you flexibility while keeping the implementation simple.

What Gets Tracked

The system automatically captures:

  • Messages: Every conversation between users and agents
  • Tool Calls: When agents use tools and their results
  • Errors: Any issues that occur during execution
  • Performance: Token usage, timing, and other metrics
  • Relationships: How different parts of your agent interact

This data helps you understand your agent’s behavior, debug issues, and optimize performance.