Skip to main content

Trinity Agent Monitoring SDK

A comprehensive Python SDK for monitoring AI agents with advanced tracing, metrics collection, and observability capabilities powered by Langfuse.

Features

  • Comprehensive Agent Monitoring: Track agent execution, tool usage, and performance metrics
  • Rich Metrics Collection: Monitor tokens, costs, latency, and tool utilization
  • Tool Usage Analytics: Detailed analysis of which tools your agents use and how often
  • Easy Integration: Simple decorator-based monitoring with minimal code changes

Installation

pip install trinity-agent-monitoring

Quick Start

1. Initialize the Monitor

from trinity_agent_monitoring import create_monitor, set_monitor

# Create and set up the global monitor
monitor = create_monitor(
    public_key="your_trinity_public_key",
    secret_key="your_trinity_secret_key"
)

# Set as global monitor for easy access
set_monitor(monitor)

2. Monitor Your Agent

from trinity_agent_monitoring import get_monitor

# Get the global monitor
monitor = get_monitor()

# Use the decorator to monitor your agent
@monitor.monitor_agent(agent_name="my_ai_agent")
def my_agent_function(agent_executor,user_input):
    # Your agent logic here
    response = process_user_input(user_input)
    return response

# Call your monitored function
result = my_agent_function(agent_executor, "Hello, agent!")

3. Instance-based Monitoring

from trinity_agent_monitoring import TrinityAgentMonitor

# Create a dedicated monitor instance
monitor = TrinityAgentMonitor(
    public_key="your_public_key",
    secret_key="your_secret_key"
)

# Use with your agent
@monitor.monitor_agent("custom_agent")
def custom_agent_function():
    # Agent logic
    pass

Get Callback Handler for LangChain

# Get the callback handler for LangChain integration
callback_handler = monitor.get_callback_handler()

# Use with your LangChain agent
from langchain.agents import AgentExecutor
from langchain.llms import OpenAI

agent = AgentExecutor.from_agent_and_tools(
    agent=your_agent,
    tools=your_tools,
    callbacks=[callback_handler]
)

API Reference

TrinityAgentMonitor

Main monitoring class that provides comprehensive agent monitoring capabilities.

Utility Functions

  • create_monitor(public_key, secret_key, host): Create a new monitor instance
  • get_monitor(): Get the global monitor instance
  • set_monitor(monitor): Set the global monitor instance

Metrics Collected

The SDK automatically collects the following metrics:

  • Token Usage: Input, output, and total tokens
  • Cost Analysis: Calculated costs for each operation
  • Latency: Start time, end time, and duration
  • Tool Usage: Which tools were used and how many times
  • Input/Output: Raw input and output data for analysis
  • Metadata: Custom metadata for additional context

Support

For support and questions, contact us at support@giggso.com

Metadata

Release files for trinity-agent-monitoring 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trinity-agent-monitoring 0.2.1
File Size Uploaded Provenance Actions
trinity_agent_monitoring-0.2.1.tar.gz 13.3 kB Without provenance Details for trinity_agent_monitoring-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trinity-agent-monitoring 0.2.1
File Interpreter ABI Platform Actions
trinity_agent_monitoring-0.2.1-py3-none-any.whl Python 3 none any Details for trinity_agent_monitoring-0.2.1-py3-none-any.whl

Total release size: 26.5 kB

Release files / trinity_agent_monitoring-0.2.1.tar.gz

Download URL trinity_agent_monitoring-0.2.1.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
928ce827835656a8e3ef3d9f8c81c5df492b33e3352ebbfe9fe0366c2906c2a4
BLAKE2b-256 checksum
How to use checksums
9167c0dd09f8bcf43301d245b545aa3cdc4001c66f43070986ba3fe753857291
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release files / trinity_agent_monitoring-0.2.1-py3-none-any.whl

Download URL trinity_agent_monitoring-0.2.1-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05af442d6c305b3f9c1b5feee80b7c5c996717b8eb0f3419aaa9701c16ad80b2
BLAKE2b-256 checksum
How to use checksums
c20cf37e1fa3005e449783afca0ac7bb9c80f6dc131b3a6378e92ea9471c6178
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Security for trinity-agent-monitoring 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page