Skip to main content

Comprehensive Google ADK integration package for LangDB with enhanced agents, LLM integration, and distributed tracing.

Project description

LangDB ADK - Agent Development Kit for LangDB

A comprehensive Google ADK (Agent Development Kit) integration package for LangDB. This package provides seamless integration of LangDB's LLM capabilities, enhanced agent functionality, and distributed tracing into the Google ADK framework.

Features

  • LangDBLlm: Native integration with Google ADK's BaseLlm interface
  • LangDBAgent: Enhanced agent class with automatic LangDB callbacks and session management
  • LangDBTracing: Distributed tracing integration with OpenTelemetry
  • Session tracking and thread management across agent invocations
  • Comprehensive callback system for model, agent, and tool interactions

Installation

pip install langdb_adk

Usage with Google ADK

Basic Usage with LangDBAgent

import os
import asyncio
from langdb_adk import LangDBLlm, LangDBAgent, LangDBTracing
from google.adk.runners import InMemoryRunner

# Initialize tracing (optional but recommended)
LangDBTracing(collector_endpoint="https://api.staging.langdb.ai:4317")

async def main():
    # Create a LangDB agent with automatic callbacks and session management
    agent = LangDBAgent(
        model=LangDBLlm(model="openai/gpt-4.1"),
        name="my_agent",
        description="A simple agent with LangDB integration",
        instruction="You are a helpful assistant."
    )
    
    # Create a runner to execute the agent
    runner = InMemoryRunner()
    
    # Run the agent with a prompt
    response = await runner.run(agent, "Hello, how are you?")
    print(response.text)

if __name__ == "__main__":
    asyncio.run(main())

Basic Usage with Standard Agent (Legacy)

from langdb_adk import LangDBLlm, LangDBAgent
from langdb_adk import LangDBTracing
LangDBTracing()


root_agent = LangDBAgent(
    model=LangDBLlm(model="openai/gpt-4.1"),
    name="root_agent",
    description="A Travel Conceirge using the services of multiple sub-agents",
    instruction="You are a travel concierge that coordinates with specialist agents.",
)

Complete Example with Sub-Agents and Tracing

from langdb_adk import LangDBLlm, LangDBAgent, LangDBTracing

# Initialize tracing with LangDB collector
LangDBTracing()

# Create sub-agents for different capabilities
planning_agent = LangDBAgent(
    model=LangDBLlm(model="openai/gpt-4.1"),
    name="planning_agent",
    description="Handles travel planning tasks",
    instruction="You help users plan their travel itineraries."
)

booking_agent = LangDBAgent(
    model=LangDBLlm(model="openai/gpt-4.1"),
    name="booking_agent", 
    description="Handles travel booking tasks",
    instruction="You help users book flights, hotels, and activities."
)

# Create main agent with sub-agents
root_agent = LangDBAgent(
    model=LangDBLlm(model="openai/gpt-4.1"),
    name="root_agent",
    description="A Travel Concierge using multiple sub-agents",
    instruction="You are a travel concierge that coordinates with specialist agents.",
    sub_agents=[planning_agent, booking_agent]
)

With MCP Servers

# Configure MCP servers for LangDB
mcp_servers = [
    {
        "server_url": "server_url",
        "type": "sse",
        "name": "search",
        "description": "Web search capabilities via DuckDuckGo"
    }
]


    # Initialize the LangDB LLM with MCP servers
llm = LangDBLlm(
        model="anthropic/claude-sonnet-4",
        api_key=os.getenv("LANGDB_API_KEY"),
        project_id=os.getenv("LANGDB_PROJECT_ID"),
        mcp_servers=mcp_servers
    )
    
    # Create a LangDB agent with MCP capabilities
root_agent = LangDBAgent(
        model=llm,
        name="search_agent",
        description="Agent with web search capabilities")

Configuration

Environment Variables

  • LANGDB_API_KEY: Your LangDB API key (required)
  • LANGDB_PROJECT_ID: Your LangDB project ID (required)
  • LANGDB_TRACING_BASE_URL: Custom tracing collector endpoint (optional, defaults to https://api.us-east-1.langdb.ai:4317)

LangDBLlm Parameters

  • model: The name of the model to use (e.g., "anthropic/claude-sonnet-4", "openai/gpt-4.1")
  • api_key: Your LangDB API key (defaults to LANGDB_API_KEY env var)
  • project_id: Your LangDB project ID (defaults to LANGDB_PROJECT_ID env var)
  • extra_headers: Additional headers to include in requests
  • mcp_servers: List of MCP server configurations for extended capabilities

LangDBTracing Parameters

  • collector_endpoint: OpenTelemetry collector endpoint (defaults to LANGDB_TRACING_BASE_URL or https://api.us-east-1.langdb.ai:4317)
  • api_key: Your LangDB API key (defaults to LANGDB_API_KEY env var)
  • project_id: Your LangDB project ID (defaults to LANGDB_PROJECT_ID env var)
  • client_name: Client identifier for tracing (defaults to "adk" for LangDBAdkTracing)

Advanced Features

Session Management

LangDBAgent automatically manages session tracking across agent invocations:

  • Thread ID: Maintains consistent session IDs across agent calls within the same conversation
  • Invocation Tracking: Tracks sequence of invocations for debugging and analytics
  • State Persistence: Maintains state across callbacks and sub-agent interactions

Distributed Tracing

LangDBTracing provides comprehensive observability through OpenTelemetry:

  • Automatic Span Creation: Traces all agent, model, and tool interactions
  • Attribute Mapping: Maps ADK attributes to LangDB-specific attributes
  • Session Correlation: Links spans across different agents using consistent thread IDs
  • Run ID Tracking: Provides unique run identifiers for each execution

Custom Tracing Setup

from langdb_adk import LangDBTracing

# Use default endpoints and credentials from environment
tracing = LangDBTracing()

# Or configure custom settings
tracing = LangDBTracing(
    collector_endpoint="https://custom-collector.example.com:4317",
    api_key="your-api-key",
    project_id="your-project-id",
    client_name="adk"
)

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgements

  • Google ADK Team for the Agent Development Kit
  • OpenTelemetry community for distributed tracing standards

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langdb_adk-0.1.13.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langdb_adk-0.1.13-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file langdb_adk-0.1.13.tar.gz.

File metadata

  • Download URL: langdb_adk-0.1.13.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.3

File hashes

Hashes for langdb_adk-0.1.13.tar.gz
Algorithm Hash digest
SHA256 846b18b2ff85fa01cb4d2d0a0693076b2f1de898ec4ac1641567f76988d9fd19
MD5 e79396a5d1ad9941a56433dd88a516c3
BLAKE2b-256 0491d76d7e88bc7249e4c7c04bec364d5f5a85f43f0e0ccdeff820886ef4e13e

See more details on using hashes here.

File details

Details for the file langdb_adk-0.1.13-py3-none-any.whl.

File metadata

File hashes

Hashes for langdb_adk-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 36ed5c3886570c3019096776bdf2b6f3632dbcfb62c8b6af29f354dbbd83c25e
MD5 1ccf2c0afe79c7b867eb81d7c7345525
BLAKE2b-256 d82ddd6869e7943f8e4a111fc09e3b0d6c3a0c98a26b5bd0778c454315bd27f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page