[GH-ISSUE #252] bug: unguarded json.loads on streamed tool-call arguments crashes the request on empty/truncated JSON #165

Open
opened 2026-10-18 14:03:30 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @1-kabir on GitHub (Sep 5, 2026).
Original GitHub issue: https://github.com/open-webui/computer/issues/252

bug: unguarded json.loads on streamed tool-call arguments crashes the request on empty/truncated JSON

Bug description

Providers occasionally stream empty or truncated tool-call argument JSON
(e.g. output cut off by token limits or an upstream hiccup). The unguarded
json.loads() on streamed arguments then raises JSONDecodeError, which
surfaces to the user as a raw error and aborts the in-flight step:

Error: Expecting value: line 1 column 1 (char 0)

This is provider-agnostic — any of the streaming providers can emit an empty
or truncated arguments payload.

Expected behavior

A malformed/empty streamed arguments payload should degrade gracefully, not
kill the request.

Suggested approach

Add a shared parse helper that:

  1. Parses strictly,
  2. Falls back to the existing lenient extract_json() helper,
  3. On total failure, raises a descriptive error naming the tool and including a payload snippet (instead of a bare JSONDecodeError).

Apply it to all streaming providers (Anthropic, OpenAI chat completions,
OpenAI Responses) and to Anthropic history replay, where a stale corrupt
payload in history should degrade to {} rather than breaking the current
request.

Environment

  • Latest main

Originally created by @1-kabir on GitHub (Sep 5, 2026). Original GitHub issue: https://github.com/open-webui/computer/issues/252 bug: unguarded `json.loads` on streamed tool-call arguments crashes the request on empty/truncated JSON ### Bug description Providers occasionally stream empty or truncated tool-call argument JSON (e.g. output cut off by token limits or an upstream hiccup). The unguarded `json.loads()` on streamed arguments then raises `JSONDecodeError`, which surfaces to the user as a raw error and aborts the in-flight step: ``` Error: Expecting value: line 1 column 1 (char 0) ``` This is provider-agnostic — any of the streaming providers can emit an empty or truncated arguments payload. ### Expected behavior A malformed/empty streamed arguments payload should degrade gracefully, not kill the request. ### Suggested approach Add a shared parse helper that: 1. Parses strictly, 2. Falls back to the existing lenient `extract_json()` helper, 3. On total failure, raises a descriptive error naming the tool and including a payload snippet (instead of a bare JSONDecodeError). Apply it to all streaming providers (Anthropic, OpenAI chat completions, OpenAI Responses) and to Anthropic history replay, where a stale corrupt payload in history should degrade to `{}` rather than breaking the current request. ### Environment - Latest main ---
Author
Owner

@owui-terminator[bot] commented on GitHub (Sep 5, 2026):

🔍 Related Issues Found

I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:

  1. 🟣 #196 bug: tool-call arguments are never captured — input_json_delta fragments are ignored
    This is the closest related issue in the same Anthropic/streaming tool-call path. It also concerns handling streamed tool-call arguments correctly, though it focuses on lost input_json_delta fragments rather than crashes from malformed JSON.
    by penradioGables

  2. 🟣 #96 bug: OpenAI-compatible streaming usage can end responses early
    This issue is about streaming-provider edge cases in OpenAI-compatible flows causing requests to terminate early. It is not about tool-call JSON parsing specifically, but it is adjacent to the same class of streaming robustness bugs.
    by sandrogauci


💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead.

This comment was generated automatically. React with 👍 if helpful, 👎 if not.

<!-- gh-comment-id:5550970621 --> @owui-terminator[bot] commented on GitHub (Sep 5, 2026): <!-- terminator-bot:related-issues-reply --> 🔍 **Related Issues Found** I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions: 1. 🟣 [#196](https://github.com/open-webui/computer/issues/196) **bug: tool-call arguments are never captured — `input_json_delta` fragments are ignored** *This is the closest related issue in the same Anthropic/streaming tool-call path. It also concerns handling streamed tool-call arguments correctly, though it focuses on lost `input_json_delta` fragments rather than crashes from malformed JSON.* *by penradioGables* 2. 🟣 [#96](https://github.com/open-webui/computer/issues/96) **bug: OpenAI-compatible streaming usage can end responses early** *This issue is about streaming-provider edge cases in OpenAI-compatible flows causing requests to terminate early. It is not about tool-call JSON parsing specifically, but it is adjacent to the same class of streaming robustness bugs.* *by sandrogauci* --- 💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead. *This comment was generated automatically.* React with 👍 if helpful, 👎 if not.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/computer#165
No description provided.