@@ -4,10 +4,9 @@ Kernel-level guardrails and policy enforcement for OpenAI Agents SDK using [Agen
44
55## Features
66
7- - ** Output Guardrails** : Block dangerous patterns in agent outputs
8- - ** Input Validation** : Filter malicious inputs before processing
9- - ** Tool Control** : Limit which tools agents can use
10- - ** Rate Limiting** : Cap tool invocations per run
7+ - ** Output Guardrails** : Block dangerous patterns in agent outputs (automatic)
8+ - ** Input Validation** : Filter malicious inputs before processing (automatic)
9+ - ** Tool Policy** : Define allowed/blocked tools (requires manual ` check_tool() ` calls)
1110- ** Violation Handling** : Callbacks for policy violations
1211
1312## Installation
@@ -27,8 +26,8 @@ from agents.contrib import create_governance_guardrail
2726# Create guardrail with simple config
2827guardrail = create_governance_guardrail(
2928 blocked_patterns = [" DROP TABLE" , " rm -rf" , " DELETE FROM" ],
30- blocked_tools = [" shell_execute" ],
31- max_tool_calls = 10 ,
29+ blocked_tools = [" shell_execute" ], # Use with check_tool() for enforcement
30+ max_tool_calls = 10 , # Use with check_tool() for enforcement
3231)
3332
3433# Create agent with guardrail
@@ -126,6 +125,29 @@ else:
126125 result = await Runner.run(agent, user_input)
127126```
128127
128+ ### Tool Policy Enforcement
129+
130+ Tool policies (` blocked_tools ` , ` allowed_tools ` , ` max_tool_calls ` ) are not automatically
131+ enforced during agent execution. Use ` check_tool() ` in your tool implementations:
132+
133+ ``` python
134+ from agents.contrib import GovernanceGuardrail, GovernancePolicy
135+
136+ policy = GovernancePolicy(
137+ blocked_tools = [" dangerous_tool" ],
138+ max_tool_calls = 10 ,
139+ )
140+
141+ guardrail = GovernanceGuardrail(policy)
142+
143+ # In your tool implementation:
144+ def my_tool (name : str , args : dict ):
145+ violation = guardrail.check_tool(name)
146+ if violation:
147+ raise ValueError (f " Tool blocked: { violation.description} " )
148+ # ... execute tool
149+ ```
150+
129151## Integration with Agent-OS Kernel
130152
131153For full kernel-level governance:
0 commit comments