Skip to content

fix: preserve None content on tool-call-only assistant messages (#11906) - #11924

Closed
kagura-agent wants to merge 1 commit into
NousResearch:mainfrom
kagura-agent:fix/empty-assistant-content
Closed

fix: preserve None content on tool-call-only assistant messages (#11906)#11924
kagura-agent wants to merge 1 commit into
NousResearch:mainfrom
kagura-agent:fix/empty-assistant-content

Conversation

@kagura-agent

Copy link
Copy Markdown
Contributor

Problem

Empty assistant content (None) gets normalized to empty string '', which causes HTTP 400 on Anthropic-compatible proxies ('text content blocks must be non-empty'). This happens when the model returns a tool-call-only response.

Fix

Three-layer normalization to prevent empty text blocks:

  1. run_agent.py (storage): Normalize empty string to None when storing assistant messages
  2. run_agent.py (API prep): Strip empty assistant content before sending to API (2 locations)
  3. anthropic_adapter.py: Normalize in Anthropic message conversion as defensive guard

Tests

  • New test files covering empty content round-trips and Anthropic adapter behavior

Fixes #11906

…Research#11906)

When the model returns a tool-call-only response with content=None,
the content was being normalized to empty string '', which causes
HTTP 400 on Anthropic-compatible proxies ('text content blocks must
be non-empty'). Keep content as None in conversation history dicts
so the API client serializes it as null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kagura-agent
kagura-agent force-pushed the fix/empty-assistant-content branch from acca090 to a1b4e52 Compare April 18, 2026 03:04
@kagura-agent

Copy link
Copy Markdown
Contributor Author

Closing to reduce PR volume — I had too many open PRs. Apologies for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant