fix(acp): inline file content for ResourceContentBlock @-references#20237
Open
evantouchelf wants to merge 1 commit into
Open
fix(acp): inline file content for ResourceContentBlock @-references#20237evantouchelf wants to merge 1 commit into
evantouchelf wants to merge 1 commit into
Conversation
When Zed sends a file:// URI via ACP ResourceContentBlock (e.g. @filename), the ACP adapter now reads the file content on the server side and inlines it directly into the prompt, so the AI sees the file contents without needing an extra read_file tool call. Supports: - file:// URIs with #L9 / #L9:15 line ranges - URL-decoded paths (Chinese characters, spaces) - EmbeddedResourceContentBlock (text/blob) - Fallback to [Referenced file: ...] marker on failure - 100K character truncation Fixes: ResourceContentBlock and EmbeddedResourceContentBlock were previously silently dropped in both _extract_text() and _content_blocks_to_openai_user_content().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Zed (and other ACP editors) sends a @filename reference to a file, it comes through as a ResourceContentBlock (with a file:// URI) or an EmbeddedResourceContentBlock (with inline content). The ACP adapter's
_content_blocks_to_openai_user_content()and_extract_text()functions only handled TextContentBlock and ImageContentBlock — resource blocks were silently dropped.This meant users could @src/main.rs in Zed and the AI would never see the file content.
Fix
Added handling for three ACP content block types:
ResourceContentBlock (resource_link)
Zed sends the file as a file:// URI with optional line ranges (#L9 or #L9:15). The server now:
--- File: /path#L9:15 ---...--- End of /path ---EmbeddedResourceContentBlock with TextResourceContents
Inlines resource.text directly (the client already embedded the content).
EmbeddedResourceContentBlock with BlobResourceContents
Decodes base64 for text/* mime types; marks binary content as [Binary content, type: ...].
Testing
Related
Fixes a gap where resource content blocks were declared in the function type signature but not handled in the implementation body.