magpie's built-in Devin (internal/gateway/devin.go buildDevin) sends the images a tool returned on the tool message that answers the call (inlineImages(p.Images), field 10). A chat's tool message holds text alone, so magpie's gateway hands the plugin those images in the user message after the results (buildChat's seeLater: "[From the result of <tool> (tool call <id>):]" then the images, and the result's text ends "[The tool returned an image; it follows in the next message.]"). The plugin sent them to Devin as a user message of their own, and a tool message's own image_url parts were dropped. build() now puts each result's images back on its tool message: the images under a heading naming a result just sent, up to the number its note says (so the user's own images after them stay the user's), and a tool message's own data: image_url parts. The note is taken off the result's text when every image it names went back with it; an empty result is "(no output)", as the built-in words it. Images without bytes (URLs) are left out, as inlineImages leaves them. A heading that names no result just sent is left as the user's text. Run: - bun test in packages/devin under a mktemp HOME: 93 pass, 0 fail. - bun scripts/check.mjs devin: ok. - tool-images.test.mjs against the old index.mjs: 3 of its 4 tests red (the fourth guards a heading naming no result, which held before too). With the count limit broken by hand (images past the note's number taken as the tool's), the two-results test goes red. - The fixtures in testdata/ are magpie's literal buildChat output at origin/main b03031738, captured with a throwaway test in a separate magpie worktree (codexViewImage, and an Anthropic request with two Read results and the user's own image). Not tried: a real Devin account (whether Devin's model reads a tool message's images better than a user message's was not measured); OpenCode itself, outside magpie, whose own shape for a tool's images was not read.
1 line
857 B
JSON
1 line
857 B
JSON
{"max_tokens":10,"messages":[{"content":"shot","role":"user"},{"role":"assistant","tool_calls":[{"function":{"arguments":"{\"p\":\"a.png\"}","name":"Read"},"id":"toolu_1","type":"function"},{"function":{"arguments":"{\"p\":\"b.png\"}","name":"Read"},"id":"toolu_2","type":"function"}]},{"content":"two pics\n\n[The tool returned 2 images; they follow in the next message.]","role":"tool","tool_call_id":"toolu_1"},{"content":"plain","role":"tool","tool_call_id":"toolu_2"},{"content":[{"text":"[From the result of Read (tool call toolu_1):]","type":"text"},{"image_url":{"url":"data:image/png;base64,AAAA"},"type":"image_url"},{"image_url":{"url":"data:image/jpeg;base64,BBBB"},"type":"image_url"},{"image_url":{"url":"data:image/gif;base64,CCCC"},"type":"image_url"},{"text":"what are these?","type":"text"}],"role":"user"}],"model":"swe-2","stream":false} |