AgentControlPlugin.
Use this example if you want the recommended, attach-once integration path for Google ADK.
What It Demonstrates
AgentControlPluginattached through an ADKAppplugin.bind(root_agent)for step discovery and registration- pre-LLM prompt injection blocking
- pre-tool restricted-city blocking
- post-tool output filtering for synthetic unsafe output
- the same app code working with either server-side or sdk-local control execution
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:adk-plugin-block-prompt-injectionadk-plugin-block-restricted-citiesadk-plugin-block-internal-contact-output
root_agent.get_current_timeroot_agent.get_weather
Run
Suggested Scenarios
Safe request:Testville is a deliberate demo trigger that makes the tool produce an internal contact note so the post-tool control can block it deterministically.
Files
setup_controls.py- creates the plugin example controlsmy_agent/agent.py- ADK app that attachesAgentControlPlugin.env.example- environment variables for local runs
Notes
plugin.bind(root_agent)runs during app startup so the example can pre-register the LLM and tool steps before the runner starts.- If you need lower-level manual lifecycle wiring, use /examples/google-adk-callbacks.
- If you want explicit per-tool
@control()protection instead of the framework-native integration, use /examples/google-adk-decorator.
Source Code
View the complete example with all scripts and setup instructions:Google ADK Plugin Example