Track and analyze your Google Agent Development Kit (ADK) AI agents with AgentOps
AgentOps provides seamless integration with Google Agent Development Kit (ADK), allowing you to track and analyze all your ADK agent interactions automatically.
Initialize AgentOps at the beginning of your application to automatically track all Google ADK agent interactions:
import asyncioimport uuidimport osfrom google.genai import typesimport agentopsfrom google.adk.agents import Agentfrom google.adk.runners import InMemoryRunnerfrom google.adk.agents.run_config import RunConfig, StreamingMode# Initialize AgentOpsagentops.init(api_key="<INSERT YOUR API KEY HERE>")# Create a simple agent with no toolsagent = Agent( name="simple_agent", model="gemini-1.5-flash", instruction="You are a helpful assistant that provides clear and concise answers.",)# Create a runnerrunner = InMemoryRunner( agent=agent, app_name="simple-example",)# Setup sessionuser_id =f"user-{uuid.uuid4().hex[:8]}"session_id =f"session-{uuid.uuid4().hex[:8]}"runner.session_service.create_session( app_name="simple-example", user_id=user_id, session_id=session_id,)# Run the agent with a user messageasyncdefrun_agent(): message ="What are three benefits of artificial intelligence?" content = types.Content( role="user", parts=[types.Part(text=message)],) run_config = RunConfig( streaming_mode=StreamingMode.NONE,)asyncfor event in runner.run_async( user_id=user_id, session_id=session_id, new_message=content, run_config=run_config,):ifhasattr(event,'content')and event.content and event.content.parts:for part in event.content.parts:ifhasattr(part,'text')and part.text:print(part.text)# Run the agentasyncio.run(run_agent())