Skip to main content
Google’s Agent Development Kit (ADK) is a flexible, model-agnostic framework for building and orchestrating agents. While optimized for Gemini, ADK supports any model and both simple tasks and complex multi-agent workflows. Weave automatically traces agents built with ADK, including each agent invocation, sub-agent handoff, model call, and tool call. Weave displays the captured data in the Agents view of your project.

Trace Google ADK agents with Weave

The Weave SDK autopatches with Google ADK for Python so you can capture traces from your ADK agents with minimal setup. This guide shows how to initialize Weave and then run a multi-turn research agent built with Google ADK so that Weave captures every agent invocation, model call, and tool call across the session.

Prerequisites

  • A W&B account and API key set as a WANDB_API_KEY environment variable.
  • A Google API key for Gemini.
  • Python 3.10+.

Install packages

Install the following packages in your developer environment. These provide the Weave SDK, the Google ADK framework, and the HTTP client used by the example tool.
pip install weave google-adk requests

Initialize Weave in your code

Add weave.init to the project, along with your W&B team and project names, and then build an agent the way you normally would. The following code creates a research_assistant agent that uses gemini-2.5-flash and a wikipedia_search tool, then runs three questions through a single ADK session while Weave captures the trace.
import asyncio
import requests
import weave
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
from google.genai import types

weave.init("<your-team>/<your-project-name>")

def wikipedia_search(query: str) -> dict:
    """Search Wikipedia for a topic and return its title and intro paragraph.

    Args:
        query: The topic to search for.

    Returns:
        A dictionary with the article title and intro extract.
    """
    r = requests.get(
        "https://en.wikipedia.org/w/api.php",
        params={
            "action": "query", "generator": "search", "gsrsearch": query, "gsrlimit": 1,
            "prop": "extracts", "exintro": True, "explaintext": True, "format": "json",
        },
        headers={"User-Agent": "weave-demo"},
    ).json()
    page = next(iter(r["query"]["pages"].values()))
    return {"title": page["title"], "extract": page["extract"]}

agent = Agent(
    name="research_assistant",
    model="gemini-2.5-flash",
    instruction=(
        "You are a research assistant. Use the wikipedia_search tool to look up "
        "topics when needed, and cite the article titles you used."
    ),
    tools=[wikipedia_search],
)

async def main():
    runner = InMemoryRunner(agent=agent, app_name="research-app")
    session = await runner.session_service.create_session(
        app_name="research-app", user_id="user-1"
    )

    questions = [
        "Who founded Anthropic?",
        "What is Claude (the AI assistant)?",
        "Summarize what we discussed in one sentence.",
    ]

    for question in questions:
        print(f"USER: {question}")
        async for event in runner.run_async(
            user_id="user-1",
            session_id=session.id,
            new_message=types.Content(
                role="user",
                parts=[types.Part(text=question)],
            ),
        ):
            if event.is_final_response() and event.content:
                print(f"AGENT: {event.content.parts[0].text}\n")

asyncio.run(main())
The example runs three turns in a single ADK session. The first two turns trigger Wikipedia lookups, and the third uses the previous conversation context to produce a summary without a tool call.

See your agent traces in the Agents view

After the script runs, weave.init() prints a link to your project. Open the Agents view to inspect:
  • A session containing the conversation’s turns.
  • Each turn rendered as an invoke_agent span with nested chat and execute_tool children.
  • The full input, model, output, token usage, and tool results at each step.
For details about viewing Agents data in Weave, see View agent activity.