> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-update-1770920925-e15dbde.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Trace Google ADK applications

This guide shows you how to trace [Google Agent Development Kit (ADK)](https://github.com/google/adk-python) agents in LangSmith. You'll configure automatic tracing for your ADK applications to capture agent invocations, tool calls, and LLM interactions.

## Installation

Install the required packages using your preferred package manager:

<CodeGroup>
  ```bash pip theme={null}
  pip install langsmith google-adk
  ```

  ```bash uv theme={null}
  uv add langsmith google-adk
  ```
</CodeGroup>

## Setup

Set your [API keys](/langsmith/create-account-api-key):

```bash theme={null}
export LANGSMITH_API_KEY=<your_langsmith_api_key>
export GOOGLE_API_KEY=<your_google_api_key>
```

To create a Google API key, refer to [Google AI Studio](https://aistudio.google.com/api-keys).

## Configure tracing

To trace ADK agents, use `configure_google_adk()` from the LangSmith SDK. Call this function once at the start of your application before creating any ADK agents:

```python theme={null}
from langsmith.integrations.google_adk import configure_google_adk

configure_google_adk(
    project_name="my-adk-project",  # Optional: defaults to LANGSMITH_PROJECT env var
)
```

The function accepts the following optional parameters:

* `project_name`: LangSmith project to send traces to. Defaults to the `LANGSMITH_PROJECT` environment variable.
* `name`: Name for the root trace. Defaults to `"google_adk.session"`.
* `metadata`: Dictionary of key-value pairs for additional context.
* `tags`: List of strings to categorize traces.

## Example

This example creates a weather agent with a tool, then runs it with tracing enabled:

```python theme={null}
from langsmith.integrations.google_adk import configure_google_adk
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types

# Configure LangSmith tracing
configure_google_adk(project_name="weather-assistant")

# Define a tool
def get_weather(city: str) -> dict:
    """Get weather for a city."""
    return {"city": city, "temperature": "72°F", "conditions": "Sunny"}

# Create the agent
agent = Agent(
    name="weather_agent",
    model="gemini-2.0-flash",
    description="Provides weather information.",
    instruction="Use the get_weather tool to answer weather questions.",
    tools=[get_weather],
)

# Set up session and runner
session_service = InMemorySessionService()
session_service.create_session_sync(
    app_name="weather_app",
    user_id="user_123",
    session_id="session_456",
)

runner = Runner(
    agent=agent,
    app_name="weather_app",
    session_service=session_service,
)

# Run the agent
events = runner.run(
    user_id="user_123",
    session_id="session_456",
    new_message=types.Content(
        role="user",
        parts=[types.Part(text="What's the weather in San Francisco?")],
    ),
)

for event in events:
    if event.is_final_response():
        print(event.content.parts[0].text)
```

## View traces in LangSmith

After running your application, you can view traces in the [LangSmith UI](https://smith.langchain.com) that include:

* **Agent invocations**: Complete flows through your ADK agents
* **Tool calls**: Individual function calls made by agents
* **LLM interactions**: Requests and responses from Gemini models
* **Multi-agent workflows**: Traces from sequential and parallel agent compositions

<img src="https://mintcdn.com/langchain-5e9cc07a-preview-update-1770920925-e15dbde/4x_4Eu33iESkLFLy/langsmith/images/adk.png?fit=max&auto=format&n=4x_4Eu33iESkLFLy&q=85&s=4c9e9f451cfb478ecf79018d4509ed85" alt="LangSmith trace view showing Google ADK agent execution" width="3022" height="1444" data-path="langsmith/images/adk.png" />

## Custom metadata and tags

Add metadata and tags when configuring tracing to categorize and filter traces:

```python theme={null}
from langsmith.integrations.google_adk import configure_google_adk

configure_google_adk(
    project_name="production-agents",
    metadata={
        "environment": "production",
        "team": "ml-platform",
    },
    tags=["adk", "weather", "v2"],
)
```

## Multi-agent workflows

The integration automatically traces multi-agent workflows including sequential and parallel agent compositions:

```python theme={null}
from langsmith.integrations.google_adk import configure_google_adk
from google.adk.agents import Agent, SequentialAgent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types

configure_google_adk(project_name="multi-agent-demo")

# Create sub-agents
translator = Agent(
    name="translator",
    model="gemini-2.0-flash",
    description="Translates text to English.",
)

summarizer = Agent(
    name="summarizer",
    model="gemini-2.0-flash",
    description="Summarizes text concisely.",
)

# Create a sequential agent that runs sub-agents in order
pipeline = SequentialAgent(
    name="translate_and_summarize",
    sub_agents=[translator, summarizer],
    description="Translates text then summarizes it.",
)

# Set up and run
session_service = InMemorySessionService()
session_service.create_session_sync(
    app_name="pipeline_app",
    user_id="user_123",
    session_id="session_456",
)

runner = Runner(
    agent=pipeline,
    app_name="pipeline_app",
    session_service=session_service,
)

events = runner.run(
    user_id="user_123",
    session_id="session_456",
    new_message=types.Content(
        role="user",
        parts=[types.Part(text="Bonjour, comment allez-vous aujourd'hui?")],
    ),
)

for event in events:
    print(event)
```

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/trace-with-google-adk.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
</Callout>

<Tip icon="terminal" iconType="regular">
  [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
</Tip>
