mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #582] [CLOSED] Serve tool result images #2706
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#2706
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/582
Author: @gopinath87607
Created: 10/3/2026
Status: ❌ Closed
Base:
main← Head:serve-tool-result-images📝 Commits (2)
35f4aaeserve (vision): an image inside a tool_result reached the model as an empty result07ec590serve (vision): an image source that fails is a 400, not an empty reply📊 Changes
3 files changed (+118 additions, -9 deletions)
View changed files
📝
serve/frontend.py(+16 -3)📝
serve/server.py(+16 -4)📝
serve/test_server.py(+86 -2)📄 Description
What this is
The Anthropic dialect flattened a tool's result through
_text_of(), which keeps the text partsonly, so an image a tool returned — Claude Code's
Readon a picture, a screenshot tool, a browsertool — was dropped with no error, no log line and no refusal. The model received an empty tool
result and answered anyway: a confident description of a picture it had never been given.
This is the shape Claude Code uses for every image its
Readtool returns, which is why imagescould work in one client and come back wrong in another.
Measured, before the fix
4-way IQ3_S rig, one image, three request shapes:
tool_result"tool"messageThe image contributes ~576 tokens, so 380 is the proof that it never arrived.
The fix
_parts_of()keeps it, and the pack's chat template already renders one image item per image for amessage of any role (
chat_template.jinja:8), so the rows land inside<tool_response>where thepicture belongs. A message holding an image beside a
tool_resultwas dropped the same way and nowkeeps it too.
A text-only result is unchanged:
_parts_of()returns a plain string when there is no image.After: 959 prompt tokens and "The letter Q inside a green circle on a purple background."
A bad image source, folded in
The second commit is the same API surface:
Vision.loadletOSErrorout of every fetch — a 404(
HTTPError), a refused connection or an unknown host (URLError) are allOSError— and adata:URL with no comma raised
IndexError. The dispatcher maps onlyValueErrorto a status, so all ofthose closed the client's connection with no reply at all (
curl: (52) Empty reply from server)instead of a 400. Every branch of
loadnow raisesValueErrorsaying what went wrong, like the lastline already did. It sat in the Monitor's commit on the old branch; it is an image-API fix, so it is
here rather than there.
Testing
serve/test_server.py'sToolResultImages: the image survives andimages_of()finds it, atext-only result is unchanged, an image beside a tool result survives, and the rendered prompt gets
the encoder's rows.
BadImageSourcepins the 400: a 404, a refused connection, an unknown host, adata:URL that is not base64, and a file that cannot be read all raiseValueError, and a readablesource still loads.
serve's 126 tests pass onv0.1.38(python3 -m unittest serve.test_server).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.