The adapter utilities handle conversion between ACP content blocks and LangChain multimodal content formats. These functions are used internally by the ACPAgentServer but are also available for custom integrations.
Learn more: For the ACP content block specification, see agentclientprotocol.com.
Each ACP content block type has a dedicated converter that returns a list of LangChain-compatible content dictionaries.
from deepagents_acp.utils import convert_text_block_to_content_blocks
blocks = convert_text_block_to_content_blocks(text_block)
# [{"type": "text", "text": "Hello, world!"}]
Converts ACP image blocks to LangChain image_url content. Supports inline base64 data with MIME type:
from deepagents_acp.utils import convert_image_block_to_content_blocks
blocks = convert_image_block_to_content_blocks(image_block)
# [{"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}]
Converts ACP resource references to text content with URI, description, and MIME type metadata. The root_dir is stripped from file URIs to produce workspace-relative paths:
from deepagents_acp.utils import convert_resource_block_to_content_blocks
blocks = convert_resource_block_to_content_blocks(resource_block, root_dir="/workspace")
# [{"type": "text", "text": "[Resource: filename\nURI: file://src/app.py\n...]"}]
Handles inline resource data — text resources are converted to text content, binary blobs to base64 data URIs:
from deepagents_acp.utils import convert_embedded_resource_block_to_content_blocks
blocks = convert_embedded_resource_block_to_content_blocks(embedded_block)
Audio content is not currently supported and raises an exception:
from deepagents_acp.utils import convert_audio_block_to_content_blocks
# Raises: Exception("Audio is not currently supported.")
| ACP Block Type | LangChain Output Type | Notes |
|---|---|---|
TextContentBlock |
text |
Direct text passthrough |
ImageContentBlock |
image_url |
Base64 data URI with MIME type |
ResourceContentBlock |
text |
Metadata formatted as text |
EmbeddedResourceContentBlock |
text or data URI |
Text or binary content |
AudioContentBlock |
— | Not supported |
Convert an ACP text block to LangChain content blocks.
Convert an ACP image block to LangChain content blocks.
Convert an ACP audio block to LangChain content blocks.
Convert an ACP resource block to LangChain content blocks.
Convert an ACP embedded resource block to LangChain content blocks.