> ## Documentation Index
> Fetch the complete documentation index at: https://docs.freeplay.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Agent Development Kit (ADK)

> Integrate Google's Agent Development Kit with Freeplay for agent observability and evaluation.

# Google Agent Observability and Evaluation with Freeplay

See Google's Guide [here](https://google.github.io/adk-docs/observability/freeplay/).

We provide an end-to-end integrated workflow for building and optimizing AI agents with Google's ADK. With ADK and Freeplay your whole team can easily collaborate to iterate on agent instructions (prompts), experiment with and compare different models and agent changes, run evals both offline and online to measure quality, monitor production, and review data by hand.

Key benefits of connecting Freeplay:

* **Simple observability** - focused on agents, LLM calls and tool calls for easy human review
* **Online evals/automated scorers** - for error detection in production
* **Offline evals and experiment comparison** - to test changes before deploying
* **Prompt management** - supports pushing changes straight from the Freeplay playground to code
* **Human review workflow** - for collaboration on error analysis and data annotation
* **Powerful UI** - makes it possible for domain experts to collaborate closely with engineers

Freeplay and Google's ADK complement one another. ADK gives you a powerful and expressive agent orchestration framework while Freeplay plugs in for observability, prompt management, evaluation and testing. Once you integrate with Freeplay, you can update prompts and evals from the Freeplay UI or from code, so that anyone on your team can contribute.

<iframe src="https://www.loom.com/embed/82f41ffde94949beb941cb191f53c3ec" title="Loom video player" frameborder="0" className="w-full aspect-video rounded-xl" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

## Getting Started

