forked from microsoft/agent-governance-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.py
More file actions
56 lines (44 loc) · 1.46 KB
/
quickstart.py
File metadata and controls
56 lines (44 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""
Agent Governance — Quick Start
Boot the full governance stack and execute a governed action.
Usage:
pip install ai-agent-governance
python examples/quickstart.py
"""
import asyncio
from agent_os import StatelessKernel, ExecutionContext
from agentmesh import AgentIdentity
# 1. Boot the governance kernel
kernel = StatelessKernel()
print("✅ Governance kernel booted")
# 2. Create an execution context for our agent
ctx = ExecutionContext(
agent_id="quickstart-agent",
policies=["read_only"],
)
# 3. Register a zero-trust agent identity
identity = AgentIdentity.create(
name="quickstart-agent",
sponsor="demo@example.com",
capabilities=["read:data", "write:reports"],
)
print(f"✅ Agent identity created: {identity.did}")
async def main():
# 4. Execute a governed action
result = await kernel.execute(
action="database_query",
params={"query": "SELECT * FROM reports"},
context=ctx,
)
print(f"✅ Query result: success={result.success}")
# 5. Try a blocked action (write blocked by read_only policy)
result = await kernel.execute(
action="file_write",
params={"path": "/data/secret.txt", "content": "test"},
context=ctx,
)
print(f"✅ Write blocked: success={result.success}, signal={result.signal}")
print("\n🎉 Governance stack is running! Your agent is now governed.")
asyncio.run(main())