In this tutorial, we implement a governed AI-agent workflow inspired by Microsoft's Agent Governance Toolkit. The core idea is to insert a governance layer between agents and their tools, ensuring every action is checked against policies before execution.
We create a Colab-ready notebook where agents cannot directly invoke tools. Instead, each action passes through a governance layer that evaluates the agent's identity, trust score, risk tier, requested tool, action type, sensitivity level, and policy rules.
Defining the Policy
We define a YAML-based policy that controls destructive database operations, external email sending, shell execution, access to sensitive data, and financial transfers. For example:
- Destructive database actions (drop, delete, truncate) are denied outright.
- External emails require human approval.
- Shell commands are sandboxed with blocked dangerous commands.
- Low-trust agents are denied access to sensitive data.
- Financial transfers above $1000 require approval.
- High-risk agents are rate-limited on autonomous actions.
Governance in Action
Each tool is wrapped with governance logic. Actions can be:
- Allowed: proceeds normally.
- Denied: blocked and logged.
- Sandboxed: executed in a restricted environment.
- Requiring Approval: routed to an approval step before execution.
We also generate tamper-evident audit records using HMAC-SHA256 hashing, chain them to prevent tampering, and visualize governance decisions as a graph showing relationships between agents, tools, rules, and outcomes.
Key Takeaway
This implementation demonstrates how to enforce safe AI agent behavior with policies, approvals, audit logs, and risk controls. It's a practical blueprint for anyone looking to deploy governed AI agents in production.