Skip to content

feat(acp): add support for file reference in ACP protocol#1063

Closed
xiaoju111a wants to merge 1 commit intoMoonshotAI:mainfrom
xiaoju111a:fix-acp-file-reference
Closed

feat(acp): add support for file reference in ACP protocol#1063
xiaoju111a wants to merge 1 commit intoMoonshotAI:mainfrom
xiaoju111a:fix-acp-file-reference

Conversation

@xiaoju111a
Copy link
Contributor

@xiaoju111a xiaoju111a commented Feb 9, 2026

Related Issue

Resolves #1054

Description

This PR adds support for embedded resources in the ACP (Agent Communication Protocol) by implementing proper handling of EmbeddedResourceContentBlock according to the official ACP protocol specification. This enables IDE integrations (like Zed) to use @-mentions to reference files.

Changes Made

src/kimi_cli/acp/convert.py:

  • Added handler for EmbeddedResourceContentBlock - extracts and converts embedded text content to TextPart
  • Handles both text resources (TextResourceContents) and logs info for binary resources (BlobResourceContents)

tests/ui_and_conv/test_acp_convert.py:

  • Test for handling EmbeddedResourceContentBlock with embedded content
  • Tests verify that unsupported block types (including ResourceContentBlock) are not converted

Technical Details

According to the official ACP specification:

EmbeddedResourceContentBlock (type: "resource"):

  • This is the preferred way for Clients to include context (e.g., @-mentions) that the Agent may not have direct access to
  • The Client reads the file and embeds the actual content in the message
  • Our implementation extracts this embedded content and passes it to the LLM

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

Open with Devin

@xiaoju111a xiaoju111a force-pushed the fix-acp-file-reference branch 3 times, most recently from 5f24b07 to d5f3b10 Compare February 9, 2026 08:40
Implements proper handling of ACP content blocks according to the official
protocol specification:

- EmbeddedResourceContentBlock: Extracts and converts embedded text content
  to TextPart. This is the preferred way for Clients to include context
  (e.g., @-mentions) that the Agent may not have direct access to.

- ResourceContentBlock: Logs the resource reference but does not convert to
  content. According to ACP protocol, these are references to resources the
  Agent should be able to access directly through its own tools.

This implementation follows the ACP design principle where Clients embed
content they have access to, while resource links are left for the Agent
to access when needed.
@xiaoju111a xiaoju111a force-pushed the fix-acp-file-reference branch from d5f3b10 to a5eddc9 Compare February 9, 2026 08:46
@xiaoju111a xiaoju111a marked this pull request as ready for review February 27, 2026 03:34
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

resource = block.resource
if isinstance(resource, acp.schema.TextResourceContents):
content.append(TextPart(text=f"File: {resource.uri}\n\n{resource.text}"))
elif resource.__class__.__name__ == "BlobResourceContents":
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 String-based class name check for BlobResourceContents is fragile and inconsistent

On line 36, resource.__class__.__name__ == "BlobResourceContents" is used instead of isinstance(resource, acp.schema.BlobResourceContents), while line 34 correctly uses isinstance(resource, acp.schema.TextResourceContents) for the sibling type.

Root Cause

The EmbeddedResourceContentBlock.resource field in ACP is a union of TextResourceContents | BlobResourceContents. Line 34 checks TextResourceContents via isinstance, but line 36 checks BlobResourceContents via string comparison on the class name. This is fragile because:

  1. It will fail to match subclasses of BlobResourceContents (unlike isinstance).
  2. It could falsely match an unrelated class that happens to share the same name.
  3. acp.schema.BlobResourceContents should be available in agent-client-protocol==0.7.0 (the TextResourceContents sibling is available, and both are standard ACP/MCP resource content types). The kosong package in the same repo also references BlobResourceContents at packages/kosong/src/kosong/tooling/mcp.py.

Impact: If a future version of the ACP SDK introduces a subclass or alias of BlobResourceContents, the string check would silently fail, causing the resource to fall into the else branch and log an incorrect "Unknown resource type" warning instead of the intended "Skipping binary embedded resource" info message.

Suggested change
elif resource.__class__.__name__ == "BlobResourceContents":
elif isinstance(resource, acp.schema.BlobResourceContents):
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Zed ACP is unable to recognize the files I am currently handling.

1 participant