Files
Kristopher Overholt 50f7df7f46 Add Kotlin language support to ADK docs (#1768)
* Add Kotlin to hero / front page

* Add quickstart page for Kotlin

* Complete Kotlin quickstart guide and fix hero code sample (#2)

* Replace GitHub repo links with language icons in header (#3)

* Fix header icon FOUC and homepage font weight regression (#4)

* Testing staging pipeline

* Revert test edit (for staging pipeline)

* Update language icon tooltips to indicate GitHub destination (#5)

* Add link to ADK Kotlin release notes (#7)

* Initial commit of ADK Kotlin API reference docs (#6)

* Add script to generate ADK Kotlin API reference docs (#8)

* Update links and link checker ignore list (temporarily) (#9)

* Add ADK Kotlin for Android getting started guide to Advanced setup page (#10)

* Add advanced setup page with steps to "Use ADK Kotlin in Android projects"

* Update temp link checker rules

* Add placeholder folder for adk-samples (#13)

* adding linter/compilation checks for kotlin snippets (#12)

* adding linter/compilation checks for kotlin snippets

* Add Kotlin validation scripts

* Initial commit of Kotlin sample agents for adk-samples (#15)

* Adding kotlin snippet for llm agents (#16)

* Adding kotlin snippets to  Events (#17)

* Pull changes to docs/events/index.md from glaforge-kotlin-snippets

* fixing kotlin event timestamp and longRunningToolIds

* Fix language tags (#19)

* Fix language tags

* Update

* Fix wrapping

* Fix wrapping (again)

* Fix wrapping/format

* Fix language tag on integration page

* Enable check_paths in PyMdown Snippets Extension to make the build fail if a snippet can't be found (#20)

* Update mkdocs config (#21)

* Fix broken links, update URLs to adk.dev, and improve (temp) lychee config (#22)

* Add Kotlin/maven badge to README (#23)

* Adding Kotlin snippets for artifacts  (#18)

* Pull Kotlin snippets for artifacts from glaforge-kotlin-snippets

* Add comprehensive Kotlin snippets for artifacts

* Refactor artifacts documentation to use external Kotlin snippets

* Update Kotlin model to gemini-flash-latest

* Fix GCS initialization in Kotlin artifact snippet

* afixi failing test with capital-agent added to files_to_check

* Fix snippet label syntax for MkDocs build

* Configure proper Gradle project for Kotlin snippets and fix dependencies

* Add KSP support and generated sources to Kotlin snippets build

* fixing capital_agent turnComplete

* Fix syntax error in build.gradle.kts by removing invalid placeholders (#25)

* Adding Kotlin snippets to google-gemini.md (#27)

Pulling kotlin changes to google-gemini.md from glaforge-kotlin-snippets

* Add a warning about not adding an api key to production code. (#28)

* Add a warning about not adding an api key to production code.

* Update note

---------

Co-authored-by: Kristopher Overholt <koverholt@google.com>

* Add ADK Demo App sample showcasing Gemini-powered agents (#29)

This sample demonstrates how to use the Google ADK (Agent Development Kit) in an Android application to create a chat interface powered by a Gemini-based "Fun Facts" agent. The implementation features:
*   Integration with the Kotlin ADK core and processor libraries.
*   A `FunFactsAgent` defined using `LlmAgent` and the Gemini model.
*   A `ChatViewModel` utilizing `InMemoryRunner` for asynchronous message streaming.
*   A modern UI built with Jetpack Compose and Material 3.
*   Build configuration logic for secure API key management via environment variables or `local.properties`.

* Update Kotlin docs and samples to align with adk-kotlin API changes (#30)

Rename GeminiModel to Gemini, @AdkTool/@AdkParam to @Tool/@Param,
adkTools() to generatedTools(), replace DebugRunner with InMemoryRunner,
fix AgentLoader import path, use SingleAgentLoader, bump Kotlin to
2.3.21 and KSP to 2.3.7, and update Android minSdk from 24 to 26.

* adding kotlin info to READMEs (#14)

* Reorganize Android sample agent and add READMEs (#31)

* Move Android sample agent

* Update repo README, add Android README, update sample agent README

* Minor edit to language support tags (#32)

* Remove blog post link (#33)

Will re-add after it's published

* Remove examples link (#34)

* Adding Kotlin snippets for Sessions docs (#26)

* initial kotlins snippets additions to sessions docs

* Updating memory docs with kotlin snippets

* Adding kotlin snippets to session state docs.

* update model to gemini-flash-latest

* sessions examples clean-up

* fixing sessions snippet markers

* adding kotlin session snippets to files to test

* adding callback to memory_example

* Fixing capital agent snippet  (#35)

Fixing file name
Updating adkTool > Tool
Updating GeminiModel > Gemini

* Adding kotlin snippets for tools docs (#36)

* adding function tool kotlin snippets

* adding function_tools snippets to files to test

* Adding kotlin snippets to observability docs (#37)

* initial kotlin observability updates

* adding observability snippets to file check (#38)

* Adding Kotlin snippets to Callbacks docs (#39)

*  kotlin callbacks snippets

* adding callbacks snippets to file check

* Align Kotlin and KSP versions with published 0.1.0 artifacts (#40)

* switch CLI entry points from InMemoryRunner to ReplRunner (#41)

* Switch CLI entry points from InMemoryRunner to ReplRunner

* Fix wording

* Update API reference docs for Kotlin, 2026-05-18 (#42)

* Remove ADK on Android note until published (#43)

* Update Kotlin code samples (#44)

* Rename GeminiModel to Gemini in Kotlin snippets and docs

* Remove broken SessionKey call and use sessionId directly in AgentTool snippet

* Rewrite Go hero snippet to use llmagent API

* Use isFinalResponse with safe access in CapitalAgent snippet

* Use Role.USER constant instead of raw string in SetupExample

* Use full semver v0.1.0 in Kotlin language support tags

* Remove Android setup steps, moving to new property (#45)

* Tutorial Kotlin agent (#46)

* Adding multi-tool-agent snippet and updating tutorial
* Fixing Go language order on tutorial page
* adding multi tool agent example to files to test

* Inline Kotlin get-started code sample

* Kotlin Multi agents snippets (#47)

* Multi-agent kotlin snippets

* Fixing docs tags in multiagent example

* Fix Kotlin language support tags, code samples, and google-gemini.md cleanup (#48)

* Add Kotlin v0.1.0 to language support tags across docs

* Fix MultiToolAgent.kt model string and argument style

* Update MultiAgentExample.kt to use gemini-flash-latest model string

* Fix google-gemini.md: add Kotlin sample, remove unsupported Java tabs

* Remove explicit apiKey from CallbackBasic.kt for consistency

* Standardize Gemini() constructor to use named args in all snippets

* Remove adk-samples directory (moved to google/adk-samples#1969)

* Remove adk-samples directory (moved to google/adk-samples#1969) (#49)

* Update API reference docs for ADK Kotlin 0.1.0 (#50)

* Remove adk-samples directory (moved to google/adk-samples#1969)

* Update API reference docs for ADK Kotlin 0.1.0

* Remove kotlin lycheeignore config (#51)

* Remove adk-samples directory (moved to google/adk-samples#1969)

* Remove Kotlin .lycheeignore config links

---------

Co-authored-by: Toni Klopfenstein <2359976+ToniCorinne@users.noreply.github.com>
Co-authored-by: Jolanda Verhoef <JolandaVerhoef@users.noreply.github.com>
2026-05-19 11:43:42 -05:00

8.7 KiB

catalog_title, catalog_description, catalog_icon, catalog_tags
catalog_title catalog_description catalog_icon catalog_tags
AgentOps Session replays, metrics, and monitoring for ADK agents /integrations/assets/agentops.png
observability

AgentOps observability for ADK

Supported in ADKPython

With just two lines of code, AgentOps provides session replays, metrics, and monitoring for agents.

Why AgentOps for ADK?

Observability is a key aspect of developing and deploying conversational AI agents. It allows developers to understand how their agents are performing, how their agents are interacting with users, and how their agents use external tools and APIs.

By integrating AgentOps, developers can gain deep insights into their ADK agent's behavior, LLM interactions, and tool usage.

Google ADK includes its own OpenTelemetry-based tracing system, primarily aimed at providing developers with a way to trace the basic flow of execution within their agents. AgentOps enhances this by offering a dedicated and more comprehensive observability platform with:

  • Unified Tracing and Replay Analytics: Consolidate traces from ADK and other components of your AI stack.
  • Rich Visualization: Intuitive dashboards to visualize agent execution flow, LLM calls, and tool performance.
  • Detailed Debugging: Drill down into specific spans, view prompts, completions, token counts, and errors.
  • LLM Cost and Latency Tracking: Track latencies, costs (via token usage), and identify bottlenecks.
  • Simplified Setup: Get started with just a few lines of code.

AgentOps Agent Observability Dashboard

AgentOps Dashboard showing an ADK trace with nested agent, LLM, and tool spans.

AgentOps dashboard displaying a trace from a multi-step ADK application execution. You can see the hierarchical structure of spans, including the main agent workflow, individual sub-agents, LLM calls, and tool executions. Note the clear hierarchy: the main workflow agent span contains child spans for various sub-agent operations, LLM calls, and tool executions.

Getting Started with AgentOps and ADK

Integrating AgentOps into your ADK application is straightforward:

  1. Install AgentOps:

    pip install -U agentops
    
  2. Create an API Key Create a user API key here: Create API Key and configure your environment:

    Add your API key to your environment variables:

    AGENTOPS_API_KEY=<YOUR_AGENTOPS_API_KEY>
    
  3. Initialize AgentOps: Add the following lines at the beginning of your ADK application script (e.g., your main Python file running the ADK Runner):

    import agentops
    agentops.init()
    

    This will initiate an AgentOps session as well as automatically track ADK agents.

    Detailed example:

    import agentops
    import os
    from dotenv import load_dotenv
    
    # Load environment variables (optional, if you use a .env file for API keys)
    load_dotenv()
    
    agentops.init(
        api_key=os.getenv("AGENTOPS_API_KEY"), # Your AgentOps API Key
        trace_name="my-adk-app-trace"  # Optional: A name for your trace
        # auto_start_session=True is the default.
        # Set to False if you want to manually control session start/end.
    )
    

    🚨 🔑 You can find your AgentOps API key on your AgentOps Dashboard after signing up. It's recommended to set it as an environment variable (AGENTOPS_API_KEY).

Once initialized, AgentOps will automatically begin instrumenting your ADK agent.

This is all you need to capture all telemetry data for your ADK agent

How AgentOps Instruments ADK

AgentOps employs a sophisticated strategy to provide seamless observability without conflicting with ADK's native telemetry:

  1. Neutralizing ADK's Native Telemetry: AgentOps detects ADK and intelligently patches ADK's internal OpenTelemetry tracer (typically trace.get_tracer('gcp.vertex.agent')). It replaces it with a NoOpTracer, ensuring that ADK's own attempts to create telemetry spans are effectively silenced. This prevents duplicate traces and allows AgentOps to be the authoritative source for observability data.

  2. AgentOps-Controlled Span Creation: AgentOps takes control by wrapping key ADK methods to create a logical hierarchy of spans:

    • Agent Execution Spans (e.g., adk.agent.MySequentialAgent): When an ADK agent (like BaseAgent, SequentialAgent, or LlmAgent) starts its run_async method, AgentOps initiates a parent span for that agent's execution.

    • LLM Interaction Spans (e.g., adk.llm.gemini-pro): For calls made by an agent to an LLM (via ADK's BaseLlmFlow._call_llm_async), AgentOps creates a dedicated child span, typically named after the LLM model. This span captures request details (prompts, model parameters) and, upon completion (via ADK's _finalize_model_response_event), records response details like completions, token usage, and finish reasons.

    • Tool Usage Spans (e.g., adk.tool.MyCustomTool): When an agent uses a tool (via ADK's functions.__call_tool_async), AgentOps creates a single, comprehensive child span named after the tool. This span includes the tool's input parameters and the result it returns.

  3. Rich Attribute Collection: AgentOps reuses ADK's internal data extraction logic. It patches ADK's specific telemetry functions (e.g., google.adk.telemetry.trace_tool_call, trace_call_llm). The AgentOps wrappers for these functions take the detailed information ADK gathers and attach it as attributes to the currently active AgentOps span.

Visualizing Your ADK Agent in AgentOps

When you instrument your ADK application with AgentOps, you gain a clear, hierarchical view of your agent's execution in the AgentOps dashboard.

  1. Initialization: When agentops.init() is called (e.g., agentops.init(trace_name="my_adk_application")), an initial parent span is created if the init param auto_start_session=True (true by default). This span, often named similar to my_adk_application.session, will be the root for all operations within that trace.

  2. ADK Runner Execution: When an ADK Runner executes a top-level agent (e.g., a SequentialAgent orchestrating a workflow), AgentOps creates a corresponding agent span under the session trace. This span will reflect the name of your top-level ADK agent (e.g., adk.agent.YourMainWorkflowAgent).

  3. Sub-Agent and LLM/Tool Calls: As this main agent executes its logic, including calling sub-agents, LLMs, or tools:

    • Each sub-agent execution will appear as a nested child span under its parent agent.
    • Calls to Large Language Models will generate further nested child spans (e.g., adk.llm.<model_name>), capturing prompt details, responses, and token usage.
    • Tool invocations will also result in distinct child spans (e.g., adk.tool.<your_tool_name>), showing their parameters and results.

This creates a waterfall of spans, allowing you to see the sequence, duration, and details of each step in your ADK application. All relevant attributes, such as LLM prompts, completions, token counts, tool inputs/outputs, and agent names, are captured and displayed.

For a practical demonstration, you can explore a sample Jupyter Notebook that illustrates a human approval workflow using Google ADK and AgentOps: Google ADK Human Approval Example on GitHub.

This example showcases how a multi-step agent process with tool usage is visualized in AgentOps.

Benefits

  • Effortless Setup: Minimal code changes for comprehensive ADK tracing.
  • Deep Visibility: Understand the inner workings of complex ADK agent flows.
  • Faster Debugging: Quickly pinpoint issues with detailed trace data.
  • Performance Optimization: Analyze latencies and token usage.

By integrating AgentOps, ADK developers can significantly enhance their ability to build, debug, and maintain robust AI agents.

Further Information

To get started, create an AgentOps account. For feature requests or bug reports, please reach out to the AgentOps team on the AgentOps Repo.

🐦 X • 📢 Discord • 🖇️ AgentOps Dashboard • 📙 Documentation