mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #150] Error during DeepSeek Harness chat: This turn failed the prompt has more images than the embeddings file PI_AI_ERROR #81
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#81
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ecatvids-glitch on GitHub (Sep 29, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/150
Error as per the title. I have no idea what is going on, but the strata downloaded qwen coder says (and apologies if this is to verbose):
Strata version: 0.1.24 (
/props→build_info)Model:
Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M-00001-of-00002.gguf+mmproj-Qwen3.8-Flash-Next-BF16.gguf(--vision gpu)Platform: Windows,
serve.server --engine strata --port 8080Summary
A
/v1/chat/completionsrequest that carries at least one image and whose message text happens to contain a literal special token — in practice<|im_start|>— is rejected with:The token is not in an image part. It is plain text that came from a web page, a source file, or a chat-template document. The tokenizer turns it into a real image-pad id, so the prompt ends up with more image markers than the embeddings file has images, and the engine refuses the request.
This is not a cap and not a size limit: the same server accepts 24 images at ~1 MiB each (a ~110 MB request body) and 16 images at 2048×2048 without complaint.
Reproduction
Self-contained (Node 18+, no dependencies, no image files needed — it builds a 64×64 PNG in memory):
Observed on the live server:
200— answers normally400 the prompt has more images than the embeddings file200— answers normallyA and B differ by one string in the text. C shows the trigger needs both halves: a literal token and at least one image in the same request.
Root cause
prepare()renders the template and tokenizes the whole prompt withparse_special=True:Message text reaches that render call verbatim —
serve/frontend.py:_parts_of(line 122) appendspart.get("text", "")unchanged — so a special token sitting inside a text item becomes a real<|im_start|>id inids.The expansion loop then treats that phantom id as an image slot, but the image list is already exhausted, so it falls through to the
elsebranch and stays a bare pad token:So the Python guard only catches the fewer markers than images direction. The opposite direction — more markers than images — survives
prepare()and is only caught in the engine, which walks the markers against the combined.svefile:The neighbouring checks at
generate.cpp:3636(the embeddings file has more images than the prompt) and:3637(the prompt cannot end in an image) are reachable the same way, so they are worth covering together.Text-only requests are unaffected because
prepare()skips the whole vision branch whenimagesis empty (serve/server.py:714), and the engine takesGENrather thanGENI.Why this matters for agent clients
Any client that puts fetched web pages, source files, or documentation into tool results will hit this the moment the conversation also carries an image — llama.cpp, Qwen-VL, and mmproj docs are full of the literal token. The failure is a hard
400on a turn whose history is already durable, so the conversation cannot be retried without losing the turn.Suggested fix
Neutralize special-token syntax in message text before it is rendered, leaving the markers the template itself emits untouched. The narrow place to do it is
serve/frontend.py, where text items are collected (_text_ofat line 51 and_parts_ofat lines 110-123):Escaping rather than dropping keeps the text readable to the model (these strings are exactly what vision-related questions are about). Alternatives that would also work: encode text spans with
parse_special=Falseand splice the template's markers in as ids, or count phantom markers inprepare()and fail with a clear message that names the offending text.Notes for the maintainer
/propsreportsn_ctx: 131072,modalities.vision: true;/healthreportsmax_context: 131072.@Niko1221 commented on GitHub (Sep 29, 2026):
Thanks for the clear repro, confirmed on main. A literal
<|image_pad|>in message text is tokenized as a real image marker, so the counts no longer match. (It's only that marker; other control tokens in the text don't cause this 400.) We'll make the server expand only the markers the template emits for images and add your repro as a test.@Niko1221 commented on GitHub (Sep 29, 2026):
Fixed in 0.1.27: only the image markers the chat template writes (right after
<|vision_start|>) become images. The same text inside a message stays plain text, so an image plus<|image_pad|>in the message no longer gives the 400. Your repro is now a server test. Thanks @ecatvids-glitch!