Skip to content

Latest commit

 

History

History
104 lines (71 loc) · 2.19 KB

File metadata and controls

104 lines (71 loc) · 2.19 KB

Google ADK Decorator Example

This example shows how to use Agent Control's @control() decorator inside a Google ADK app.

Use this example if you want ADK as the host framework but prefer Agent Control's decorator model for tool protection.

What It Demonstrates

  • @control() on ADK tool functions
  • automatic step registration from decorated functions
  • pre-tool blocking for restricted cities
  • post-tool output filtering for synthetic unsafe output
  • optional sdk-local execution without changing the agent code

Prerequisites

  1. Start the Agent Control server from the repo root:
# From repo root
make server-run
  1. Install the example dependencies:
# In separate shell
cd examples/google_adk_decorator
uv pip install -e . --upgrade
  1. Set your Google API key:
export GOOGLE_API_KEY="your-key-here"
  1. Optional environment variables:
export AGENT_CONTROL_URL=http://localhost:8000
export GOOGLE_MODEL=gemini-2.5-flash

Setup

Default server execution:

cd examples/google_adk_decorator
uv run python setup_controls.py

Optional sdk-local execution:

cd examples/google_adk_decorator
uv run python setup_controls.py --execution sdk

The example code does not change between modes. The only difference is where the controls run:

  • server - evaluation happens on the Agent Control server
  • sdk - evaluation happens locally in the Python SDK after the controls are fetched

The setup script creates namespaced controls for this example:

  • adk-decorator-block-restricted-cities
  • adk-decorator-block-internal-contact-output

Run

cd examples/google_adk_decorator
uv run adk run my_agent

Suggested Scenarios

Safe request:

What time is it in London?

Restricted city blocked before the tool call:

What is the weather in Pyongyang?

Synthetic unsafe tool output blocked after the tool call:

What time is it in Testville?

For more details on this example, see the Docs.

Tip: If you want the framework-native, attach-once ADK integration, use examples/google_adk_plugin/ instead.