Version line
v2 — Go rewrite (1.x), main-v2 (active development)
Exact version
v1.5.0
What happened?
20260609-084614.919975000-deepseek-v4-flash.jsonl.telemetry.json
Reasonix 在将模型输出的工具调用参数序列化为 JSON 时,某些情况下 JSON 没有被完整序列化就发送给了 API,导致 API 收到的是损坏的 JSON,返回 400 错误。
Steps to reproduce
[##]([url](
20260610-063757.391625100-deepseek-v4-flash.jsonl.telemetry.json
)) Summary
Reasonix 在序列化工具调用的 arguments 字段时,某些情况下 JSON 没有被完整序列化就发送给了 LLM API,导致 API 返回 HTTP 400 错误:
"Expecting property name enclosed in double quotes: line 1 column 2 (char 1)"
"Expecting ',' delimiter: line 1 column 11 (char 10)"
Evidence
Case 1: bash tool call (Session: 20260609-084614, Line 102)
Log entry:
{"role":"assistant","content":"**第13题(多选)**:关于考核规则,描述正确的是...","tool_calls":[{"id":"call_2eeda6fb42ed440c9a7997b6","name":"bash","arguments":"{"}]}
Problem: arguments 值仅为 "{",后面应该有完整的命令但全部丢失。
Expected: 类似 "{"command": "bb-browser click @111 --tab ed3e && bb-browser click @115 --tab ed3e && bb-browser click @117 --tab ed3e"}"
API Response:
{"role":"tool","content":"error: invalid args: unexpected end of JSON input\n\nThe arguments were not valid JSON...","tool_call_id":"call_2eeda6fb42ed440c9a7997b6","name":"bash"}
Case 2: browser_wait_for tool call (Session: 20260610-063757, Line 209)
Log entry:
{"role":"assistant","tool_calls":[{"id":"call_2c80570a2cbe4edca3cdf3ba","name":"mcp__playwright__browser_wait_for","arguments":"{\"time\": 2"}]}
Problem: JSON 缺少闭合的 },应该是 "{"time": 2}"。
API Response:
error: invalid args: unexpected end of JSON input
Case 3: Another truncation (Recent error)
Error message:
Malformed request (HTTP 400): the request body was rejected.
***.BadRequestError: OpenAIException - {"error":{"message":"Expecting ',' delimiter: line 1 column 11 (char 10)","type":"BadRequestError","param":null,"code":400}}
Analysis: Error at character 10 indicates JSON is being cut off mid-serialization.
Root Cause Analysis
The arguments field in tool calls is being truncated during serialization. This happens:
- Not related to context size — Case 2 occurred in a fresh, short session
- Affects multiple tool types — Both
bash and mcp__playwright__browser_wait_for are affected
- Consistent pattern — JSON objects are either incomplete or missing closing braces
Possible causes:
- Stream response buffering issue where JSON serialization is interrupted
- Race condition in tool call argument processing
- Buffer flush timing issue with certain tool types
Steps to Reproduce
- Start a new Reasonix session
- Ask the agent to use tools that require complex arguments (e.g.,
bash with multiple commands, browser_wait_for, or parallel web_fetch calls)
- Occasionally the
arguments field gets truncated
Environment
- OS: Windows 11
- Reasonix config version: 2
- Default model: deepseek-v4-flash (via DeepSeek API)
- Alternative model tested: Agnes AI/agnes-2.0-flash
Session Logs
Logs are located at:
C:\Users\zheng\AppData\Roaming\reasonix\sessions\20260609-084614.919975000-deepseek-v4-flash.jsonl
C:\Users\zheng\AppData\Roaming\reasonix\sessions\20260610-063757.391625100-deepseek-v4-flash.jsonl
Impact
- Causes HTTP 400 errors from LLM API
- Interrupts agent workflow
- Requires user to start a new session to continue
- Wastes API tokens on failed requests
Suggested Fix
- Add validation in the tool call serialization layer to ensure JSON is complete before sending
- Implement retry logic when malformed JSON is detected
- Add logging to capture the raw model output before serialization to help debug truncation points
- Consider adding a buffer/flush mechanism for streaming responses
OS / platform
Windows11
Relevant logs or output
Version line
v2 — Go rewrite (1.x), main-v2 (active development)
Exact version
v1.5.0
What happened?
20260609-084614.919975000-deepseek-v4-flash.jsonl.telemetry.json
Reasonix 在将模型输出的工具调用参数序列化为 JSON 时,某些情况下 JSON 没有被完整序列化就发送给了 API,导致 API 收到的是损坏的 JSON,返回 400 错误。
Steps to reproduce
[##]([url](
20260610-063757.391625100-deepseek-v4-flash.jsonl.telemetry.json
)) Summary
Reasonix 在序列化工具调用的
arguments字段时,某些情况下 JSON 没有被完整序列化就发送给了 LLM API,导致 API 返回 HTTP 400 错误:"Expecting property name enclosed in double quotes: line 1 column 2 (char 1)""Expecting ',' delimiter: line 1 column 11 (char 10)"Evidence
Case 1:
bashtool call (Session: 20260609-084614, Line 102)Log entry:
{"role":"assistant","content":"**第13题(多选)**:关于考核规则,描述正确的是...","tool_calls":[{"id":"call_2eeda6fb42ed440c9a7997b6","name":"bash","arguments":"{"}]}Problem:
arguments值仅为"{",后面应该有完整的命令但全部丢失。Expected: 类似
"{"command": "bb-browser click @111 --tab ed3e && bb-browser click @115 --tab ed3e && bb-browser click @117 --tab ed3e"}"API Response:
{"role":"tool","content":"error: invalid args: unexpected end of JSON input\n\nThe arguments were not valid JSON...","tool_call_id":"call_2eeda6fb42ed440c9a7997b6","name":"bash"}Case 2:
browser_wait_fortool call (Session: 20260610-063757, Line 209)Log entry:
{"role":"assistant","tool_calls":[{"id":"call_2c80570a2cbe4edca3cdf3ba","name":"mcp__playwright__browser_wait_for","arguments":"{\"time\": 2"}]}Problem: JSON 缺少闭合的
},应该是"{"time": 2}"。API Response:
Case 3: Another truncation (Recent error)
Error message:
Analysis: Error at character 10 indicates JSON is being cut off mid-serialization.
Root Cause Analysis
The
argumentsfield in tool calls is being truncated during serialization. This happens:bashandmcp__playwright__browser_wait_forare affectedPossible causes:
Steps to Reproduce
bashwith multiple commands,browser_wait_for, or parallelweb_fetchcalls)argumentsfield gets truncatedEnvironment
Session Logs
Logs are located at:
C:\Users\zheng\AppData\Roaming\reasonix\sessions\20260609-084614.919975000-deepseek-v4-flash.jsonlC:\Users\zheng\AppData\Roaming\reasonix\sessions\20260610-063757.391625100-deepseek-v4-flash.jsonlImpact
Suggested Fix
OS / platform
Windows11
Relevant logs or output