Skip to content

Kingy / AI Fix Finder

← All fixes

Parsing each streamed tool-argument fragment as JSON fails

Check this fix ↓

The owned client treated an incomplete argument delta as a whole JSON document. Assembling the complete call restored its original inventory task without changing the model request.

kingy tested

Tested repair · llama.cpp + Python client · llama.cpp 0.6.0 b11429; Qwen3-4B Q4_K_M; Python 3.14.0

Check this fix

Applies when
The reference streaming client raises JSONDecodeError on an arguments delta such as an opening brace; the complete tool arguments arrive over multiple events.
Change to inspect
Accumulate tool-call argument fragments by call index and validate only after a complete tool_calls finish and DONE. Then validate the allowed function and exact arguments before supplying the harmless fixture result and requesting the final answer.
Expected result
0/3 baseline full-task passes, 3/3 corrected passes and 0/1 reverted passes. Each repair uses its own seven attempts; corrected generations are not counted twice.
If it still fails
Keep the original failed output and check the conditions and verification steps below. Retained failed attempt: All three baseline attempts and the reverted attempt failed the unchanged full-task checker; raw requests, responses and client errors are retained.

Tested or reviewed 2026-10-27. Verify the original task on your own version and settings; this case does not prove a universal fix.

Read the verification steps ↓ · Report your outcome ↓

What happened

Symptom

The reference streaming client raises JSONDecodeError on an arguments delta such as an opening brace; the complete tool arguments arrive over multiple events.

Exact environment and tested conditions

Same exact pinned local runtime/model and original synthetic task; see evidence packet for full requests.

Owned Python reference integration; POST /v1/chat/completions on a loopback-only server.

Correction

Accumulate tool-call argument fragments by call index and validate only after a complete tool_calls finish and DONE. Then validate the allowed function and exact arguments before supplying the harmless fixture result and requesting the final answer.

Result

0/3 baseline full-task passes, 3/3 corrected passes and 0/1 reverted passes. Each repair uses its own seven attempts; corrected generations are not counted twice.

What did not work

All three baseline attempts and the reverted attempt failed the unchanged full-task checker; raw requests, responses and client errors are retained.

  1. Keep argument deltas provisional. For this single-choice/single-call fixture, collect the call identity/name and append argument fragments for index 0.
  2. Require finish_reason=tool_calls, DONE and a complete allowed lookup_stock call with exactly sku KINGY-017. Reject missing completion, changed identity or malformed arguments before any operation.
  3. Supply only the owned synthetic result stock 37 with the actual tool_call_id; append the assembled assistant call and make the final request with tool_choice=none.
  4. Require the exact final answer Stock for KINGY-017: 37. with finish_reason=stop. No generated code, external inventory lookup or other tool is executed.
Sources & limits

Four client/configuration repairs: full qualification report, exact changes and limits

Download four client repairs evidence ZIP (105,390 bytes; SHA-256 3896413bb91395bd1634be0491ba3fc7a0f4cbba8d5c55416a2d52e246bb6ed1)

Pinned llama.cpp server API documentation for tested build d81235049

Record checked 2026-10-27.

Qualified October 27, 2026 by the same agent in one fresh server process on one Apple M4 Pro Mac with 24 GiB unified memory; no independent operator, second machine or human usability outcome.

Three baseline failures, three corrected full-task passes and one reverted failure per repair. These are fixed synthetic integration tasks chosen after exploration, not a general reliability estimate or evidence of user demand.

llama.cpp 0.6.0 build 11429 commit d81235049, Qwen3-4B Q4_K_M, Python 3.14.0; CPU-only four threads, one slot, 2048-token context, reasoning off, temperature 0, seed 42 and cache_prompt=false.

The failing clients/settings are owned reference integrations. These tests do not establish an installed application defect or an upstream runtime fix. Runtime binaries and model weights are excluded from the package.

The reference decoder supports the retained complete LF-delimited, UTF-8 SSE bodies for one choice and one call only. It is not a general network client. Real multi-call clients need index separation and appropriate execution permissions/idempotency. This repairs assembly before history commitment, rather than the existing rejection/retry of an already malformed history turn.

This still happens?

Send the smallest example that reproduces it. Use a public, non-sensitive example; leave out account details, keys and private files.

Help improve this tool

Did this repair work for you?

About AI Fix Finder. Your self-reported outcome goes to Kingy’s private review queue; it is not an independently verified reproduction.

Your experience with AI Fix Finder
What happened?