Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Observability #199

Merged
merged 2 commits into from
Mar 4, 2025
Merged

Conversation

bonk1t
Copy link
Collaborator

@bonk1t bonk1t commented Dec 9, 2024

Observability

This PR introduces comprehensive observability support for Agency Swarm through Langchain callbacks, allowing you to track, monitor, and analyze the behavior and performance of your agents.

To use tracking with Langchain callbacks, you need to install the langchain package:

pip install langchain

Langfuse

Langfuse is an observability platform that provides detailed execution tracking with features like tracing, metrics, and debugging tools.

Screenshot 2024-12-20 at 01 36 29

To use Langfuse with Agency Swarm:

  1. Install the langfuse package:
pip install langfuse
  1. Set the required environment variables:
export LANGFUSE_SECRET_KEY=<your-secret-key>
export LANGFUSE_PUBLIC_KEY=<your-public-key>

You can get your keys from the Langfuse dashboard.

  1. Initialize tracking in your code:
from agency_swarm import init_tracking
init_tracking("langfuse")

Configuration options can be passed to the Langfuse callback handler:

init_tracking(
    "langfuse",
    debug=True,
    host="custom-host",
    user_id="user-123",
)

For additional parameters, see the Langfuse documentation.

Local Tracking

This PR also introduces a lightweight local tracker that logs agent activities to a SQLite database.

To use the local tracker:

from agency_swarm import init_tracking
init_tracking("local")

This creates a SQLite database in the current working directory. For a custom database location:

from agency_swarm import init_tracking
init_tracking("local", db_path="path/to/your/database.db")

Additional Features

  • Support for token counting and cost tracking
  • Streaming response monitoring
  • Tool usage tracking
  • Extensive refactoring for maintainability

@bonk1t bonk1t changed the title Add SQLite and Langfuse trackers; Refactor test system Integrate Observability Dec 9, 2024
@bonk1t bonk1t marked this pull request as ready for review December 20, 2024 02:33
@bonk1t bonk1t requested a review from VRSEN December 20, 2024 02:43
@bonk1t bonk1t force-pushed the dev/integrate-observability branch from 9f2bf9e to 0ab8520 Compare March 3, 2025 23:35
@VRSEN VRSEN merged commit b61fe92 into VRSEN:main Mar 4, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants