Skip to content

Kingy / AI Fix Finder

← All fixes

Qwen3 schema request fails with an old assistant prefill

Check this fix ↓

On the tested build, an old empty-thinking assistant prefill caused HTTP 400. Removing that appended message restored the exact JSON task.

kingy tested

Tested repair · llama.cpp + Qwen3-4B · llama.cpp 0.6.0 b11429; Qwen3-4B Q4_K_M; pinned SHA-256 in evidence

Check this fix

Applies when
A schema-constrained chat request returns HTTP 400: Failed to initialize samplers: std::exception after appending an assistant message containing <think>\n\n</think>\n\n.
Change to inspect
Remove the manually appended empty-thinking assistant message. Keep the original user message, schema, output budget and model template unchanged; let the template create the generation prompt.
Expected result
In each of two fresh-process runs: 0/3 baseline task passes, 3/3 corrected passes and 0/1 reverted passes. All original task checks and scoped completion checks passed. The offline audit recomputed acceptance from raw responses and rejected six damaged corrected-response controls.
If it still fails
Keep the original failed output and check the conditions and verification steps below. Retained failed attempt: The historical assistant-prefill workaround failed with HTTP 400 in the exploratory run; the original no-prefill request and a supported thinking-off control worked.

Tested or reviewed 2026-10-16. 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 ↓

Check this failure on your own input

Start with the original example, then replace it with a non-sensitive request and response. Compare the observed condition with the correction below.

Download this case’s input and verification checklist

Run this case’s local diagnostic

Free browser-local debugger

Why did my AI response fail?

Check an empty answer, context overflow, missing fields, incomplete tool history, cache evidence, Unicode stream framing, or a schema sent to the wrong endpoint. Inspect a proposed change, then verify it against your original task.

Pasted data stays in this tab. This debugger makes no API calls, executes no tools, and saves no inputs. Diagnosis does not prove a correction works on your setup.

Try a retained example or paste your own JSON below.

What to verify after the correction

Up to 40,000 characters per box. Use the final assembled Chat Completions JSON body, not an individual streaming fragment, cURL command, or HTTP headers. Complete text-only SSE with a stop event and [DONE] is also supported; imported text is already decoded by your browser. Native /completion requests are supported for schema-envelope checks. Leave keys and account details out.

Context counts and local file import

Use measured runtime counts, including template, history and tools. This tool does not estimate tokens from character count or predict memory fit.

Loading local debugger…

Enter the full runtime and build to compare its exact text with the documented case. A match does not verify your model, configuration or repair; check the other case conditions too. The comparison status and documented version, but not your input, are included in the diagnosis download. For JSON or CSV, check the output in Output Preflight after a change; this does not establish factual accuracy.

Evidence and supported scope

Rules reuse the ten completed pilot repairs listed below. Model tests used pinned llama.cpp 0.6.0 b11429 and Qwen3-4B Q4_K_M on one Mac. The first four have separate-agent reruns on that Mac; the remaining six have same-agent repeats. No second-machine, human reproduction, or universal compatibility is claimed. Example previews replay retained data; they run no new model inference.

Malformed JSON, conflicting schemas and unsupported response shapes remain unresolved. A parseable response can still contain wrong facts. Schema-envelope proposals preserve the supplied schema; they do not establish general schema support.

What happened

Symptom

A schema-constrained chat request returns HTTP 400: Failed to initialize samplers: std::exception after appending an assistant message containing <think>\n\n</think>\n\n.

Exact environment and tested conditions

Qualified 2026-10-16 Pacific on llama.cpp 0.6.0 build 11429 (d81235049), Qwen3-4B Q4_K_M; exact artifact SHA-256 in the package.

Apple M4 Pro, 24 GiB unified memory, macOS 26.3; CPU only, two threads, one slot, 2048-token context; loopback/offline.

For each repair, the same agent completed two seven-trial sequences in fresh server processes on the same Mac. Unchanged passing case runs were reused; the evidence index identifies them.

Correction

Remove the manually appended empty-thinking assistant message. Keep the original user message, schema, output budget and model template unchanged; let the template create the generation prompt.

Result

In each of two fresh-process runs: 0/3 baseline task passes, 3/3 corrected passes and 0/1 reverted passes. All original task checks and scoped completion checks passed. The offline audit recomputed acceptance from raw responses and rejected six damaged corrected-response controls.

What did not work

The historical assistant-prefill workaround failed with HTTP 400 in the exploratory run; the original no-prefill request and a supported thinking-off control worked.

  1. Compare the frozen request and prefill in fixtures/005-prefill.json before changing your client.
  2. Remove only the final manually added assistant prefill. Preserve real conversation history and the original JSON schema.
  3. Repeat the same extraction request. Require the exact array containing id 17 and text ALPHA, plus finish_reason=stop.
  4. Retain the raw HTTP error and corrected response. The package includes a restored-prefill negative control.
Sources & limits

Repair 005: full current qualification report and limits

Download repairs 005-010 evidence ZIP (412,621 bytes; SHA-256 8a3e0d0b0f217f30e583450c7073dd1558ce75b9bb8f0e3e8f348e6260a28b93)

Record checked 2026-10-16.

Same-agent repeatability checks on one Mac; no independent operator, second machine or human acceptance test.

Fixed synthetic tasks selected after exploration. The repeat counts do not establish a general reliability rate or support for other models and builds.

Runtime binaries and model weights are excluded. Exploratory failures, the failed first qualification fixture and all final trial responses are retained.

Client demonstrations identify owned reference integrations and injected inputs explicitly; they are not claims of a repaired Open WebUI release or a general llama.cpp bug fix.

The 2025 upstream empty-response defect was not reproduced: the request without prefill already worked. This repair addresses the obsolete workaround failing on the pinned 2026 build.

Do not remove genuine assistant history or assume every kind of assistant prefill is invalid.

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?