You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guardrails.md
+1-81Lines changed: 1 addition & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,84 +151,4 @@ async def main():
151
151
1. This is the actual agent's output type.
152
152
2. This is the guardrail's output type.
153
153
3. This is the guardrail function that receives the agent's output, and returns the result.
154
-
4. This is the actual agent that defines the workflow.
155
-
156
-
## Tool guardrails
157
-
158
-
Tool guardrails provide fine-grained control over individual tool calls, allowing you to validate inputs and outputs at the tool level. This is particularly useful for:
159
-
160
-
- Blocking sensitive data in tool arguments
161
-
- Preventing unauthorized access to certain tools
162
-
- Sanitizing tool outputs before they're returned
163
-
- Implementing custom validation logic for specific tools
164
-
165
-
There are two types of tool guardrails:
166
-
167
-
1.**Tool input guardrails** run before a tool is executed, validating the tool call arguments
168
-
2.**Tool output guardrails** run after a tool is executed, validating the tool's output
169
-
170
-
### Tool input guardrails
171
-
172
-
Tool input guardrails run in 3 steps:
173
-
174
-
1. First, the guardrail receives the tool call data including arguments, context, and agent information
175
-
2. Next, the guardrail function runs to produce a [`ToolGuardrailFunctionOutput`][agents.tool_guardrails.ToolGuardrailFunctionOutput]
176
-
3. Finally, we check if [`.tripwire_triggered`][agents.tool_guardrails.ToolGuardrailFunctionOutput.tripwire_triggered] is true. If true, a [`ToolInputGuardrailTripwireTriggered`][agents.exceptions.ToolInputGuardrailTripwireTriggered] exception is raised
177
-
178
-
### Tool output guardrails
179
-
180
-
Tool output guardrails run in 3 steps:
181
-
182
-
1. First, the guardrail receives the tool call data plus the tool's output
183
-
2. Next, the guardrail function runs to produce a [`ToolGuardrailFunctionOutput`][agents.tool_guardrails.ToolGuardrailFunctionOutput]
184
-
3. Finally, we check if [`.tripwire_triggered`][agents.tool_guardrails.ToolGuardrailFunctionOutput.tripwire_triggered] is true. If true, a [`ToolOutputGuardrailTripwireTriggered`][agents.exceptions.ToolOutputGuardrailTripwireTriggered] exception is raised
185
-
186
-
### Implementing tool guardrails
187
-
188
-
You can create tool guardrails using the `@tool_input_guardrail` and `@tool_output_guardrail` decorators:
0 commit comments