Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

Use safe expression parser in calculator tool example (#6211)

iris-clawd9d7055351502
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`)