|
| 1 | +--- |
| 2 | +catalog_title: Future AGI |
| 3 | +catalog_description: Trace, evaluate, and improve ADK agents with the traceAI OpenTelemetry integration |
| 4 | +catalog_icon: /integrations/assets/futureagi.png |
| 5 | +catalog_tags: ["observability"] |
| 6 | +--- |
| 7 | + |
| 8 | +# Future AGI observability for ADK |
| 9 | + |
| 10 | +<div class="language-support-tag"> |
| 11 | + <span class="lst-supported">Supported in ADK</span><span class="lst-python">Python</span> |
| 12 | +</div> |
| 13 | + |
| 14 | +[Future AGI](https://futureagi.com) is an observability and evaluation platform |
| 15 | +for AI agents. The |
| 16 | +[`traceai-google-adk`](https://pypi.org/project/traceai-google-adk/) package |
| 17 | +auto-instruments ADK agents and exports every agent run, model call, tool |
| 18 | +execution, and event-loop cycle to Future AGI as OpenTelemetry spans, where you |
| 19 | +can inspect the run tree, evaluate behavior, and run experiments. |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +## Overview |
| 24 | + |
| 25 | +The `traceai-google-adk` package adds OpenTelemetry instrumentation for ADK, |
| 26 | +allowing you to: |
| 27 | + |
| 28 | +- **Trace agent runs:** Capture every agent invocation, tool call, model |
| 29 | + request, and response with prompts, completions, parameters, and token usage. |
| 30 | +- **Evaluate behavior:** Run pre-built or custom evaluators against the captured |
| 31 | + traces. |
| 32 | +- **Debug agents:** Drill into hierarchical run trees to find failed tool calls, |
| 33 | + latency hotspots, and unexpected branches. |
| 34 | + |
| 35 | +## Prerequisites |
| 36 | + |
| 37 | +1. Sign up at [app.futureagi.com](https://app.futureagi.com). |
| 38 | +2. Copy your `FI_API_KEY` and `FI_SECRET_KEY` from the dashboard. |
| 39 | +3. Set the environment variables: |
| 40 | + |
| 41 | + ```bash |
| 42 | + export FI_API_KEY=<your-fi-api-key> |
| 43 | + export FI_SECRET_KEY=<your-fi-secret-key> |
| 44 | + export GOOGLE_API_KEY=<your-google-api-key> |
| 45 | + ``` |
| 46 | + |
| 47 | +## Installation |
| 48 | + |
| 49 | +```bash |
| 50 | +pip install traceai-google-adk |
| 51 | +``` |
| 52 | + |
| 53 | +The `traceai-google-adk` package declares `google-adk` and `google-genai` as |
| 54 | +runtime dependencies, so they install transitively. |
| 55 | + |
| 56 | +## Sending Traces to Future AGI |
| 57 | + |
| 58 | +Register the Future AGI tracer once at startup and attach the |
| 59 | +`GoogleADKInstrumentor` **before** running any agent. Every subsequent ADK agent |
| 60 | +invocation is captured automatically. |
| 61 | + |
| 62 | +```python |
| 63 | +import asyncio |
| 64 | + |
| 65 | +from fi_instrumentation import register |
| 66 | +from fi_instrumentation.fi_types import ProjectType |
| 67 | +from google.adk.agents import Agent |
| 68 | +from google.adk.runners import InMemoryRunner |
| 69 | +from google.genai import types |
| 70 | +from traceai_google_adk import GoogleADKInstrumentor |
| 71 | + |
| 72 | +tracer_provider = register( |
| 73 | + project_type=ProjectType.OBSERVE, |
| 74 | + project_name="adk-weather-agent", |
| 75 | +) |
| 76 | +GoogleADKInstrumentor().instrument(tracer_provider=tracer_provider) |
| 77 | + |
| 78 | + |
| 79 | +def get_weather(city: str) -> dict: |
| 80 | + """Retrieves the current weather report for a specified city.""" |
| 81 | + if city.lower() == "new york": |
| 82 | + return { |
| 83 | + "status": "success", |
| 84 | + "report": "The weather in New York is sunny with a temperature of 25°C.", |
| 85 | + } |
| 86 | + return { |
| 87 | + "status": "error", |
| 88 | + "error_message": f"Weather information for '{city}' is not available.", |
| 89 | + } |
| 90 | + |
| 91 | + |
| 92 | +agent = Agent( |
| 93 | + name="weather_agent", |
| 94 | + model="gemini-flash-latest", |
| 95 | + description="Agent to answer weather questions.", |
| 96 | + instruction="You must use the available tools to find an answer.", |
| 97 | + tools=[get_weather], |
| 98 | +) |
| 99 | + |
| 100 | + |
| 101 | +async def main(): |
| 102 | + runner = InMemoryRunner(agent=agent, app_name="weather_app") |
| 103 | + await runner.session_service.create_session( |
| 104 | + app_name="weather_app", user_id="user", session_id="session" |
| 105 | + ) |
| 106 | + async for event in runner.run_async( |
| 107 | + user_id="user", |
| 108 | + session_id="session", |
| 109 | + new_message=types.Content( |
| 110 | + role="user", |
| 111 | + parts=[types.Part(text="What is the weather in New York?")], |
| 112 | + ), |
| 113 | + ): |
| 114 | + if event.is_final_response(): |
| 115 | + print(event.content.parts[0].text.strip()) |
| 116 | + |
| 117 | + |
| 118 | +if __name__ == "__main__": |
| 119 | + asyncio.run(main()) |
| 120 | +``` |
| 121 | + |
| 122 | +## View Traces in the Dashboard |
| 123 | + |
| 124 | +Run the agent, then open your project in the [Future AGI |
| 125 | +dashboard](https://app.futureagi.com). Each ADK agent run produces a |
| 126 | +hierarchical trace with prompts, completions, model parameters, token usage, |
| 127 | +tool inputs and outputs, and event-loop cycles laid out for inspection. |
| 128 | + |
| 129 | +## Resources |
| 130 | + |
| 131 | +- [`traceai-google-adk` on PyPI](https://pypi.org/project/traceai-google-adk/) |
| 132 | +- [`traceAI` on GitHub](https://github.com/future-agi/traceAI/tree/main/python/frameworks/google-adk) |
| 133 | +- [Future AGI documentation](https://docs.futureagi.com) |
0 commit comments