| Requirement | Version |
|---|---|
| Agent Assembly Python SDK (agent-assembly) | >= 0.0.1rc6 |
Install:
uv add agent-assembly==0.0.1rc6
# or
pip install agent-assembly==0.0.1rc6Demonstrates how to integrate Agent Assembly with the OpenAI Agents SDK to enforce governance policy — including approval gates — on tool calls before execution.
- Initializing Agent Assembly with
init_assembly(). - Enforcing a governance policy using
AssemblyCallbackHandler+ a policy interceptor. - Running an allowed tool call (
search_documents). - Running a tool that requires human approval (
send_message_to_user— auto-denied offline). - Running a denied tool call (
delete_record— blocked by a policy rule). - How the
OpenAIAgentsPatchinterceptsFunctionTool.__call__at the framework level.
| Requirement | Version |
|---|---|
| Python | >= 3.12 |
| uv | latest |
| Agent Assembly Python SDK | >= 0.0.1rc6 |
No OPENAI_API_KEY is required for the offline demo.
cd python/openai-agents-sdk
uv sync --extra devuv run python src/main.py==============================================================
Agent Assembly — OpenAI Agents SDK Demo
==============================================================
Initializing Agent Assembly (gateway: http://localhost:8080, sdk-only mode)...
Agent: openai-agents-demo
Gateway: http://localhost:8080
Mode: sdk-only (offline demo)
Policy rules (local simulation of gateway policy):
DENY — delete_record, drop_table (destructive data ops)
APPROVAL — send_message_to_user, trigger_payment
ALLOW — everything else
Running governed tool calls:
--------------------------------------------
→ search_documents({"query": "agent governance best practices"})
✅ ALLOWED — 📄 Search results for 'agent governance best practices': ...
→ send_message_to_user({"user_id": "u-001", "message": "Your report is ready."})
❌ BLOCKED — Tool 'send_message_to_user' requires approval, but no approver is available in offline mode.
→ delete_record({"record_id": "rec-7829"})
❌ BLOCKED — Tool 'delete_record' is permanently blocked by policy rule 'deny_destructive_data_ops'.
uv run pytest tests/ -v- Start an Agent Assembly gateway or use your SaaS workspace URL.
- Copy
.env.exampleto.envand fill in your credentials. - Run with environment variables:
OPENAI_API_KEY=sk-... \
AGENT_ASSEMBLY_GATEWAY_URL=http://localhost:8080 \
AGENT_ASSEMBLY_API_KEY=your-key \
uv run python src/main.pyWhen an OPENAI_API_KEY is set, you can extend main.py to create a real agents.Agent with your FunctionTool instances. Agent Assembly's OpenAIAgentsPatch intercepts every tool call automatically once init_assembly() has run.
| Problem | Fix |
|---|---|
ModuleNotFoundError: agent_assembly |
Run uv sync first |
ModuleNotFoundError: openai |
Run uv sync — openai-agents is a required dependency |
ToolExecutionBlockedError in tests |
Expected — the deny/approval policy rules are intentional |