From 9d705535150226c250d35aa0f8d10a1f3f6e9f32 Mon Sep 17 00:00:00 2001 From: iris-clawd Date: Wed, 17 Jun 2026 20:59:26 -0300 Subject: [PATCH] Use safe expression parser in calculator tool example (#6211) * Replace eval with safe expression parser in calculator tool example Update the calculator tool example in the CLI template to use ast.parse instead of eval for expression evaluation. Co-authored-by: Vinicius Brasil * Replace calculator example with practical file reader tool * Use word count example - safe, no file/eval risk --------- Co-authored-by: Vinicius Brasil --- lib/cli/src/crewai_cli/templates/AGENTS.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/cli/src/crewai_cli/templates/AGENTS.md b/lib/cli/src/crewai_cli/templates/AGENTS.md index bb54b7cb3..cb9fff256 100644 --- a/lib/cli/src/crewai_cli/templates/AGENTS.md +++ b/lib/cli/src/crewai_cli/templates/AGENTS.md @@ -767,10 +767,11 @@ class CustomSearchTool(BaseTool): ```python from crewai.tools import tool -@tool("Calculator") -def calculator(expression: str) -> str: - """Evaluates a mathematical expression and returns the result.""" - return str(eval(expression)) +@tool("WordCount") +def word_count(text: str) -> str: + """Counts the number of words in the given text.""" + count = len(text.split()) + return f"Word count: {count}" ``` ### Built-in Tools (install with `uv add crewai-tools`)