From a9063600b2df40e444440899f22358e49e42c5d3 Mon Sep 17 00:00:00 2001 From: thomaschhh <64537745+thomaschhh@users.noreply.github.com> Date: Thu, 16 Jul 2026 16:53:46 +0200 Subject: [PATCH 1/3] Update json-repair version in pyproject.toml fix(deps): widen json-repair bound to allow GHSA-xf7x-x43h-rpqh fix json-repair~=0.25.2 caps at <0.26.0, below the 0.60.1 release that fixes GHSA-xf7x-x43h-rpqh (HIGH, CVSS 7.5). CrewAI only uses repair_json(), whose signature is unchanged, so widening is API-safe. --- lib/crewai/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/crewai/pyproject.toml b/lib/crewai/pyproject.toml index a5f96fb277..ea1c1e772e 100644 --- a/lib/crewai/pyproject.toml +++ b/lib/crewai/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "click>=8.1.7,<9", "appdirs~=1.4.4", "jsonref~=1.1.0", - "json-repair~=0.25.2", + "json-repair>=0.60.1,<1.0", "cel-python>=0.5.0,<0.6", "tomli-w~=1.1.0", "tomli~=2.0.2", From 976d29acf8fb8dcb5720090427c63ee60ce8fa8d Mon Sep 17 00:00:00 2001 From: thomaschhh <64537745+thomaschhh@users.noreply.github.com> Date: Thu, 16 Jul 2026 15:30:22 +0000 Subject: [PATCH 2/3] fix(parser): adapt _safe_repair_json to json-repair >=0.60 semantics json-repair >=0.60 fabricates output for non-JSON input (e.g. wraps "{invalid_json" as ["invalid_json"]) instead of returning the empty sentinel 0.25.x produced. The old UNABLE_TO_REPAIR_JSON_RESULTS check therefore no longer detects unrepairable input, and the parser returned garbage for plain-text tool inputs. Only trust the repaired result when it parses back to a JSON object; otherwise keep the original string. Restores prior behavior across the full parser test suite under the widened json-repair bound. Co-Authored-By: Claude Opus 4.8 (1M context) --- lib/crewai/src/crewai/agents/parser.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/crewai/src/crewai/agents/parser.py b/lib/crewai/src/crewai/agents/parser.py index c59719226c..d30e415c38 100644 --- a/lib/crewai/src/crewai/agents/parser.py +++ b/lib/crewai/src/crewai/agents/parser.py @@ -6,6 +6,7 @@ """ from dataclasses import dataclass +import json from json_repair import repair_json # type: ignore[import-untyped] from pydantic import BaseModel @@ -176,4 +177,15 @@ def _safe_repair_json(tool_input: str) -> str: if result in UNABLE_TO_REPAIR_JSON_RESULTS: return tool_input + # json-repair >=0.60 fabricates output (e.g. wraps non-JSON text in a + # list) instead of returning an empty sentinel, so a non-empty result no + # longer means the input was valid JSON. Only trust a result that parses + # back to a JSON object; otherwise keep the original string. + try: + parsed = json.loads(result) + except ValueError: + return tool_input + if not isinstance(parsed, dict): + return tool_input + return str(result) From 75ab677e18501a9e6269dd8517db491d4ccdb573 Mon Sep 17 00:00:00 2001 From: Thomas Dethmann Date: Mon, 20 Jul 2026 05:32:18 +0000 Subject: [PATCH 3/3] fix(parser): replace ValueError with JSONDecodeError in _safe_repair_json --- lib/crewai/src/crewai/agents/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/crewai/src/crewai/agents/parser.py b/lib/crewai/src/crewai/agents/parser.py index d30e415c38..e680d779ee 100644 --- a/lib/crewai/src/crewai/agents/parser.py +++ b/lib/crewai/src/crewai/agents/parser.py @@ -183,7 +183,7 @@ def _safe_repair_json(tool_input: str) -> str: # back to a JSON object; otherwise keep the original string. try: parsed = json.loads(result) - except ValueError: + except json.JSONDecodeError: return tool_input if not isinstance(parsed, dict): return tool_input