Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/crewai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions lib/crewai/src/crewai/agents/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

from dataclasses import dataclass
import json

from json_repair import repair_json # type: ignore[import-untyped]
from pydantic import BaseModel
Expand Down Expand Up @@ -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 json.JSONDecodeError:
return tool_input
if not isinstance(parsed, dict):
return tool_input

return str(result)