Microsoft Agent Governance Toolkit (AGT) policy enforcement for Strands Agents
Project description
strands-agt
Microsoft Agent Governance Toolkit (AGT) policy enforcement for Strands Agents.
Provides a deterministic, YAML-based InterventionHandler that gates tool calls before execution — no model judgment involved.
Installation
pip install strands-agt
Quick Start
from strands import Agent
from strands_agt import AGTGovernance
governance = AGTGovernance(policies="policies.yaml")
agent = Agent(tools=[...], interventions=[governance])
result = agent("search for documents")
Policy Format
Policies are defined in YAML:
policies:
- name: allow-search
effect: allow
actions: ["search"]
principals: ["User::*"]
- name: deny-delete
effect: deny
actions: ["delete_file"]
reason: "File deletion is not permitted"
Effects
| Effect | Strands Action | Behavior |
|---|---|---|
allow |
Proceed() |
Tool executes normally |
deny |
Deny(reason=...) |
Tool is blocked, reason shown to model |
steer |
Guide(feedback=...) |
Tool is blocked with corrective guidance |
Evaluation Order
- Deny policies are checked first — first match short-circuits
- Steer policies are checked next
- Allow policies are checked last — first match permits
- No match = deny (fail-closed)
Features
Role-Based Access
governance = AGTGovernance(
policies="role_policies.yaml",
principal_resolver=lambda state: {
"type": state.get("user_role", "User"),
"id": state.get("user_id", "anonymous"),
},
)
agent = Agent(tools=[...], interventions=[governance])
agent("Delete backups", invocation_state={"user_role": "Admin", "user_id": "alice"})
Rate Limiting
policies:
- name: rate-limited-email
effect: allow
actions: ["send_email"]
conditions:
session.call_count:
lt: 5
Context Enrichment
governance = AGTGovernance(
policies="env_policies.yaml",
context_enricher=lambda ctx: {
"environment": os.environ.get("DEPLOY_ENV", "development"),
"tenant_id": ctx["invocation_state"].get("tenant_id"),
},
)
Condition Operators
Conditions support: lt, lte, gt, gte, eq, neq, in.
conditions:
session.call_count:
lt: 10
input.database:
in: ["analytics", "staging"]
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
policies |
str | list[str] |
required | YAML policy file path(s) or inline YAML |
principal |
dict[str, str] | None |
{"type": "User", "id": "anonymous"} |
Static principal identity |
principal_resolver |
Callable | None |
None |
Dynamic resolver from invocation_state |
context_enricher |
Callable | None |
None |
Injects extra fields into policy context |
on_error |
str |
"throw" |
Error mode: "throw", "proceed", or "deny" |
Development
pip install -e ".[dev]"
pytest
ruff check src tests
mypy src
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strands_agt-0.1.0.tar.gz.
File metadata
- Download URL: strands_agt-0.1.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f423e98385c770d5cc567e5f3a9b2a87cd7960a90908e16ff92236d145ea9b2b
|
|
| MD5 |
600dc177791837c8f8ef4104b8683bd4
|
|
| BLAKE2b-256 |
cc43664008735afc56def3c6d0655ef2378edf1732a14b47a4e2cb699d1cdd2f
|
File details
Details for the file strands_agt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: strands_agt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
934ae392576f4090b3dab93a8567284ecd25a685ffbdf00681f24f8270ecaee5
|
|
| MD5 |
566b2dea75aca6a5c59ce90af08088df
|
|
| BLAKE2b-256 |
7056da855a8411c63f768b997a09be0d797c10e74364e491af32f205bd20a3b2
|