agy-cli 0.1.45: a tool result's image goes to agy as a prompt image, not an offloaded file (distinceeeee on X)

Report: on agy-cli 0.1.43 with agy 1.5.8, when OpenCode's read tool
returns a screenshot, agy writes the image to
.system_generated/steps/N/media_0.jpg. The model never sees the image and
keeps re-reading files.

Cause: the bridge answered agy's MCP tools/call with the image as MCP
image content. agy offloads MCP images to a file, and its model only gets
"Image read successfully [Resource offloaded to file://…]". There are no
image tokens, so it loops trying to get the image back.

Fix: when agy supports prompt images and a tool result carries an image,
the result takes the steer-in-session path. The MCP call is answered with
its text plus a line saying the image follows. The image goes in the next
session/prompt as an ACP image block, in the same session, so it reaches
the model as an image. withoutAnswered keeps an answered result's images
in the prompt and drops the rest. If steering fails, the existing replay
fallback already sends tool_result images as prompt images. An agy
without image support keeps the old MCP path.

Run:
- Real agy 1.5.8 (macOS), sandbox HOME and sandbox keychain,
  gemini-3.8-flash-high, through a harness that drives the plugin's fetch
  with an OpenCode-style read tool:
  - origin/main: shot.jpg and term.png each looped through 8 reads
    without an answer.
  - This change: 1 read each. shot.jpg was answered correctly
    ("PLUM-7342 ORBIT", red circle, blue square, green triangle).
    term.png was answered correctly twice (all five terminal lines,
    including "TOKEN: ZEBRA-5519", and the yellow rectangle).
- WSL magpie-desktop (Ubuntu 24.04), bun 1.4.2, temp HOME:
  - packages/agy-cli `bun test`: 21 pass, 0 fail.
  - `node test/smoke.mjs`: ALL OK (347 checks).
  - `bun scripts/check.mjs agy-cli`: ok.
- Broken by hand: smoke.mjs with origin/main's index.mjs fails exactly
  the two image checks this change adds or rewrites (2 FAILURES of 347).

Not tried:
- Gemini 4 Carbon: not offered to the test account.
- Real agy on Linux, and a real OpenCode front end.
- stream:true against real agy (the harness is non-streaming; smoke
  covers SSE).
This commit is contained in:
yetone
2026-11-14 18:20:54 +08:00
parent 1dbbc1fb48
commit 6e0cecb2a0
5 changed files with 71 additions and 15 deletions
+2 -1
View File
@@ -55,7 +55,8 @@ agy 连接 `--ide-mcp-port` 时会运行 `nc 127.0.0.1 <端口>`。插件在 agy
历史保留。
- **流式输出与思考摘要**:思考摘要以 `thinking` 块返回,设置 `AGY_BRIDGE_THINKING=0` 可关闭。
- **图片输入**:支持内联 base64 的 PNG、JPEG、GIF、WebP。需要 agy 1.5.0 或更新版本,
因为图片能力要由 ACP 服务端声明。
因为图片能力要由 ACP 服务端声明。工具返回的图片(如 `read` 读到的截图)也作为提示里的
图片交给 agy:走 MCP 的话,agy 会把它存成文件,模型看不到。
- **工具调用**:支持并行和连续调用。运行超过 150 秒的工具会先收到 "still running" 的
占位响应,真正的结果送达后继续同一轮对话,每个调用只在客户端执行一次。
- **会话续接**:每轮结束后记录会话。重启 Magpie 或插件后,只要历史和指令的哈希一致,