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.

As explained in https://github.com/mangiucugna/json_repair?tab=readme-ov-file#performance-considerations we can skip a wasteful json.loads() here and save quite some time (#2397)

Stefano Baccianella4daa88fa59f2
diff --git a/src/crewai/tools/tool_usage.py b/src/crewai/tools/tool_usage.py
index 25e4b126a..9c924027d 100644
--- a/src/crewai/tools/tool_usage.py
+++ b/src/crewai/tools/tool_usage.py
@@ -455,7 +455,7 @@ class ToolUsage:
# Attempt 4: Repair JSON
try:
- repaired_input = repair_json(tool_input)
+ repaired_input = repair_json(tool_input, skip_json_loads=True)
self._printer.print(
content=f"Repaired JSON: {repaired_input}", color="blue"
)