feat(plugins): add AgentHooksPlugin to govern ADK agents with agent-hooks - #6605
Open
prayagupa wants to merge 1 commit into
Open
feat(plugins): add AgentHooksPlugin to govern ADK agents with agent-hooks#6605prayagupa wants to merge 1 commit into
prayagupa wants to merge 1 commit into
Conversation
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Testing Plan
Unit Tests:
New suite
tests/unittests/plugins/test_agent_hooks_plugin.py(26 tests) coversthe interception-point mapping, fail-closed paths (engine error / malformed
verdict / timeout → deny), enforcement-mode fidelity (
evaluate_onlydoes nottransform), startup-deny re-enforcement at the first model call, pre/post
tool-call id correlation across arg transforms, and recursion-depth bounding of
untrusted input.
Manual End-to-End (E2E) Tests:
The change ships a runnable sample that governs a real local model (no scripted
tool output):
The support agent has two tools.
lookup_accountreturnsemail+api_key;delete_accountis destructive. A singleToolGovernanceInterceptordenies thedestructive tool and redacts the sensitive fields, and the run prints the audit
trail. Actual output:
Checklist
Additional context
Interception-point mapping (ADK callback → agent-hooks point):
before_run_callbackagent_startupon_user_message_callbackinputbefore_model_callbackpre_model_callafter_model_callbackpost_model_callbefore_tool_callbackpre_tool_callafter_tool_callbackpost_tool_callon_event_callback(final)outputafter_run_callbackagent_shutdownpre_model_callsupportsallow/denyonly; atransformthere is treatedas a fail-closed deny, because rebuilding a provider-native request from wire
messages is not round-trip safe.
security boundary — interceptors run in-process with full data access and the
interception points do not guarantee complete mediation.
src/google/adk/plugins/_agent_hooks_plugin.py(+ lazy export inplugins/__init__.py),pyproject.toml(agent-hooksextra),contributing/samples/agent_hooks/, and the unit-test suite. (9 files, +1753.)