AutoGen + Tork Governance
Add AI safety guardrails to Microsoft AutoGen multi-agent conversations. Govern messages, block dangerous code execution, and maintain compliance across agent teams.
Message Governance
Validate all agent messages
GroupChat Support
Govern multi-agent teams
Code Execution
Block dangerous imports
Tool Validation
Secure function calls
Installation
Install Tork with AutoGen dependencies.
The Tork SDK includes AutoGen adapters in tork.adapters.autogen.
TorkAutoGenMiddleware
Central middleware for governing AutoGen agent conversations.
The middleware wraps AutoGen agents to evaluate all incoming and outgoing messages against your governance policies. Use wrap_agent() to add governance to any agent.
TorkGovernedAssistant
Direct wrapper for AssistantAgent with built-in governance.
TorkGovernedAssistant wraps an AutoGen AssistantAgent directly. It validates messages on receive and responses on generate, raising exceptions when policies are violated.
Governed GroupChat
Govern multi-agent team conversations.
Use create_governed_group_chat() to automatically wrap all agents in a group. Every message between agents is evaluated against policies.
Code Execution Governance
Block dangerous imports and operations in generated code.
AutoGen can execute code generated by agents. Tork policies can block dangerous imports like os, subprocess, and prevent access to sensitive system resources.
Configure Code Policies
Set up code execution policies in the Tork dashboard to block specific imports, file operations, network access, and other dangerous operations.
Tool/Function Validation
Validate tool calls before execution.
When agents use tools or functions, validate the inputs before execution. Block dangerous SQL queries, restrict email recipients, or enforce data access policies.
Error Handling
Handle governance violations gracefully.
Catch governance exceptions to provide user-friendly responses instead of errors. Use MessageBlockedError for input violations and ResponseBlockedError for output violations.
Multi-Agent Workflow
Complete example of a governed customer service team.
Build complex multi-agent systems with governance on every communication. This example shows a customer service team with specialized agents.
Advanced Patterns
Compliance receipts and async support
Best Practices
Wrap all agents in multi-agent systems
Use middleware.wrap_agent() for every agent to ensure no communication bypasses governance.
Configure code execution policies
Block dangerous imports (os, subprocess, shutil) and operations (eval, exec) via the dashboard.
Validate tool calls separately
Use validate_tool_call() for sensitive operations like database queries or external API calls.
Handle exceptions gracefully
Catch MessageBlockedError and ResponseBlockedError to provide user-friendly error messages.
Enable compliance receipts for audit
Use the receipt generator to maintain a cryptographically signed audit trail of all decisions.
Imports Reference
Next Steps
Configure policies in the dashboard and explore other framework integrations.