Skip to main content

Braintrust Google ADK integration

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

braintrust-adk

SDK for integrating Braintrust with Google ADK (Agent Development Kit). This package provides automatic tracing and logging of ADK agent executions to Braintrust.

Installation

pip install braintrust-adk

Requirements

  • Python >= 3.9
  • Google ADK >= 1.14.1

Quick Start

The braintrust-adk integration automatically traces your ADK agents' execution, including:

  • Agent invocations and responses
  • Tool calls and their results
  • Parallel execution flows
  • Multi-step agent reasoning

Basic Usage

from google.adk.agents import LlmAgent
from braintrust_adk import setup_adk

# Initialize Braintrust tracing
setup_adk(
    api_key="your-api-key",  # Or set BRAINTRUST_API_KEY env var
    project_name="my-adk-project"  # Optional: defaults to "default-google-adk-py"
)

# Create your ADK agent as normal
agent = LlmAgent(
    tools=[get_weather, get_current_time],
    model="gemini-2.0-flash-exp",
    system_instruction="You are a helpful assistant that can check weather and time."
)

# Use the agent - all interactions are automatically traced to Braintrust
response = agent.send_message("What's the weather like in New York?")
print(response.text)

Advanced Configuration

Using Project ID

If you know your Braintrust project ID, you can use it directly:

setup_adk(
    api_key="your-api-key",
    project_id="your-project-id"  # Use project ID instead of name
)

Custom Tools with Tracing

Other braintrust functions like traced work seamlessly with this integration.

from braintrust import traced

@traced
def get_weather(city: str) -> dict:
    """Get weather for a city."""
    # Your implementation here
    return {"status": "success", "temperature": 72, "city": city}

@traced
def search_flights(origin: str, destination: str, date: str) -> dict:
    """Search for flights."""
    # Your implementation here
    return {"flights": [...]}

# Create agent with multiple tools
agent = LlmAgent(
    tools=[get_weather, search_flights],
    model="gemini-2.0-flash-exp",
    system_instruction="You are a travel assistant."
)

# All tool calls are automatically traced
response = agent.send_message(
    "I need to fly from NYC to LA tomorrow. What's the weather like in LA?"
)

Manual Patching

The setup_adk will automatically patch Google ADK Runner, Agent, and Flow classes to automatically trace all agent interactions. If you prefer to manually patch classes, you can use the wrap_agent, wrap_runner, and wrap_flow functions. Take a look at the manual example.

Note that, as of writing, adk web does not support custom Runners and you will need to use setup_adk if you would like LLM traces.

Examples

The examples/ directory contains complete working examples:

Viewing Traces in Braintrust

Once you've set up the integration, you can view your traces in the Braintrust dashboard:

  1. Navigate to your project in Braintrust
  2. Click on "Logs" to see all agent executions
  3. Click on any log entry to see the full trace including:
    • Agent reasoning steps
    • Tool calls and responses
    • Token usage and latency metrics
    • Any errors or warnings

Development

To contribute to this integration:

# Clone the repository
git clone https://github.com/braintrustdata/braintrust-sdk.git
cd sdk/integrations/adk-py

uv sync

# Run examples
cd examples

# simple programmatic agent call
uv run manual.py

# or use the adk web UI
uv run adk web --port 8888

Related Resources

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

braintrust_adk-0.2.2rc1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

braintrust_adk-0.2.2rc1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file braintrust_adk-0.2.2rc1.tar.gz.

File metadata

  • Download URL: braintrust_adk-0.2.2rc1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for braintrust_adk-0.2.2rc1.tar.gz
Algorithm Hash digest
SHA256 4b01d3ac8bed0324221c09aff698494a57487970805e48485c57b869e5a84d18
MD5 096686b0d1343a1a150def61ebf18733
BLAKE2b-256 68f8610b42f9ceac3195e231f761e95b91eb14968aef0a7802eb7d160847d630

See more details on using hashes here.

File details

Details for the file braintrust_adk-0.2.2rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for braintrust_adk-0.2.2rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f1bae8b3d533ba9a55be084ecf308e6f17556565e18899754bf459782e9d3ec
MD5 688311d79a5b2bfbf0f462a4f561e341
BLAKE2b-256 ab886bfd55249cf361e21bd1702e998b87af0f79b346fbd2963f5eb629937e87

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