Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
"observability/langwatch",
"observability/langsmith",
"observability/langtrace",
"observability/maxim",
"observability/weave"
]
},
Expand Down
Binary file added images/maxim.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 162 additions & 0 deletions observability/maxim.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
title: Maxim
description: Integrate Agno with Maxim to send traces and gain insights into your agent's performance.
---

## Integrating Agno with Maxim

Maxim AI provides comprehensive agent monitoring, evaluation, and observability for your Agno applications. With Maxim's one-line integration, you can easily trace and analyse agent interactions, performance metrics, and more.

## Prerequisites

1. **Install Dependencies**

Ensure you have the necessary packages installed:

```bash
pip install agno openai maxim-py
```

2. **Setup Maxim Account**

- Sign up for an account at [Maxim](https://getmaxim.ai/).
- Generate your API key from the Maxim dashboard.
- Create a repository to store your traces.

3. **Set Environment Variables**

Configure your environment with the Maxim API key:

```bash
export MAXIM_API_KEY=<your-api-key>
export MAXIM_LOG_REPO_ID=<your-repo-id>
export OPENAI_API_KEY=<your-openai-api-key>
```

## Sending Traces to Maxim

### Example: Basic Maxim Integration

This example demonstrates how to instrument your Agno agent with Maxim and send traces for monitoring and evaluation.

```python
import os
from dotenv import load_dotenv
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools
from maxim import Maxim
from maxim.logger.agno import instrument_agno

# Load environment variables
load_dotenv()

# Instrument Agno with Maxim
instrument_agno(Maxim().logger())

# Create and configure the agent
agent = Agent(
name="Stock Price Agent",
model=OpenAIChat(id="gpt-4o"),
tools=[YFinanceTools()],
instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
show_tool_calls=True,
markdown=True,
)

# Use the agent
response = agent.run("What is the current price of Tesla?")
print(response.content)
```

### Example: Multi-Agent System with Maxim

This example demonstrates how to set up a multi-agent system with comprehensive Maxim tracing.

```python
import os
from dotenv import load_dotenv
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.googlesearch import GoogleSearchTools
from agno.tools.yfinance import YFinanceTools
from maxim import Maxim
from maxim.logger.agno import instrument_agno

# Load environment variables
load_dotenv()

# Instrument Agno with Maxim
instrument_agno(Maxim().logger())

# Create individual agents
web_search_agent = Agent(
name="Web Agent",
role="Search the web for information",
model=OpenAIChat(id="gpt-4o"),
tools=[GoogleSearchTools()],
instructions="Always include sources",
show_tool_calls=True,
markdown=True,
)

finance_agent = Agent(
name="Finance Agent",
role="Get financial data",
model=OpenAIChat(id="gpt-4o"),
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],
instructions="Use tables to display data",
markdown=True,
)

# Create multi-agent system
multi_ai_agent = Agent(
team=[web_search_agent, finance_agent],
model=OpenAIChat(id="gpt-4o"),
instructions="You are a helpful financial assistant. Answer user questions about stocks, companies, and financial data.",
show_tool_calls=True,
markdown=True
)

# Use the multi-agent system
response = multi_ai_agent.run("What's the current stock price of Apple and what are the latest analyst recommendations?")
print(response.content)
```

![agno.gif](/images/maxim.gif)

## Features

### Observability & Tracing

Maxim provides comprehensive observability for your Agno agents:

- **Agent Tracing**: Track your agent's complete lifecycle, including tool calls, agent trajectories, and decision flows
- **Token Usage**: Monitor prompt and completion token consumption
- **Model Information**: Track which models are being used and their performance
- **Tool Calls**: Detailed logging of all tool executions and their results
- **Performance Metrics**: Latency, cost, and error rate tracking

### Evaluation & Analytics

- **Auto Evaluations**: Automatically evaluate captured logs based on filters and sampling
- **Human Evaluations**: Use human evaluation or rating to assess log quality
- **Node Level Evaluations**: Evaluate any component of your trace for detailed insights
- **Dashboards**: Visualize traces over time, usage metrics, latency & error rates

### Alerting

Set thresholds on error rates, cost, token usage, user feedback, and latency to get real-time alerts via Slack or PagerDuty.

## Notes

- **Environment Variables**: Ensure your environment variables are correctly set for the API key and repository ID.
- **Instrumentation Order**: Call `instrument_agno()` **before** creating or executing any agents to ensure proper tracing.
- **Debug Mode**: Enable debug mode to see detailed logging information:

```python
instrument_agno(Maxim().logger(), {"debug" : True})
```
- **Maxim Docs**: For more information on Maxim's features and capabilities, refer to the [Maxim documentation](https://getmaxim.ai/docs).

By following these steps, you can effectively integrate Agno with Maxim, enabling comprehensive observability, evaluation, and monitoring of your AI agents.