braintrust-adk


Namebraintrust-adk JSON
Version 0.2.3 PyPI version JSON
download
home_pageNone
SummaryBraintrust Google ADK integration
upload_time2025-11-04 01:48:36
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseApache-2.0
keywords braintrust google-adk adk agents ai llm tracing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # braintrust-adk

SDK for integrating [Braintrust](https://braintrust.dev) with [Google ADK (Agent Development Kit)](https://github.com/google/adk-python). This package provides automatic tracing and logging of ADK agent executions to Braintrust.

## Installation

```bash
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

```python
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:

```python
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.

```python
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](./examples/manual.py).

Note that, as of writing, `adk web` does not support [custom Runners](https://github.com/google/adk-web/issues/72) 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](https://braintrust.dev)
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:

```bash
# 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

- [Braintrust Documentation](https://www.braintrust.dev/docs)
- [Google ADK Documentation](https://github.com/google/genai-agent-dev-kit)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "braintrust-adk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "braintrust, google-adk, adk, agents, ai, llm, tracing",
    "author": null,
    "author_email": "Braintrust <info@braintrust.dev>",
    "download_url": "https://files.pythonhosted.org/packages/fb/43/bcea76e53dffdd54f71aaaf2c982a1a6bd2475a2e8de1d28da0e822846c8/braintrust_adk-0.2.3.tar.gz",
    "platform": null,
    "description": "# braintrust-adk\n\nSDK for integrating [Braintrust](https://braintrust.dev) with [Google ADK (Agent Development Kit)](https://github.com/google/adk-python). This package provides automatic tracing and logging of ADK agent executions to Braintrust.\n\n## Installation\n\n```bash\npip install braintrust-adk\n```\n\n## Requirements\n\n- Python >= 3.9\n- Google ADK >= 1.14.1\n\n## Quick Start\n\nThe `braintrust-adk` integration automatically traces your ADK agents' execution, including:\n\n- Agent invocations and responses\n- Tool calls and their results\n- Parallel execution flows\n- Multi-step agent reasoning\n\n### Basic Usage\n\n```python\nfrom google.adk.agents import LlmAgent\nfrom braintrust_adk import setup_adk\n\n# Initialize Braintrust tracing\nsetup_adk(\n    api_key=\"your-api-key\",  # Or set BRAINTRUST_API_KEY env var\n    project_name=\"my-adk-project\"  # Optional: defaults to \"default-google-adk-py\"\n)\n\n# Create your ADK agent as normal\nagent = LlmAgent(\n    tools=[get_weather, get_current_time],\n    model=\"gemini-2.0-flash-exp\",\n    system_instruction=\"You are a helpful assistant that can check weather and time.\"\n)\n\n# Use the agent - all interactions are automatically traced to Braintrust\nresponse = agent.send_message(\"What's the weather like in New York?\")\nprint(response.text)\n```\n\n### Advanced Configuration\n\n#### Using Project ID\n\nIf you know your Braintrust project ID, you can use it directly:\n\n```python\nsetup_adk(\n    api_key=\"your-api-key\",\n    project_id=\"your-project-id\"  # Use project ID instead of name\n)\n```\n\n#### Custom Tools with Tracing\n\nOther braintrust functions like `traced` work seamlessly with this integration.\n\n```python\nfrom braintrust import traced\n\n@traced\ndef get_weather(city: str) -> dict:\n    \"\"\"Get weather for a city.\"\"\"\n    # Your implementation here\n    return {\"status\": \"success\", \"temperature\": 72, \"city\": city}\n\n@traced\ndef search_flights(origin: str, destination: str, date: str) -> dict:\n    \"\"\"Search for flights.\"\"\"\n    # Your implementation here\n    return {\"flights\": [...]}\n\n# Create agent with multiple tools\nagent = LlmAgent(\n    tools=[get_weather, search_flights],\n    model=\"gemini-2.0-flash-exp\",\n    system_instruction=\"You are a travel assistant.\"\n)\n\n# All tool calls are automatically traced\nresponse = agent.send_message(\n    \"I need to fly from NYC to LA tomorrow. What's the weather like in LA?\"\n)\n```\n\n### Manual Patching\n\nThe `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](./examples/manual.py).\n\nNote that, as of writing, `adk web` does not support [custom Runners](https://github.com/google/adk-web/issues/72) and you will need to use `setup_adk` if you would like LLM traces.\n\n## Examples\n\nThe `examples/` directory contains complete working examples:\n\n## Viewing Traces in Braintrust\n\nOnce you've set up the integration, you can view your traces in the Braintrust dashboard:\n\n1. Navigate to your project in [Braintrust](https://braintrust.dev)\n2. Click on \"Logs\" to see all agent executions\n3. Click on any log entry to see the full trace including:\n   - Agent reasoning steps\n   - Tool calls and responses\n   - Token usage and latency metrics\n   - Any errors or warnings\n\n## Development\n\nTo contribute to this integration:\n\n```bash\n# Clone the repository\ngit clone https://github.com/braintrustdata/braintrust-sdk.git\ncd sdk/integrations/adk-py\n\nuv sync\n\n# Run examples\ncd examples\n\n# simple programmatic agent call\nuv run manual.py\n\n# or use the adk web UI\nuv run adk web --port 8888\n```\n\n## Related Resources\n\n- [Braintrust Documentation](https://www.braintrust.dev/docs)\n- [Google ADK Documentation](https://github.com/google/genai-agent-dev-kit)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Braintrust Google ADK integration",
    "version": "0.2.3",
    "project_urls": {
        "Homepage": "https://www.braintrust.dev",
        "Repository": "https://github.com/braintrustdata/braintrust-sdk"
    },
    "split_keywords": [
        "braintrust",
        " google-adk",
        " adk",
        " agents",
        " ai",
        " llm",
        " tracing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c45b0b3b5dbde82f09245859e520003e1cfd0bcd4c5eaf023a1c38d8e76cd915",
                "md5": "63d43c0ea884d65a2e801fb8ae024c9c",
                "sha256": "6bdbf8059fc3b81ef89dd49578b52729f7f6fee3140ecf8c8c1f29fcd0d1a928"
            },
            "downloads": -1,
            "filename": "braintrust_adk-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "63d43c0ea884d65a2e801fb8ae024c9c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 19455,
            "upload_time": "2025-11-04T01:48:35",
            "upload_time_iso_8601": "2025-11-04T01:48:35.868199Z",
            "url": "https://files.pythonhosted.org/packages/c4/5b/0b3b5dbde82f09245859e520003e1cfd0bcd4c5eaf023a1c38d8e76cd915/braintrust_adk-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fb43bcea76e53dffdd54f71aaaf2c982a1a6bd2475a2e8de1d28da0e822846c8",
                "md5": "aa5514f617cb9f24e05ff58ec6861825",
                "sha256": "ac9ba87ba2c9975767ada16f18ce139de929a662945c7172400d64ac8e7044e6"
            },
            "downloads": -1,
            "filename": "braintrust_adk-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "aa5514f617cb9f24e05ff58ec6861825",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 20093,
            "upload_time": "2025-11-04T01:48:36",
            "upload_time_iso_8601": "2025-11-04T01:48:36.766557Z",
            "url": "https://files.pythonhosted.org/packages/fb/43/bcea76e53dffdd54f71aaaf2c982a1a6bd2475a2e8de1d28da0e822846c8/braintrust_adk-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-04 01:48:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "braintrustdata",
    "github_project": "braintrust-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "braintrust-adk"
}
        
Elapsed time: 2.52233s