Skip to content

[Bug]: Assistant messages with empty content cause HTTP 400 on Anthropic-compatible proxies #11906

@xiaoyin1993

Description

@xiaoyin1993

Bug Description

When using an OpenAI-compatible proxy that forwards to Anthropic (e.g. claude-code-router, one-api), the agent intermittently fails with:

HTTP 400: "messages: text content blocks must be non-empty"

Steps to Reproduce

  1. Configure hermes-agent to use an OpenAI-compatible proxy that forwards to Anthropic (e.g. base_url: http://localhost:3001/v1)
  2. Start a conversation that triggers tool calls
  3. After the model returns a tool-call-only response (content is None), the empty string gets stored in history
  4. On the next API round-trip, the proxy rejects the empty text block → HTTP 400

Expected Behavior

Empty assistant content should be normalized to None instead of "", preventing the proxy from generating empty text blocks.

Actual Behavior

assistant_message.content = None → normalized to "" → stored in history → proxy translates to {"type": "text", "text": ""} → Anthropic rejects with 400.

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

No response

Debug Report

*

Operating System

macos

Python Version

3.12.11

Hermes Version

Hermes Agent v0.10.0 (2026.4.16)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions