Skip to content

Commit 243d82c

Browse files
committed
fix: adapt _safe_repair_json to json-repair 0.60 semantics
json-repair >= 0.60 returns an empty string for plain-text input and wraps brace-enclosed junk in a single-element list instead of the old ""/{} sentinel values. Treat both as unrepairable so the original tool input is preserved.
1 parent 786fa3d commit 243d82c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/crewai/src/crewai/agents/parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,12 @@ def _safe_repair_json(tool_input: str) -> str:
173173
tool_input = tool_input.replace('"""', '"')
174174

175175
result = repair_json(tool_input)
176-
if result in UNABLE_TO_REPAIR_JSON_RESULTS:
176+
if not result or result in UNABLE_TO_REPAIR_JSON_RESULTS:
177+
return tool_input
178+
179+
# json-repair >= 0.60 wraps non-JSON input in a single-element list;
180+
# treat that as unrepairable and return the original.
181+
if result.startswith("[") and not tool_input.lstrip().startswith("["):
177182
return tool_input
178183

179184
return str(result)

0 commit comments

Comments
 (0)