-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
Sample: Agent Governance — Tool Policy, Trust Scoring, and Audit
What kind of sample would you like to see?
A governance-focused sample demonstrating how to use ADK's BasePlugin and callbacks to enforce runtime governance on agent tool usage.
Proposed: agent-governance sample
This sample would demonstrate:
-
GovernancePlugin — A
BasePluginthat enforces tool policiesbefore_tool_callback: Allowlist/blocklist tools, scan arguments for sensitive patterns, enforce rate limitson_user_message_callback: Detect threat signals (data exfiltration, privilege escalation, prompt injection) before agent processingafter_tool_callback: Append-only audit trail of all tool calls with policy decisions
-
Multi-agent trust scoring — A
SequentialAgentwhere:- A "router" agent delegates to specialist sub-agents
- Each sub-agent has its own governance policy (different tool permissions)
- Trust scores decay over time and improve with successful completions
- Low-trust agents get stricter policies
-
YAML-driven policy configuration — Policies loaded from config files, not hardcoded:
name: customer-service allowed_tools: [search_kb, create_ticket, lookup_order] blocked_patterns: ["(?i)(ssn|credit.card|password)"] max_calls_per_request: 20 require_human_approval: [create_ticket]
How it differs from existing samples
safety-plugins |
policy-as-code |
This proposal | |
|---|---|---|---|
| Focus | Content safety (Model Armor) | Infrastructure policy (Terraform/OPA) | Runtime tool governance |
| Cloud dependency | Requires Google Cloud | Requires GCP + OPA | None (pure Python) |
| Enforcement point | Model input/output | Before deployment | Before each tool call |
| Multi-agent | No | No | Yes (trust scoring) |
| Audit trail | No | No | Yes (JSON Lines) |
Proposed Directory Structure
python/agents/agent-governance/
├── agent_governance/
│ ├── __init__.py
│ ├── agent.py # Root agent with governance callbacks
│ ├── governance_plugin.py # BasePlugin implementation
│ ├── policy.py # GovernancePolicy dataclass + YAML loading
│ ├── intent.py # Threat signal classification
│ ├── trust.py # Trust scoring with decay
│ ├── audit.py # Append-only audit trail
│ └── tools.py # Example governed tools
├── policies/
│ ├── production.yaml
│ └── strict.yaml
├── tests/
│ └── test_governance.py
├── pyproject.toml
└── README.md
ADK language
Python
Context
We've built this pattern for PydanticAI (57 tests passing), CrewAI, and OpenAI Agents. Happy to submit a PR porting this to ADK's plugin architecture.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels