Google ADK (Agent Development Kit) is Google’s framework for building AI agents powered by Gemini models. Braintrust automatically traces ADK agent executions, capturing agent invocations, tool calls, parallel flows, and multi-step reasoning.
Call setup_adk() to enable automatic tracing for all ADK agent interactions:
trace-adk-braintrust.py
Report incorrect code
Copy
Ask AI
import asynciofrom braintrust_adk import setup_adkfrom google.adk import Runnerfrom google.adk.agents import LlmAgentfrom google.adk.sessions import InMemorySessionServicefrom google.genai import typessetup_adk( project_name="my-adk-project",)# Create your ADK agent as normaldef get_weather(city: str) -> dict: """Get weather for a city.""" return {"temperature": 72, "condition": "sunny", "city": city}def get_current_time() -> str: """Get the current time.""" from datetime import datetime return datetime.now().strftime("%I:%M %p")async def main(): # Create the agent agent = LlmAgent( name="weather_time_assistant", tools=[get_weather, get_current_time], model="gemini-2.0-flash-exp", instruction="You are a helpful assistant that can check weather and time.", ) # Create a session service and a runner session_service = InMemorySessionService() runner = Runner(app_name="weather_app", agent=agent, session_service=session_service) # Create a fake session user_id = "user123" session_id = "session123" await session_service.create_session(app_name="weather_app", user_id=user_id, session_id=session_id) # Create the message to send new_message = types.Content( parts=[types.Part(text="What's the weather like in New York?")], role="user", ) # Run the agent with the query events = runner.run( user_id=user_id, session_id=session_id, new_message=new_message, ) # Process the events and print the agent's response for event in events: print(event)if __name__ == "__main__": asyncio.run(main())