feat: add Agent Governance Toolkit sample — policy enforcement for ADK agents#117
feat: add Agent Governance Toolkit sample — policy enforcement for ADK agents#117imran-siddique wants to merge 4 commits intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
| @@ -0,0 +1,125 @@ | |||
| # Copyright 2026 Microsoft Corporation | |||
There was a problem hiding this comment.
We can have a plugins/ folder under src/google/adk_community to host the plugin
| @@ -0,0 +1,125 @@ | |||
| # Copyright 2026 Microsoft Corporation | |||
|
Hi @hangfei @Jacksunwei — friendly ping for a review when you get a chance. Happy to address any feedback. Thanks! |
|
Hi @imran-siddique , I already left some comments and those haven't been addressed |
|
@gemini-cli /review |
|
🤖 Hi @DeanChensj, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
Thank you for the contribution! The integration with the Agent Governance Toolkit is a great addition.
However, I've identified a few issues that should be addressed:
- Security (Fail-Open): The plugin currently allows all tool calls if the
agentmesh-platformdependency is missing. This could lead to a false sense of security. - Enforcement Mechanism: It's unclear if returning
{"allowed": False}actually blocks the tool call ingoogle-adk. Raising an exception might be more robust. - Licensing/Copyright: As noted by @DeanChensj, the licensing and copyright should be aligned with the project's standards.
- Reliability: The default policy directory path and the installation instructions in the logs could be improved for better UX.
Please see the line-level comments for more details.
| @@ -0,0 +1,125 @@ | |||
| # Copyright 2026 Microsoft Corporation | |||
There was a problem hiding this comment.
I agree with @DeanChensj. This sample is being contributed to a Google-owned repository, so it should ideally follow the project's licensing (Apache 2.0) and copyright standards. Also, the plugins/ folder suggestion would help better integrate this into the ADK community structure.
| data={"tool_args": args or {}, "reason": result.reason}, | ||
| ) | ||
| audit_id = entry.entry_id | ||
| else: |
There was a problem hiding this comment.
It's important to verify if google-adk's Agent class automatically interprets the allowed key in the returned dictionary. If the agent doesn't check this value, the governance won't actually be enforced. Most plugin systems expect an exception to be raised to block an action. If result.allowed is False, should we raise an exception here?
| "agentmesh-platform not installed. " | ||
| "Install with: pip install agentmesh-platform" | ||
| ) | ||
|
|
There was a problem hiding this comment.
This install command should probably match the one in the README (agentmesh-platform[server]) to ensure all necessary components (like the audit service) are available.
|
|
||
| def __init__( | ||
| self, | ||
| policy_dir: str | Path = "./policies", |
There was a problem hiding this comment.
Using a relative path like "./policies" as a default can be unreliable depending on where the user executes their script. It might be better to require this path or calculate it relative to the agent's entry point.
| from agentmesh.governance.policy import PolicyEngine | ||
| from agentmesh.services.audit import AuditService | ||
|
|
||
| self._engine = PolicyEngine() |
There was a problem hiding this comment.
This "fail-open" logic (returning allowed: True when agentmesh-platform is missing) might be a security risk. If a user intends to have governance but the package is missing, the agent will proceed without any restrictions. Consider raising an ImportError or providing a configuration to choose between fail-open and fail-closed behaviors.
Summary
Adds a community sample demonstrating the Agent Governance Toolkit (AGT) integration with Google ADK, as discussed in google/adk-python#5418 and invited by @DeanChensj.
What's included
How it works
\
Tool call → GovernancePlugin.before_tool_call() → Policy evaluation (<5ms) → Allow/Deny/Warn → Audit log
\\
Requirements
\\�ash
pip install google-adk agentmesh-platform
\\
AGT Stats