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

# Google ADK

> Protect Google ADK agents with Dome content Guards or the full Trust Runtime.

<Tip>
  **TL;DR:** For content protection, wrap Dome as ADK model callbacks with `generate_adk_input_callback` and `generate_adk_output_callback`. For full Agent security (identity, tool permissions, audit), pass your ADK `Agent` to `secure_agent()`.
</Tip>

Google ADK [Agents](/owner-guide/register-agents/what-is-an-agent) expose `before_model_callback` and `after_model_callback` hooks that run immediately before and after the model is invoked. Dome plugs into both. You have two levels of protection.

## Choosing a Protection Level

<Tabs>
  <Tab title="Content Guards">
    Add Dome input and output [Guardrails](/concepts/defense/guardrail) as ADK callbacks. Install the ADK dependency first (`pip install google-adk`).

    ```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 is async-first, but ADK does not yet support async model callbacks.
    # nest_asyncio bridges the two until ADK adds async callback support.
    import nest_asyncio
    nest_asyncio.apply()

    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, protected by Dome",
        instruction="You are a friendly, question-answering AI agent.",
        before_model_callback=guard_input,
        after_model_callback=guard_output,
    )
    ```

    Both factories accept optional `blocked_message` (a custom message returned when content is blocked) and `additional_callback` (another callback to chain after Dome):

    ```python theme={null}
    guard_input = generate_adk_input_callback(
        dome,
        blocked_message="Your request was blocked by a Guardrail.",
        additional_callback=my_logging_callback,
    )
    ```
  </Tab>

  <Tab title="Trust Runtime">
    For identity attestation, tool-permission enforcement, and audit on top of content Guards, wrap the Agent with [`secure_agent()`](/concepts/defense/trust-runtime). It detects ADK automatically and injects input, output, and tool callbacks in place.

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

    agent = Agent(
        model="gemini-2.0-flash-001",
        name="travel_agent",
        instruction="You help users book travel.",
        tools=[search_flights, process_payment],
    )

    # Injects input/output Guards plus tool-permission checks (MAC).
    secure_agent(agent, agent_id="travel-agent", mode="enforce")
    ```

    The Trust Runtime adapter requires the `trust-adapters` extra (which includes `google-adk`):

    ```bash theme={null}
    pip install "vijil-dome[trust,trust-adapters]"
    ```

    In `enforce` mode, a denied tool call is short-circuited before the tool runs. In `warn` mode, the violation is logged but execution continues. See [Trust Runtime](/concepts/defense/trust-runtime) for identity and manifest details.
  </Tab>
</Tabs>

## Deployment

To deploy an ADK Agent protected with Dome, follow ADK's [Cloud Run deployment guide via the gcloud CLI](https://google.github.io/adk-docs/deploy/cloud-run/#gcloud-cli) and add `vijil-dome` to your Agent's `requirements.txt`. Use a container large enough for Dome's models: we recommend `--cpu=4 --memory=8Gi`.

<Warning>
  Deploying directly via the ADK CLI is not supported, because it does not let you set requirements or increase the container image size. The default 1 CPU / 512 MB container is insufficient for Dome's default configuration. Use 4 CPUs and 8 GiB memory.
</Warning>

<Warning>
  Dome uses the `annoy` package (the `embeddings` extra) for a fast embeddings store. `annoy` is not currently compatible with Google ADK on Cloud Run. Use the default in-memory option if you need embeddings-based Detectors. Most default configurations do not require it.
</Warning>

For a full walkthrough of guarding and deploying a multi-agent ADK setup, see the [Vijil blog post](https://www.vijil.ai/blog/protecting-google-adk-agents-with-vijil-dome).

## Next Steps

<CardGroup cols={2}>
  <Card title="Trust Runtime" icon="fingerprint" href="/concepts/defense/trust-runtime">
    Identity, tool permissions, and attestation
  </Card>

  <Card title="Configure Guardrails" icon="sliders-horizontal" href="/developer-guide/protect/configuring-guardrails">
    Choose which Guards run
  </Card>
</CardGroup>
