Skip to content

fix(acp): forward image tool-result blocks to ACP clients#562

Open
SharanKarchella wants to merge 1 commit into
getkimchi:masterfrom
SharanKarchella:fix/acp-forward-nontext-tool-results
Open

fix(acp): forward image tool-result blocks to ACP clients#562
SharanKarchella wants to merge 1 commit into
getkimchi:masterfrom
SharanKarchella:fix/acp-forward-nontext-tool-results

Conversation

@SharanKarchella

Copy link
Copy Markdown

Description

toolResultContent() in src/modes/acp/server.ts forwarded only text blocks to ACP clients, so image blocks in a tool result were silently dropped — a client like Zed saw a completed tool call with empty content. This resolves the maintainer TODO on that function.

Resolves the maintainer TODO in toolResultContent (src/modes/acp/server.ts).

What actually reaches this code (AGENTS.md "Before Adding Features" check)

The ACP tool-result translation is local to this repo: node_modules/@earendil-works/pi-coding-agent/dist has no @agentclientprotocol / toolResultContent references, so this is the correct layer to fix (not upstream).

Tool-result content is typed by pi-ai as (TextContent | ImageContent)[] (ToolResultMessage). Therefore:

  • image blocks genuinely occur (web_fetch, or an MCP image tool whose block survives the bridge) and were the ones being dropped → fixed here.
  • resource / resource_link / audio blocks never reach toolResultContent: the MCP bridge transformMcpContent() (src/extensions/mcp-adapter/tool-registrar.ts) already flattens them to text. A resource branch here would be unreachable dead code, so the stale TODO comment is corrected instead. True resource passthrough would require an upstream pi-ai change (worth a separate follow-up issue).

Changes

  • Forward image tool-result blocks as ACP { type: "content", content: { type: "image", data, mimeType } }, mirroring the existing inbound prompt → pi-ai image mapping in server.ts. Guarded on data/mimeType being strings, consistent with the text branch.
  • Replace the stale TODO with a comment describing the real data flow.
  • Tests (extending the existing tool execution stream suite): image on tool_execution_end, image on a streaming partialResult, and mixed text+image ordering.

Verification

  • pnpm run check (biome lint + tsc --noEmit) — passes.
  • pnpm run test — full unit suite green (299 files, 4589 passed / 3 skipped); the ACP server test file is 124/124 (3 new).

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

toolResultContent() forwarded only text blocks, so image blocks (e.g.
from web_fetch, or an MCP image tool whose block survives
transformMcpContent) were dropped and ACP clients like Zed saw a
completed tool call with empty content. Resolves the maintainer TODO.

pi-ai types tool-result content as (TextContent | ImageContent)[], and
the MCP bridge (transformMcpContent) already flattens resource /
resource_link / audio to text, so image is the only non-text block that
reaches this translation. The TODO's note about dropped MCP resource
blocks no longer applies; the comment now describes the real data flow
(true resource passthrough would need an upstream pi-ai change).

Tests cover the end-result path, the streaming partial path, and mixed
text+image ordering.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@readme-ai-writer

readme-ai-writer Bot commented Jun 10, 2026

Copy link
Copy Markdown

Documentation Changes Added

Page Section Action Summary
coding-acpGuides📝 UpdatedUpdate ACP page to remove the "Non-text tool results" limitation and update the troubleshooting section, since image tool-result blocks are now properly forwarded to ACP clients.

🔗 View all changes in ReadMe


Actions

  • Merge documentation branch with PR merge
  • Delete documentation branch with PR close

If neither actions are selected, on PR close/merge the docs branch in ReadMe will remain open.

@kimchi-review

kimchi-review Bot commented Jun 10, 2026

Copy link
Copy Markdown

Kimchi Code Review

Property Value
Commit 5230ec1
Author @SharanKarchella
Files changed 0
Review status Completed
Comments 0
Duration 160s

Summary

📊 Review Score: 93/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 2/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — Three targeted tests were added: one for image-only tool_execution_end, one for image blocks in streaming partialResult, and one verifying mixed text/image ordering. Together they cover both call sites that use toolResultContent.

No significant issues found. LGTM! 🎉

What to expect

Kimchi will analyze the changes in this pull request and post:

  • A summary of the overall changes
  • Inline comments on specific lines with findings categorized by issue type

The review typically completes within a few minutes. This comment will be updated once the review is ready.

Interact with Kimchi
  • @getkimchi review — re-trigger a full review on the latest commit
  • @getkimchi summary — regenerate the PR summary
  • @getkimchi ignore — skip this PR (no review will be posted)
  • Reply to any inline comment to ask follow-up questions or request clarification
Configuration

Reviews are configured by your organization admin.
Review instructions, excluded directories, and severity thresholds can be adjusted per repository in the Kimchi dashboard.


Powered by Kimchi — AI-powered code review by CAST AI

@kimchi-review kimchi-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Review Score: 93/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 2/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — Three targeted tests were added: one for image-only tool_execution_end, one for image blocks in streaming partialResult, and one verifying mixed text/image ordering. Together they cover both call sites that use toolResultContent.

No significant issues found. LGTM! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant