From 243d82c878b53331572e1bd1b0bf1225806d7f09 Mon Sep 17 00:00:00 2001 From: Rip&Tear <84775494+theCyberTech@users.noreply.github.com> Date: Wed, 22 Jul 2026 18:04:58 +0800 Subject: [PATCH] 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. --- lib/crewai/src/crewai/agents/parser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/crewai/src/crewai/agents/parser.py b/lib/crewai/src/crewai/agents/parser.py index c59719226c..86a8d2020a 100644 --- a/lib/crewai/src/crewai/agents/parser.py +++ b/lib/crewai/src/crewai/agents/parser.py @@ -173,7 +173,12 @@ def _safe_repair_json(tool_input: str) -> str: tool_input = tool_input.replace('"""', '"') result = repair_json(tool_input) - if result in UNABLE_TO_REPAIR_JSON_RESULTS: + if not result or result in UNABLE_TO_REPAIR_JSON_RESULTS: + return tool_input + + # json-repair >= 0.60 wraps non-JSON input in a single-element list; + # treat that as unrepairable and return the original. + if result.startswith("[") and not tool_input.lstrip().startswith("["): return tool_input return str(result)