mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #3171] [Bug]: elastic vision — a tool-returned image crashes the request (400 "malformed", AttributeError on a None encoder proc) #1278
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#1278
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 @Lithivm on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3171
What happened
With the elastic image encoder (
vram_elastic: true+ vision"elastic": true), any request that carries an image a tool returned fails with a 400 and an internalAttributeError, because the encoder is not running yet and nothing starts it on that path.An agent hits this continuously: a tool that reads an image file (Claude Code's
Readof a screenshot, an MCP tool returning a plot) breaks the whole turn — and since clients resend history, the same picture can break the next turns too.Reproduction — no waiting involved
The encoder has not started in a fresh elastic session (it starts with the first picture), so this reproduces on the first request:
"vram_elastic": trueand"vision": {"gpu": true, "elastic": true, ...}; start the server.strata-vision.exeis not running (expected for elastic).The same request succeeds with
"elastic": false(the encoder is started with the model, soVision.procis neverNone), which is the current workaround. A user-sent image works too — only the tool-returned path fails.Traceback
(line numbers are 0.1.44.1; it arrives through
/v1/responseshere and through/v1/messagesin the repro)Cause
The two places that encode a request's pictures are not symmetric.
prepare()starts an elastic encoder before encoding:_note_unreadable_tool_images()(called earlier fromprepare(), for pictures a tool returned) encodes without it:Vision.encode()writes toself.proc.stdinunconditionally, so with an elastic encoder that has not started (or has stopped afterelastic_idle_s) it raisesAttributeError. That function'sexcept (ValueError, OSError)does not catch it, so the exception escapesprepare()and lands in_post's genericexcept (TypeError, KeyError, AttributeError, IndexError, UnicodeError), which reports any such internal error as400 invalid_request_error("the request is malformed") — hence a server bug that looks like a client bug. This is present onmain(76e51103):prepare()has the_vision_up()call at line 4345-4346,_note_unreadable_tool_images()has none.Suggested fix
Start the encoder there too, exactly as the sibling path does (PR follows):
_vision_up()is a no-op when the encoder is not elastic or is already running, so this changes nothing for non-elastic setups.Two smaller things seen on the way, both separate from the fix above:
_note_unreadable_tool_images()exists so that an unreadable tool picture becomes[image omitted: ...]instead of a 400. Widening itsexcepttoAttributeError(or toException) would keep that promise for unexpected failures as well — right now an internal error on this path defeats the function's own purpose._post's generic handler maps anyAttributeErrorraised while preparing a request to400 invalid_request_error. That is how this surfaced as "the request is malformed": the message sent the reporter looking at their own client. An internal error is a 500.Environment
--kv q4_0,--mmap-experts,--vram-reserve-mib 1600,--vram-elastic"vision": {"gpu": true, "max_tokens": 1024, "elastic": true, "elastic_mib": 3584, "elastic_idle_s": 120},"vram_elastic": trueRelated but different: #2454 (an elastic encoder re-starts on every turn whose history re-sends a cached picture — a churn/wall-time issue, not a crash).
@jerry78424 commented on GitHub (Oct 19, 2026):
Cross-link: #2641 (opened 10/15) has a pending fix for this root cause — the missing
_vision_up()on the tool-image path, plus the two sides that adding a wake there brings (the turn updateslast_image_atin afinallyso the idle sweep doesn't reclaim the just-started encoder;RuntimeErrorjoins the except filter so a failing start becomes the documented note, not a dead request), with regression tests. Your repro here matches ours exactly. #3174 is the same core fix; happy with whichever PR the maintainer prefers to land, andFixes #3171will close this one with it.