-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathagent.py
More file actions
38 lines (30 loc) · 1.08 KB
/
agent.py
File metadata and controls
38 lines (30 loc) · 1.08 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
"""Agent OS Demo - Your First Governed Agent"""
import asyncio
from agent_os import StatelessKernel, ExecutionContext
# Create stateless kernel (no external dependencies)
kernel = StatelessKernel()
async def my_agent(task: str) -> str:
"""Process a task safely through the kernel."""
# Create execution context
ctx = ExecutionContext(
agent_id="demo-agent",
policies=["read_only"] # Apply safety policy
)
# Execute through the kernel
result = await kernel.execute(
action="process_task",
params={"task": task, "output": f"Processed: {task.upper()}"},
context=ctx
)
return result.data if result.success else f"Error: {result.error}"
async def main():
print("[Agent OS] Demo")
print("=" * 40)
result = await my_agent("Hello, Agent OS!")
print(f"[OK] Result: {result}")
print("")
print("Success! Your agent ran safely under kernel governance!")
print("")
print("The kernel checked the 'read_only' policy before execution.")
if __name__ == "__main__":
asyncio.run(main())