You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiple get_file_diff tool calls fail with concatenated JSON arguments #110
Proval fails during the planning step when reviewing a merge request that changes multiple files.
A review of an MR with a single changed file completes successfully. When the MR contains multiple changed files, Proval fails while processing get_file_diff tool calls.
Environment
Proval image: ghcr.io/seoes/proval:latest
Git provider: GitLab
Model: nemotron-3-ultra
LLM proxy: LiteLLM
Logs
For an MR with multiple changed files:
[Setup]
fetching pull request version
[Setup]
version ready head=37…
[Setup]
building pull request prompt
[Plan]
loop started
[Plan]
step 1: 1 tool call(s)
[Plan]
Get File Diff
{"filePath": "file1.py"}{"filePath": "file2.py"}{"filePath": "file3.py"}
[Plan]
Error · get_file_diff
JSON Parse error: Unable to parse JSON string
[Plan]
agent loop failed: JSON Parse error: Unable to parse JSON string
@pr0g88 Thanks for the logs. This does not look like a duplicate of an existing issue.
The failure is in argument parsing, not GitLab or get_file_diff itself. get_file_diff only accepts one filePath string (apps/api/src/agent/pull-request/tool/get-file-diff.ts). The plan step received one tool call whose arguments are three JSON objects stuck together:
apps/api/src/agent/llm/loop.ts does JSON.parse(tc.arguments) and rethrows on failure, which matches agent loop failed: JSON Parse error: Unable to parse JSON string. Tool execute errors are returned to the model. Parse errors abort the whole plan loop. A single-file MR works because that string is valid JSON.
Two likely sources, both consistent with step 1: 1 tool call(s):
Streaming merge. OpenAI-compatible streaming in apps/api/src/agent/llm/openai.ts (accumulateChatCompletionStream) keys tool calls by tool_calls[].index and concatenates arguments. A missing index becomes 0. If LiteLLM or nemotron-3-ultra emits several get_file_diff calls with no index, or all index: 0, Proval will fold them into one call and concatenate the JSON. Tests in openai.streaming.test.ts only cover distinct indices.
Model output. The model put concatenated JSON in a single arguments field. There is no splitter today.
Either way Proval should not die here. Practical fixes:
Treat a new id at the same stream index as a new tool call, instead of appending arguments.
Split concatenated JSON objects into separate calls (or parse the first object and return a recoverable error for the rest).
On JSON.parse failure, return a tool error to the model instead of throwing, same as execute failures.
If you can grab one raw LiteLLM stream chunk (or a non-streamed response) for a multi-file MR, the useful check is whether several tool_calls share index: 0 or omit index. That distinguishes a Proval merge bug from the model writing concatenated JSON. A single-file vs multi-file pair of those dumps would be enough.
Thanks for the fix. The issue is still reproducible with a multi-file MR.
Proval logs one Get File Diff tool call with concatenated JSON arguments:
{"filePath": "file1.py"}{"filePath": "file2.py"}{"filePath": "file3.py"}
It then logs a JSON parse error. The subsequent LiteLLM request fails in the Ollama request transformation:
json.loads(typed_tool["function"]["arguments"])
JSONDecodeError: Extra data: line 1 column 29
This suggests the malformed tool call is still being included in the conversation history sent on the next model call. The retries appear to resend the same invalid arguments and fail identically.
Activity
proval-0e6d07 commentedon Nov 20, 2026
@pr0g88 Thanks for the logs. This does not look like a duplicate of an existing issue.
The failure is in argument parsing, not GitLab or
get_file_diffitself.get_file_diffonly accepts onefilePathstring (apps/api/src/agent/pull-request/tool/get-file-diff.ts). The plan step received one tool call whoseargumentsare three JSON objects stuck together:{"filePath": "file1.py"}{"filePath": "file2.py"}{"filePath": "file3.py"}apps/api/src/agent/llm/loop.tsdoesJSON.parse(tc.arguments)and rethrows on failure, which matchesagent loop failed: JSON Parse error: Unable to parse JSON string. Toolexecuteerrors are returned to the model. Parse errors abort the whole plan loop. A single-file MR works because that string is valid JSON.Two likely sources, both consistent with
step 1: 1 tool call(s):apps/api/src/agent/llm/openai.ts(accumulateChatCompletionStream) keys tool calls bytool_calls[].indexand concatenatesarguments. A missing index becomes0. If LiteLLM ornemotron-3-ultraemits severalget_file_diffcalls with no index, or allindex: 0, Proval will fold them into one call and concatenate the JSON. Tests inopenai.streaming.test.tsonly cover distinct indices.argumentsfield. There is no splitter today.Either way Proval should not die here. Practical fixes:
idat the same stream index as a new tool call, instead of appending arguments.JSON.parsefailure, return a tool error to the model instead of throwing, same asexecutefailures.If you can grab one raw LiteLLM stream chunk (or a non-streamed response) for a multi-file MR, the useful check is whether several
tool_callsshareindex: 0or omitindex. That distinguishes a Proval merge bug from the model writing concatenated JSON. A single-file vs multi-file pair of those dumps would be enough.seoes commentedon Nov 22, 2026
Hi @pr0g88!
First of all, thanks for using Proval and reporting this issue
Looks like tool call from LiteLLM got no
indexvalue so Proval push them as same index's valueI made some update to parse those request to have their own index number and retry with failed tool call
You can try docker image with version
0.4.1orlatestIf you find any other issues, feel free to open additional issue
pr0g88 commentedon Nov 23, 2026
Thanks for the fix. The issue is still reproducible with a multi-file MR.
Proval logs one Get File Diff tool call with concatenated JSON arguments:
{"filePath": "file1.py"}{"filePath": "file2.py"}{"filePath": "file3.py"}
It then logs a JSON parse error. The subsequent LiteLLM request fails in the Ollama request transformation:
json.loads(typed_tool["function"]["arguments"])
JSONDecodeError: Extra data: line 1 column 29
This suggests the malformed tool call is still being included in the conversation history sent on the next model call. The retries appear to resend the same invalid arguments and fail identically.
seoes commentedon Nov 23, 2026
Hi @pr0g88
Looks like the Ollama case with LiteLLM was fixed in BerriAI/litellm#49183. It should return index for each tool calling
The fix is in
v1.108.5and later (latestv1.108.15), but not inv1.109.xorv1.110.xyet. Can you try with one of those?If the error still occurs, let me know which LiteLLM version you're running and I'll look into it.
pr0g88 commentedon Nov 23, 2026
Thanks, you were right. I was running an older LiteLLM version. I’ll upgrade to v1.108.15 and test again.
seoes commentedon Nov 23, 2026
Great. Please let me know if it works. I should made an document for it
and again, thanks for reporting this issue. Agent loop got more reliable when tool calling failed (not only using litellm) thanks to you