NousResearch/hermes-agent · error · ValueError
image input 'data' must be bytes
Error message
image input 'data' must be bytes
What it means
Error "image input 'data' must be bytes" thrown in NousResearch/hermes-agent.
Source
Thrown at agent/plugin_llm.py:538
except (TypeError, ValueError):
schema_text = str(json_schema)
header = f"{header}\n\nJSON schema:\n{schema_text}"
user_parts.append({"type": "text", "text": header})
for block in inputs:
norm = _normalize_input_block(block)
if norm["type"] == "text":
user_parts.append({"type": "text", "text": norm["text"]})
elif norm["type"] == "image":
if norm.get("url"):
user_parts.append({
"type": "image_url",
"image_url": {"url": norm["url"]},
})
else:
data = norm.get("data") or b""
if not isinstance(data, (bytes, bytearray)):
raise ValueError("image input 'data' must be bytes")
b64 = base64.b64encode(data).decode("ascii")
mime = norm.get("mime_type") or "image/png"
user_parts.append({
"type": "image_url",
"image_url": {"url": f"data:{mime};base64,{b64}"},
})
messages.append({"role": "user", "content": user_parts})
return messages
# ---------------------------------------------------------------------------
# JSON parsing
# ---------------------------------------------------------------------------
_FENCE_RE = re.compile(r"```(?:json)?\s*(.+?)```", re.DOTALL | re.IGNORECASE)
View on GitHub (pinned to c896c09c42)
Solutions
- Pass image 'data' as bytes, not a string or other type.
- Encode the image correctly in the plugin before building the block.
When it happens
Trigger: Thrown at agent/plugin_llm.py:538 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/ee9531b41891fa74.
Report an issue: GitHub.