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

# Google ADK

> Add Dome Guardrails to a Google ADK Agent through model callbacks.

Google ADK [Agents](/owner-guide/register-agents/what-is-an-agent) run `before_model_callback` and `after_model_callback` around every model invocation. Both callbacks scan through Dome [Guardrails](/concepts/defense/guardrail). Dome generates both callbacks from a `Dome` instance, which keeps the integration to a few lines.

## Install

```bash theme={null}
pip install "vijil-dome[local]" google-adk
```

See [Install Dome](/developer-guide/protect/installation) for the full list of extras. Add `vijil-dome[trust-adapters]` instead when you also want identity and tool access control through [Trust Runtime](/developer-guide/protect/trust-runtime).

## Guard an Agent

```python theme={null}
from google.adk.agents import Agent

from vijil_dome import Dome
from vijil_dome.integrations.adk import (
    generate_adk_input_callback,
    generate_adk_output_callback,
)

dome = Dome()

guard_input = generate_adk_input_callback(dome)
guard_output = generate_adk_output_callback(dome)

my_agent = Agent(
    model="gemini-2.0-flash-001",
    name="my_agent",
    description="An Agent built with Google ADK and protected by Dome",
    instruction="You are a friendly, question-answering AI Agent.",
    before_model_callback=guard_input,
    after_model_callback=guard_output,
)
```

Both generators accept two optional arguments:

| Argument              | Purpose                                                   |
| --------------------- | --------------------------------------------------------- |
| `blocked_message`     | Replaces the default message returned when a Guard blocks |
| `additional_callback` | Your own callback, run alongside the Dome callback        |

```python theme={null}
guard_input = generate_adk_input_callback(
    dome,
    blocked_message="I cannot help with that request.",
    additional_callback=my_own_before_model_callback,
)
```

<Note>
  Dome is asynchronous internally and ADK does not yet support asynchronous model callbacks. Apply `nest_asyncio` before you build the Agent if you hit a nested event loop error.
</Note>

## Add the Full Trust Stack

`secure_agent()` adds identity, constraints, tool-level access control, attestation, and audit events on top of the content Guards. It modifies the ADK Agent in place:

```python theme={null}
from vijil_dome import secure_agent

secure_agent(my_agent, agent_id="travel-agent", mode="enforce")
```

See [Trust Runtime](/developer-guide/protect/trust-runtime) for constraint sources and enforcement modes.

## Deploy to Cloud Run

Follow the ADK [Cloud Run deployment guide](https://google.github.io/adk-docs/deploy/cloud-run/#gcloud-cli) with the `gcloud` CLI, and add `vijil-dome` to your Agent's `requirements.txt`. Request a container large enough for the Detector models, such as `--cpu=4 --memory=8Gi`.

<Warning>
  Deploying through the ADK CLI is not supported, because it provides no way to declare extra requirements or increase the container size. Its default of 1 CPU and 512 MB is not enough for Dome's default configuration.
</Warning>

<Warning>
  The `annoy` package that backs the `embeddings` extra is not compatible with ADK Agents on Cloud Run. Use the default in-memory option when you need embeddings-based Detectors there.
</Warning>

## Next Steps

<CardGroup cols={2}>
  <Card title="Configure Guardrails" icon="sliders-horizontal" href="/developer-guide/protect/configuring-guardrails">
    Tune the Guards behind the callbacks
  </Card>

  <Card title="Trust Runtime" icon="shield-check" href="/developer-guide/protect/trust-runtime">
    Identity, tool access control, and audit events
  </Card>
</CardGroup>
