Skip to content

Commit

Permalink
improving guardrails
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomdmoura committed Jan 4, 2025
1 parent d3da731 commit 440883e
Show file tree
Hide file tree
Showing 3 changed files with 1,101 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/crewai/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from crewai.utilities.config import process_config
from crewai.utilities.converter import Converter, convert_to_model
from crewai.utilities.i18n import I18N
from crewai.utilities.printer import Printer


class Task(BaseModel):
Expand Down Expand Up @@ -394,6 +395,11 @@ def _execute_core(
guardrail_result_error=guardrail_result.error,
task_output=task_output.raw
)
printer = Printer()
printer.print(
content=f"Guardrail blocked, retrying, due to:{guardrail_result.error}\n",
color="yellow",
)
return self._execute_core(agent, context, tools)

if guardrail_result.result is None:
Expand Down
Loading

0 comments on commit 440883e

Please sign in to comment.