Repository navigation
feat(tools): read an image file as an attachment for a model that sees - #1599
Merged
Merged
Conversation
Read hands an image file (by extension, or sniffed when it has none) to a vision model as an attachment the agent loop sends with the next message, instead of refusing every image. A text-only model, or a session without an image service, gets an error pointing at ImageDecode, which describes the image in words. The Read manifest and the golden tool definitions say so.
3 tasks
Contributor
|
🎉 This PR is included in version 0.235.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Read hands an image file to a vision model as an attachment the agent loop sends with the next message, instead of refusing every image. A text-only model, or a session without an image service, gets an error pointing at ImageDecode, which describes the image in words. A file without an extension that holds an image is sniffed and treated the same.
Seen in an OpenTask run where glm-5.3-flash, a vision model, had to go through ImageDecode for every screenshot it took, because Read turned image files away for every model.
Changes
internal/tools/read.go: an image file (by extension, or sniffed when it has none) is returned as an attachment when the gateway's modalities say the model takes images. Otherwise the error names ImageDecode. The sandbox path check runs first.internal/tools/registry.go: Read gets the image service.internal/tools/Read.yaml: the manifest says what happens with an image now.internal/tools/read_test.go: a table test for a vision model, a sniffed image, a text model and a session without an image service.internal/agent/loop/testdata/tool_definitions.golden.json: refreshed.Verification
go test -race ./internal/tools/,go test ./internal/agent/... ./internal/container/...,go vet,task lint:imports,task lint: all pass.Docs
A [DOCS] issue for inference-gateway/docs follows: the tools reference's Read entry and the vision page's line that says arbitrary images are read through ImageDecode.