[Bug] ACP: content-part tool results (image reads, multi-part MCP output, executor errors) are sent to the editor as a JSON string

Đang mở
#5,229 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
tooling

Hướng nghiên cứu

Start in packages/acp-server/src/convert.ts at toolResultToAcpContent, which currently only handles string output and falls back to JSON.stringify. Compare it with the part-by-part mapping already done in replay.ts, and mirror that: text parts to text blocks, base64 images to image blocks, other parts to a [type] placeholder, [] to no content. Add cases to packages/acp-server/test/convert.test.ts; done means those pass and string, hidden and other outputs are unchanged.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

What version of Kimi Code is running?

2.7.2 (source main at e12cad1, 2026-11-22). Reproduced with a unit test on toolResultToAcpContent.

Which open platform/subscription were you using?

None involved. This is in the ACP server (kimi acp).

Which model were you using?

None involved. Any model.

What platform is your computer?

Darwin 25.6.0 arm64 arm (the code path is platform-independent).

What issue are you seeing?

In ACP mode (Zed, JetBrains or any ACP client), tool results whose output is a content-part array are sent to the editor as a single JSON string, not as readable content.

toolResultToAcpContent in packages/acp-server/src/convert.ts handles only string outputs. Anything else goes through JSON.stringify:

  if (typeof out === 'string') {
    if (out.length === 0) return [];
    return [{ type: 'content', content: { type: 'text', text: out } }];
  }
  let text: string;
  try {
    text = JSON.stringify(out);
  } catch {
    text = '[object]';
  }

A content-part array (ContentPart[]) is the normal output shape for several kinds of tool result:

  • MCP tool results with more than one content block or with an image (a single text block is collapsed to a string first)
  • ReadMediaFile image reads
  • tool calls that end with an executor-level error (timed out, cancelled or abandoned): the executor's output is [{ type: 'text', text: reason }]
  • a call that ends with no result and no error: [], which the editor shows as the text []

So the editor's tool panel shows things like [{"type":"text","text":"…"}]. For an image read it shows the whole data:image/png;base64,… URL as text, which can be hundreds of KB. ACP has native text and image content blocks for this.

Session replay (replay.ts) already maps stored tool content part by part: text parts become text blocks and other parts become a [type] placeholder. So the live view and the replayed view of the same tool call differ.

What steps can reproduce the bug?
  1. Run kimi acp from an ACP client.
  2. Ask the agent to read an image file (ReadMediaFile), or call an MCP tool that returns several content blocks or an image, such as a browser screenshot tool.
  3. Look at the tool call output in the editor.

Unit-level, calling the real converter:

toolResultToAcpContent({ type: 'tool.result', origin: 'loop', turnId: 1, toolCallId: 'c',
  output: [{ type: 'text', text: 'tool failed: boom' }], isError: true })

returns

[{ "type": "content", "content": { "type": "text", "text": "[{\"type\":\"text\",\"text\":\"tool failed: boom\"}]" } }]

For [{ type: 'text', … }, { type: 'image_url', imageUrl: { url: 'data:image/png;base64,…' } }], the single text block contains the full base64 data URL.

What is the expected behavior?
  • Text parts are sent as ACP text blocks.
  • Base64 image parts are sent as ACP image blocks.
  • Other parts get the same [type] placeholder that session replay uses.
  • An empty array produces no content.

rawOutput keeps carrying the full structure, and string outputs, hidden outputs and other values are unchanged.

Additional information

The fix is local to toolResultToAcpContent, plus tests in packages/acp-server/test/convert.test.ts. I have it ready with regression tests that fail on current main, and can open the PR once this is approved.

Ngôn ngữ chính
TypeScript
Star
8.3k
Fork
1.4k
Merge trung bình
12 giờ 6 phút
Pull request đã merge (30 ngày)
596

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của MoonshotAI/kimi-code

Tất cả issue của MoonshotAI/kimi-code

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.