[Bug]: JSONEditTool rejects explicit null values for set and add

Author: wuwenbo0626Created Sep 9, 2026Updated Sep 9, 2026

What happened?

JSONEditTool treats an explicit JSON null value as if the value argument were missing. As a result, both set and add reject valid tool calls that contain "value": null.

Minimal reproduction:

python
import asyncio
import json
import tempfile
from pathlib import Path

from trae_agent.tools.base import ToolCallArguments
from trae_agent.tools.json_edit_tool import JSONEditTool


async def main():
    with tempfile.TemporaryDirectory() as directory:
        path = Path(directory) / "data.json"
        path.write_text('{"value": 1, "items": []}')
        tool = JSONEditTool()

        set_result = await tool.execute(
            ToolCallArguments(
                {
                    "operation": "set",
                    "file_path": str(path),
                    "json_path": "$.value",
                    "value": None,
                }
            )
        )
        add_result = await tool.execute(
            ToolCallArguments(
                {
                    "operation": "add",
                    "file_path": str(path),
                    "json_path": "$.items[0]",
                    "value": None,
                }
            )
        )

        print(set_result.error)
        print(add_result.error)
        print(json.loads(path.read_text()))


asyncio.run(main())

Observed output:

A 'value' parameter is required for the 'set' operation.
A 'value' parameter is required for the 'add' operation.
{'value': 1, 'items': []}

The check currently uses value is None, which cannot distinguish an omitted argument from an explicitly supplied JSON null.

What did you expect to happen?

When the tool call contains the value key, None should be treated as the JSON value null. The example above should produce:

json
{"value": null, "items": [null]}

Only a missing value key should return the required-parameter error.

Traceback

No exception is raised. The tool returns error_code=-1 with the required-parameter message shown above.

What is your system, Python, dependency version?

  • OS: macOS arm64
  • Python: 3.12.14
  • trae-agent commit: e839e55

Additional information that you believe is relevant to this bug

In OpenAI strict mode, optional tool parameters are included in required and made nullable by Tool.get_input_schema(). The generated schema can therefore permit an explicit null value while JSONEditTool.execute() rejects it at runtime.

The intended fix is to check whether "value" is present in the arguments rather than checking whether its value is None. Regression tests should cover setting a field to null, adding null to an array, and continuing to reject an omitted value argument.