mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-03 06:08:15 +00:00
Fixes #5979 — guardrails are now enforced as hard constraints. Two bugs fixed: 1. Multiple guardrails skipped re-validation of earlier guardrails after retry. When guardrail N failed and the agent retried, the new output was only checked against guardrail N onward. Earlier guardrails (0..N-1) were not re-evaluated, allowing retry outputs to silently violate them. Fix: refactored _invoke_guardrail_function into _run_guardrails which runs ALL guardrails from the beginning on each retry attempt. 2. Negative guardrail_max_retries bypassed guardrails entirely. Setting guardrail_max_retries to a negative value made the guardrail loop execute zero iterations, letting output pass without validation. Fix: added ge=0 constraint to the guardrail_max_retries field. Co-Authored-By: João <joao@crewai.com>