mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2874] [CLOSED] serve: strata_prefix marks a chat whose history has pictures #4307
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#4307
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2874
Author: @stevie67
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:strata-prefix-images📝 Commits (1)
e3aef5eserve: strata_prefix marks a chat whose history has pictures (it was ignored for any request with an image)📊 Changes
3 files changed (+102 additions, -27 deletions)
View changed files
📝
docs/DETAILS.md(+7 -1)📝
serve/server.py(+36 -26)📝
serve/test_server.py(+59 -0)📄 Description
Issue: none open for this. Related, not resolved by it: #2255 (pinned prefixes filling the conversation cache).
Summary
"strata_prefix"was ignored for any request with an image in it (strata_prefix ignored: the request has images), so one photo anywhere in a chat's history turned it off until that message left the context. Pictures before the boundary now count with the tokens they take in the prompt, and the prefix is marked as for a text-only request.The use case: a chat client sends
{"messages": K}with K the index of its final user message. That message carries per-turn text (recalled memories, the clock) that the next turn replays without, so the turn checkpoint never matches again and only the system-prompt checkpoint was reused. With the pin, each turn resumes where the replayed history ends. A chat that once contained a photo lost this until now.What changed
serve/server.pyprepare()that turns each<|vision_start|><|image_pad|>into one pad per image token moved, unchanged, intoService.expand_image_pads(ids, counts).prepare()calls it with the encoded counts and keeps its "the prompt and its images do not match" check.resolve_prefix()takes the request's image token counts (image_counts, in prompt order) instead ofhas_images.head_ids()expands the rendered head's pictures with the same helper, so the longest common start runs through them. The refusal for images is gone.strata_prefix ... ignored: it ends inside a picture(only{"tokens": N}can land there; a message boundary cannot).serve/test_server.py, classSharedPrefix: three tests with a fake encoder whose two pictures take 3 and 5 tokens, so a wrong count or order misses the boundary:test_messages_resolve_past_a_picture_in_the_history: a photo in the history; the prefix ends at the final message's<|im_start|>and holds all 3 of its tokens.test_a_picture_after_the_prefix_stays_out_of_it: pictures on both sides; 3 tokens before the boundary, 5 after.test_a_token_boundary_inside_a_picture_is_ignored:{"tokens": N}inside the picture is ignored and said in the log.The first two failed before the change (ignored /
KeyError: 'tokens'); the third fails with the guard removed ({'tokens': 225} != {}).docs/DETAILS.md: the pinned-prefix paragraph says pictures count now, names the chat-client use, and gives the measurement below.What it leaves alone
strata_prefixtakes the same path as before:prepare()runs the moved loop with the same counts.test_without_the_field_nothing_changesand theImageMarkerstests (#150, #2228) pass unchanged.strata_prefixand no pictures:image_countsisNone, andhead_ids()returns what it did.pin=Nis one more cut in the same read loop as the turn and system-prompt checkpoints, which already handle pictures.How it was checked
python -m unittest discover -s serve -t . -p "test_*.py"on this branch (477ac13c+ this change, macOS, Python 3.14): 851 tests, 850 pass, 11 skipped. Againstmainwithout the change: 848 tests, 847 pass. The one failure is the same in both,test_keepawake.KeepAwakeTests.test_service_holds_for_the_whole_request_including_early_close, and it fails on this Mac without the change too.Live, on the DGX Spark port (#2419, engine 0.1.44.1; the same server patch applied there), GB10, Unsloth UD-Q4_K_XL, 131,072 context,
--kv int8, images on, 2026-10-17. A four-turn chat with a 640x400 PNG in its first message,{"messages": K}on every turn with history, per-turn text in the final user message:No
ignoredline in the server window. Turns 3 and 4 resumed at the pin of the turn before and still answered about the picture correctly (its colours and its text), so the picture's tokens come back intact from the pinned checkpoint.The same client in a real chat (23-31k tokens) before the change, with a photo 27 messages back: every turn reused only the system prompt's checkpoint and read 4.8-7.0k tokens (4.7-7.5 s) before answering.
Not tested
/v1/messagesand/v1/responsesrequests with pictures (they reachresolve_prefixthrough the sameprepare()).{"message": I, "chars": N}with pictures before message I (covered by the same expansion, no test of its own).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.