overview.mdx 1.5 KB

123456789101112131415161718192021222324252627
  1. ---
  2. title: "Guardrails Overview"
  3. description: "Screen agent inputs and review outputs with guardrails."
  4. icon: "shield-halved"
  5. sidebarTitle: "Overview"
  6. ---
  7. Guardrails are checkpoint functions that keep agent behavior safe and predictable. Use them to validate incoming messages before execution and validate responses before delivery.
  8. ## Choose the Right Guardrail
  9. | Type | Runs When | On Failure | Page |
  10. |------|-----------|------------|------|
  11. | **Input Guardrails** | Before the agent processes input | Return guidance (non-strict) or raise `InputGuardrailTripwireTriggered` (strict) | [Input Guardrails](/additional-features/guardrails/input-guardrails) |
  12. | **Output Guardrails** | After the agent drafts output, before delivery | Retry up to `validation_attempts`, then raise `OutputGuardrailTripwireTriggered` | [Output Guardrails](/additional-features/guardrails/output-guardrails) |
  13. ## Runnable GitHub Examples
  14. - Input guardrails example: [`examples/guardrails_input.py`](https://github.com/VRSEN/agency-swarm/blob/main/examples/guardrails_input.py)
  15. - Output guardrails example: [`examples/guardrails_output.py`](https://github.com/VRSEN/agency-swarm/blob/main/examples/guardrails_output.py)
  16. ## Best Practices
  17. - Keep each guardrail focused on one responsibility.
  18. - Write clear `output_info` messages so the model knows how to recover.
  19. - Use non-strict mode for guidance and strict mode for hard requirements.
  20. - For tool argument validation (field/model validators), use [Input Validation](/core-framework/tools/custom-tools/validation).