[BUG] Bare `None` in a ReAct Action Input reaches the tool as the string "None" (fixed upstream in json-repair 0.63, crewAI pins 0.60.x)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with _safe_repair_json in lib/crewai/src/crewai/agents/parser.py and the json-repair pin in lib/crewai/pyproject.toml; compare the reported behavior on bare None with the existing test_validate_tool_input_booleans_and_none coverage. The issue proposes parser regression tests for object fields, nested fields, list elements, and quoted "None", plus checking the dependency update against the test suite. An open pull request, #9889, is already linked to this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
On the text/ReAct tool path, if a model writes a Python-style None in the Action Input, the tool receives the string "None" instead of None. For a str | None argument this is silent: the tool runs with a country literally called "None". For int | None the string is rejected by argument validation instead (the script below only shows the silent str | None case).
The step that does it is repair_json in _safe_repair_json (lib/crewai/src/crewai/agents/parser.py:175). json-repair 0.60.1 repairs True/False but turns a bare None into "None". That was reported and fixed upstream in json-repair 0.63.0 (mangiucugna/json_repair#210), but crewAI pins json-repair~=0.60.1 (lib/crewai/pyproject.toml:38), so the fix cannot arrive through a normal update.
ToolUsage._validate_tool_input already handles Python literals via ast.literal_eval, and test_validate_tool_input_booleans_and_none covers None there. On the real ReAct path that code never sees the original text, because the parser has already rewritten it into valid JSON with "None" in it.
JSON null works and a quoted "None" correctly stays a string. Native tool calling is not affected.
Steps to Reproduce
Offline, no model call:
import json
from importlib.metadata import version
from pydantic import BaseModel
from crewai.agents.parser import parse
from crewai.tools import BaseTool
class LookupArgs(BaseModel):
query: str
country: str | None = None
class LookupTool(BaseTool):
name: str = "lookup"
description: str = "Look up a query."
args_schema: type[BaseModel] = LookupArgs
def _run(self, query: str, country: str | None = None) -> str:
return f"country={country!r}"
print("json-repair", version("json-repair"))
for action_input in (
'{"query": "x", "country": None}',
'{"query": "x", "country": null}',
'{"query": "x", "country": "None"}',
'{"query": "x", "flag": True, "ids": [1, None, 3]}',
):
action = parse(f"Thought: t\nAction: lookup\nAction Input: {action_input}")
args = json.loads(action.tool_input)
out = LookupTool().run(**args) if "country" in args else args
print(f"{action_input:52} -> {out}")
Expected behavior
| Action Input | Actual (json-repair 0.60.1, pinned) | Expected (what 0.64.9 gives) |
|---|---|---|
{"query": "x", "country": None} |
country='None' |
country=None |
{"query": "x", "country": null} |
country=None |
country=None |
{"query": "x", "country": "None"} |
country='None' |
country='None' |
{"query": "x", "flag": True, "ids": [1, None, 3]} |
'ids': [1, 'None', 3] |
'ids': [1, None, 3] |
Environment
crewAI 1.15.45 (PyPI) and main at 77237ae, json-repair 0.60.1 (locked), Python 3.13, Linux, uv venv.
Evidence
Output of the script above with the locked json-repair 0.60.1, then with 0.64.9 installed over it (crewAI source unchanged):
json-repair 0.60.1
{"query": "x", "country": None} -> country='None'
{"query": "x", "country": null} -> country=None
{"query": "x", "country": "None"} -> country='None'
{"query": "x", "flag": True, "ids": [1, None, 3]} -> {'query': 'x', 'flag': True, 'ids': [1, 'None', 3]}
json-repair 0.64.9
{"query": "x", "country": None} -> country=None
{"query": "x", "country": null} -> country=None
{"query": "x", "country": "None"} -> country='None'
{"query": "x", "flag": True, "ids": [1, None, 3]} -> {'query': 'x', 'flag': True, 'ids': [1, None, 3]}
In json_repair#210 the reporter comments that Vertex AI Gemini 2.5 Flash/Lite emits None / True / False fairly consistently, so this is not only a hand-made input (there is no saved model trace there, and I did not call a model).
Possible Solution
Two options; happy to send a PR for whichever you prefer.
-
Raise the pin to
json-repair~=0.64.9and add parser regression tests for bareNoneas an object field, a nested field and a list element, plus the quoted-"None"control. 0.63.1 is the first release with both theNonefix and the tuple fix that followed it (0.63.0 alone mis-repairs literals inside tuples), so I'd skip 0.63.0. I tried 0.64.9 locally with crewAI source unchanged: the fulllib/crewai/testssuite gives the same result as on 0.60.1 (7,671 passed; the only 3 failures also fail on the current pin in my environment: two docling tests that need network and one read-only-file test run as root). Behaviour changes to expect: barenone/NONEalso become null;{"a": None} trailing wordsnow repairs to{"a": null}; a bareNoneon a requiredstrfield is rejected by validation instead of being accepted as"None"; and per the 0.63.0 notesTrueBlueis no longer read astrue. The bump spans 0.61 to 0.64, so other repairs may shift too; the suite is the only check I have on that. -
If you'd rather not move the pin: in
_safe_repair_json, tryjson.loads, thenast.literal_eval, and callrepair_jsononly when both fail (_validate_tool_inputstarts with the same two steps). JSON has to stay first, because a valid\/escape is a different string underast.literal_eval. This still missesNonemixed with JSON literals, e.g.{"a": None, "b": true}: that is neither JSON nor a Python literal, so it still goes through repair.
Related, separate: #8195 (truncated tool input repaired and executed; closed as stale) and its open PR #8196; #6612 (the bump to json-repair~=0.60.1) and #6613 (the _safe_repair_json adaptation for 0.60).
Label request: bug, llm-generated.
- Ngôn ngữ chính
- Python
- Star
- 61.2k
- Fork
- 9.2k
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 180
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của crewAIInc/crewAI
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM providerCó thể đã có người làm @HashimSyedUBC đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missingCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Native Azure provider ignores the seed settingCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
crewAIInc/crewAI#9787 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summaryCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của crewAIInc/crewAI
Issue tương tự
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
linuxserver/docker-healthchecks#137 · 1 bình luận ·
-
RequirementAgent treats list -> add -> list as a tool call cycle and drops the second list call (Python)Có thể đã có người làm @chaitanya0305 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
i-am-bee/beeai-framework#2049 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fedora-infra/anitya#2272 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
unitaryfoundation/mitiq#3205 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[Bug]: Index worker test drops empty Git config values on WindowsCó thể đã có người làm @xiaoyesoso đã nhận hôm nay. Đang mởtriage/confirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
agentscope-ai/agentscope#4377 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày