langchain-ai/deepagents · error · ValueError

Could not parse embedded resource block. Block expected eith

Error message

Could not parse embedded resource block. Block expected either a `text` or `blob` property.

What it means

`convert_embedded_resource_block_to_content_blocks` raises ValueError when an ACP `EmbeddedResourceContentBlock`'s inner `resource` contains neither a `text` nor a `blob` property, so the block cannot be mapped to a LangChain content block. The spec requires one of the two; a block missing both is malformed.

Source

Thrown at libs/acp/deepagents_acp/utils.py:99

    """
    resource = block.resource
    if hasattr(resource, "text"):
        mime_type = getattr(resource, "mime_type", "application/text")
        return [{"type": "text", "text": f"[Embedded {mime_type} resource: {resource.text}"}]
    if hasattr(resource, "blob"):
        mime_type = getattr(resource, "mime_type", "application/octet-stream")
        data_uri = f"data:{mime_type};base64,{resource.blob}"
        return [
            {
                "type": "text",
                "text": f"[Embedded resource: {data_uri}]",
            }
        ]
    msg = (
        "Could not parse embedded resource block. "
        "Block expected either a `text` or `blob` property."
    )
    raise ValueError(msg)


DANGEROUS_SHELL_PATTERNS = (
    "$(",  # Command substitution
    "`",  # Backtick command substitution
    "$'",  # ANSI-C quoting (can encode dangerous chars via escape sequences)
    "\n",  # Newline (command injection)
    "\r",  # Carriage return (command injection)
    "\t",  # Tab (can be used for injection in some shells)
    "<(",  # Process substitution (input)
    ">(",  # Process substitution (output)
    "<<<",  # Here-string
    "<<",  # Here-doc (can embed commands)
    ">>",  # Append redirect
    ">",  # Output redirect
    "<",  # Input redirect
    "${",  # Variable expansion with braces (can run commands via ${var:-$(cmd)})
)

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Ensure the embedded resource includes either `text` (for textual content) or `blob` (base64 for binary) before sending the prompt
  2. Fix or update the client library producing the resource block so it conforms to the ACP/MCP EmbeddedResource schema
  3. Log the raw block (it is included in the error context) and check for typos in field names
  4. Convert the resource yourself into a TextContentBlock if you control the prompt construction

Example fix

// before
{"type": "resource_link", "resource": {"uri": "file:///a.txt"}}
// after
{"type": "resource_link", "resource": {"uri": "file:///a.txt", "text": "file contents"}}
Defensive patterns

Strategy: validation

Validate before calling

resource = block.resource
if not ("text" in resource or "blob" in resource):
    raise ValueError(f"embedded resource {resource.get('uri')!r} needs 'text' or 'blob'")

Type guard

def has_resource_payload(resource: dict) -> bool:
    return isinstance(resource, dict) and ("text" in resource or "blob" in resource)

Try / catch

try:
    resp = await conn.prompt(blocks, session_id)
except ValueError as exc:
    if "embedded resource block" in str(exc):
        # drop/replace the malformed block and retry
        ...
    raise

Prevention

When it happens

Trigger: Calling `prompt()` with an embedded resource whose `resource` object has no `text` and no `blob` key (e.g. only a `uri`, or a typo'd key like `body`/`data`) — conversion is invoked at server.py:989-990.

Common situations: A hand-built or buggy MCP/ACP client serializing resources with wrong field names; an intermediary proxy stripping `text`/`blob` fields; protocol-version drift where a client emits a resource shape the server doesn't recognize.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/dd26f19fe21816a6. Report an issue: GitHub.