@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. If you want the default framework-native path, use /examples/google-adk-plugin.
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
-
Start the Agent Control server from the repo root:
-
Install the example dependencies:
-
Set your Google API key:
-
Optional environment variables:
Setup
Default server execution:server- evaluation happens on the Agent Control serversdk- evaluation happens locally in the Python SDK after the controls are fetched
adk-decorator-block-restricted-citiesadk-decorator-block-internal-contact-output
Run
Suggested Scenarios
Safe request:Files
setup_controls.py- creates the decorator example controlsmy_agent/agent.py- ADK app that wraps tools with@control().env.example- environment variables for local runs
Notes
- This example focuses on tool-level protection only.
- The guarded tool implementations are marked with tool metadata before
@control()runs. That is needed because the current Python SDK inferstoolvsllmfrom function metadata at decoration time. - If you want the recommended packaged integration, use /examples/google-adk-plugin.
- If you want the ADK-native callback integration pattern, use /examples/google-adk-callbacks.
Source Code
View the complete example with all scripts and setup instructions:Google ADK Decorator Example