Back to catalog / Agent safety
Validate inputs and final outputs in an agent workflow
Add testable rejection conditions for user input and final answers, distinguishing per-tool checks.
Goal
Prevent inputs or answers that violate application rules from proceeding.
Steps
- Separate structural schema validation from business/policy checks: the former constrains field shape, the latter judges whether a request or result is allowed. [openai-guardrails]
- Use
@input_guardrailfor the first input and@output_guardrailfor final output; returnGuardrailFunctionOutput(..., tripwire_triggered=True)to block. [openai-guardrails] - For policy checks on every custom function-tool call, attach
@tool_input_guardrail/@tool_output_guardrailrather than relying on agent-level checks. [openai-guardrails] - Add tool-level checks to each side-effecting custom tool; do not assume agent-level checks cover handoffs. [openai-guardrails]
- Trigger each check with allowed and rejected cases and confirm failures stop at the intended boundary. [openai-guardrails]
How to verify
Record trigger tests and blocked execution points for each guardrail; verify handoff and tool boundaries are covered.
Troubleshooting
If a check does not run, verify which agent or tool owns that workflow boundary; handoffs and hosted tools may follow different paths.
Permissions
Prerequisites
- Python 3.10+, openai-agents compatible with the pinned revision, and authorized model-provider credentials (except local mock tests)
Permissions
- Use a local or isolated test environment; use least privilege and approval for external data or side effects
Limitations
Agent input checks run only on the first agent and output checks only on the final agent; tool checks do not cover handoffs or most hosted tools. Parallel input checks may fire after model work starts.
Pinned upstream source
- Repository
- openai/openai-agents-python
- File path
- docs/guardrails.md
- Pinned commit
f53c62451c7f34c15f0c87fa745e05404025420f- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Make Agent behavior safer and easier to verify