LangDB

Send Agno agent runs, team runs, and tool-call traces to LangDB.

Integrating Agno with LangDB

LangDB traces Agno agent runs, tool calls, team interactions, and model metrics.

For detailed integration instructions, see the LangDB Agno documentation.

langdb-agno finance team observability
LangDB Finance Team Trace

Prerequisites

  1. Install Dependencies

    Ensure you have the necessary packages installed:

    uv pip install agno 'pylangdb[agno]' openai yfinance
  2. Setup LangDB Account

    • Sign up for an account at LangDB
    • Create a new project in the LangDB dashboard
    • Obtain your API key and Project ID from the project settings
  3. Set Environment Variables

    Configure your environment with the LangDB credentials:

    export LANGDB_API_KEY="<your_langdb_api_key>"
    export LANGDB_PROJECT_ID="<your_langdb_project_id>"
    export LANGDB_API_BASE_URL="https://api.us-east-1.langdb.ai"

pylangdb instrumentation rebuilds the model URL from LANGDB_API_BASE_URL, so set this explicitly even though the uninstrumented Agno adapter has a default host. Use your LangDB region's base URL.

Sending Traces to LangDB

Example: Basic Agent Setup

Instrument your Agno agent with LangDB tracing.

from pylangdb.agno import init

# Initialize LangDB tracing - must be called before creating agents
init()

from agno.agent import Agent
from agno.models.langdb import LangDB
from agno.tools.hackernews import HackerNewsTools

# Create agent with LangDB model (uses environment variables automatically)
agent = Agent(
    name="Hacker News Research Agent",
    model=LangDB(id="openai/gpt-4.1"),
    tools=[HackerNewsTools()],
    instructions="Answer questions using current Hacker News data."
)

# Use the agent
response = agent.run("What are the latest developments in AI agents?")
print(response)

Example: Multi-Agent Team Coordination

For more complex workflows, you can use Agno's Team class with LangDB tracing:

from pylangdb.agno import init
init()

from agno.agent import Agent
from agno.team import Team
from agno.models.langdb import LangDB
from agno.tools.hackernews import HackerNewsTools
from agno.tools.yfinance import YFinanceTools

# Research Agent
web_agent = Agent(
    name="Market Research Agent",
    model=LangDB(id="openai/gpt-4.1"),
    tools=[HackerNewsTools()],
    instructions="Research current market conditions and news"
)

# Financial Analysis Agent
finance_agent = Agent(
    name="Financial Analyst",
    model=LangDB(id="xai/grok-4"),
    tools=[YFinanceTools(enable_stock_price=True, enable_company_info=True)],
    instructions="Perform quantitative financial analysis"
)

# Coordinated Team
reasoning_team = Team(
    name="Finance Reasoning Team",
    model=LangDB(id="xai/grok-4"),
    members=[web_agent, finance_agent],
    instructions=[
        "Collaborate to provide comprehensive financial insights",
        "Consider both fundamental analysis and market sentiment"
    ]
)

# Execute team workflow
reasoning_team.print_response("Analyze Apple (AAPL) investment potential")

Sample Trace

View a complete example trace in the LangDB dashboard: Finance Reasoning Team Trace

langdb-agno finance team observability
LangDB Finance Team Thread

Advanced Features

LangDB Capabilities

  • Virtual Models: Save and reuse model configurations with prompts, parameters, tools, and routing logic.
  • MCP Support: Attach Model Context Protocol servers to models.
  • Multi-Provider: Route requests to OpenAI, Anthropic, Google, xAI, and other providers.

Notes

  • Initialization Order: Always call init() before creating any Agno agents or teams
  • Environment Variables: With LANGDB_API_KEY, LANGDB_PROJECT_ID, and LANGDB_API_BASE_URL set before init(), you can create models with just LangDB(id="model_name")

Resources