Below is a guide for getting started with Freeplay and ADK. You can also find a full sample ADK agent repo [here](https://github.com/228Labs/freeplay-google-demo).

### Create a Freeplay Account

Sign up for a free [Freeplay account](https://freeplay.ai/signup) .

After creating an account, you can define the following environment variables:

```
FREEPLAY_PROJECT_ID=
FREEPLAY_API_KEY=
FREEPLAY_API_URL=
```

### Use Freeplay ADK Library

Install the Freeplay ADK library:

<CodeGroup>
  ```bash theme={null}
  pip install freeplay-python-adk
  ```
</CodeGroup>

Freeplay will automatically capture OTel logs from your ADK application when you initialize observability:

<CodeGroup>
  ```python python theme={null}
  from freeplay_python_adk.client import FreeplayADK
  FreeplayADK.initialize_observability()
  ```
</CodeGroup>

You'll also want to pass in the Freeplay plugin to your App:

<CodeGroup>
  ```python python theme={null}
  from app.agent import root_agent
  from freeplay_python_adk.freeplay_observability_plugin import FreeplayObservabilityPlugin
  from google.adk.runners import App

  app = App(
      name="app",
      root_agent=root_agent,
      plugins=[FreeplayObservabilityPlugin()],
  )

  __all__ = ["app"]
  ```
</CodeGroup>

You can now use ADK as you normally would, and you will see logs flowing to Freeplay in the Observability section.

## Observability

Freeplay's Observability feature gives you a clear view into how your agent is behaving in production. You can dig into to individual agent traces to understand each step and diagnose issues:

<img src="https://mintcdn.com/freeplay-485a287e/CgjLL0ybwTxi2RvX/images/ca79ef9074b3c1ba8d95309a398ea968da45c1cf86312fc2648cc5c47fc0ff04-image.png?fit=max&auto=format&n=CgjLL0ybwTxi2RvX&q=85&s=5865c888106f8c71009a6e52bc0173f1" alt="" width="2908" height="1702" data-path="images/ca79ef9074b3c1ba8d95309a398ea968da45c1cf86312fc2648cc5c47fc0ff04-image.png" />

You can also use Freeplay's search functionality to filter the data across any segment of interest:

<img src="https://mintcdn.com/freeplay-485a287e/X8uH3NfMBEz8W97Z/images/5ea1bc1411e4df94774a4019e641d43beadbb82873f0d16cb1d7ce743e82ca78-image.png?fit=max&auto=format&n=X8uH3NfMBEz8W97Z&q=85&s=3686e22e9a781a1249ba906779dfa15a" alt="" width="2862" height="1684" data-path="images/5ea1bc1411e4df94774a4019e641d43beadbb82873f0d16cb1d7ce743e82ca78-image.png" />

## Prompt Management (optional)

Freeplay offers [native prompt management](/core-concepts/prompt-management/managing-prompts) , which simplifies the process of version and testing different prompt versions. It allows you to experiment with changes to ADK agent instructions in the Freeplay UI, test different models, and push updates straight to your code, similar to a feature flag.

To leverage Freeplay's prompt management capabilities alongside ADK, you'll want to use the Freeplay ADK agent wrapper. `FreeplayLLMAgent` extends ADK's base `LlmAgent` class, so instead of having to hard code your prompts as agent instructions, you can version prompts in the Freeplay application.

<img src="https://mintcdn.com/freeplay-485a287e/X8uH3NfMBEz8W97Z/images/29794edcda9a6b39cec5d8b2fde2e1497d8db4566a1da579cd78e79dcfe0a9a4-image.png?fit=max&auto=format&n=X8uH3NfMBEz8W97Z&q=85&s=5dba37a05d425afcdf27d00724762e53" alt="" width="2874" height="1700" data-path="images/29794edcda9a6b39cec5d8b2fde2e1497d8db4566a1da579cd78e79dcfe0a9a4-image.png" />

First define a prompt in Freeplay by going to Prompts -> Create prompt template:

When creating your prompt template you'll need to add 3 elements, as described in the following sections:

### System Message

This corresponds to the "instructions" section in your code.

### Agent Context Variable

Adding the following to the bottom of your system message will create a variable for the ongoing agent context to be passed through:

<CodeGroup>
  ```python python theme={null}
  {{agent_context}}
  ```
</CodeGroup>

### History Block

Click new message and change the role to 'history'. This will ensure the past messages are passed through when present.

<img src="https://mintcdn.com/freeplay-485a287e/CgjLL0ybwTxi2RvX/images/c0961fbce808f8a506572aae7c21dc250b9f11c9eb1261a4c5f90c5dc0f07a5c-image.png?fit=max&auto=format&n=CgjLL0ybwTxi2RvX&q=85&s=60c6858b460dadb52879050fbc86311b" alt="" width="2146" height="814" data-path="images/c0961fbce808f8a506572aae7c21dc250b9f11c9eb1261a4c5f90c5dc0f07a5c-image.png" />

Now in your code you can use the `FreeplayLLMAgent`:

<CodeGroup>
  ```python python theme={null}
  from freeplay_python_adk.client import FreeplayADK
  from freeplay_python_adk.freeplay_llm_agent import (
      FreeplayLLMAgent,
  )

  FreeplayADK.initialize_observability()

  root_agent = FreeplayLLMAgent(
      name="social_product_researcher",
      tools=[tavily_search],
  )
  ```
</CodeGroup>

When the `social_product_researcher` is invoked, the prompt will be retrieved from Freeplay and formatted with the proper input variables.

## Evaluation

Freeplay enables you to define, version, and run [evaluations](/core-concepts/evaluations/evaluations) from the Freeplay web application. You can define evaluations for any of your prompts or agents by going to Evaluations -> "New evaluation".

<img src="https://mintcdn.com/freeplay-485a287e/X8uH3NfMBEz8W97Z/images/09f633ba22b98775d84df87e1124ad9eb9053f673be35d5cf14f741cda0a1385-image.png?fit=max&auto=format&n=X8uH3NfMBEz8W97Z&q=85&s=4c7e4d795db18df5b918dcca2ced9f52" alt="" width="2322" height="1640" data-path="images/09f633ba22b98775d84df87e1124ad9eb9053f673be35d5cf14f741cda0a1385-image.png" />

These evaluations can be configured to run for both online monitoring and offline evaluation. Datasets for offline evaluation can be uploaded to Freeplay or saved from log examples.

## Dataset Management

As you get data flowing into Freeplay, you can use these logs to start building up [datasets](/core-concepts/datasets/datasets) to test against on a repeated basis. Use production logs to create golden datasets or collections of failure cases that you can use to test against as you make changes.

<img src="https://mintcdn.com/freeplay-485a287e/X8uH3NfMBEz8W97Z/images/48a0ff399463f411432d6cd804e2be7edebb31ff42b2293146af11ee44ae65d5-image.png?fit=max&auto=format&n=X8uH3NfMBEz8W97Z&q=85&s=c9bf2ce1d975c57738f835c7964ec36b" alt="" width="2982" height="1694" data-path="images/48a0ff399463f411432d6cd804e2be7edebb31ff42b2293146af11ee44ae65d5-image.png" />

## Batch Testing

As you iterate on your agent, you can run batch tests (i.e., offline experiments) at both the [prompt](/core-concepts/test-runs/component-level-test-runs) and [end-to-end](/core-concepts/test-runs/end-to-end-test-runs) agent level. This allows you to compare multiple different models or prompt changes and quantify changes head to head across your full agent execution.

[Here](https://github.com/228Labs/freeplay-google-demo/blob/main/examples/example_test_run.py) is a code example for executing a batch test on Freeplay with ADK. [Here](https://github.com/228Labs/freeplay-google-demo/blob/main/examples/example_test_run.py) is a code example for executing a batch test on Freeplay with the Google ADK.

## Sign up now

Go to [Freeplay](https://freeplay.ai/) to sign up for an account, and check out a full Freeplay ADK Integration [here](https://github.com/228Labs/freeplay-google-demo).
