openclaw - 💡(How to fix) Fix fix(agents): sanitize blank user text content blocks during Bedrock replay [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72622Fetched 2026-04-28 06:33:58
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1cross-referenced ×1

Error Message

Validation error: The text field in the ContentBlock object at messages.21.content.0 is blank. Add text to the text field, and try again.

Root Cause

OpenClaw can inject blank role=user messages into session transcripts — observed during /new//reset transitions and possibly other runtime events. The session JSONL ends up with entries like:

{"type": "message", "message": {"role": "user", "content": [{"type": "text", "text": ""}]}}

The existing fix (#71627 / 930d81aa41) sanitizes blank assistant content blocks but blank user text blocks pass through unchecked and poison the Bedrock Converse replay.

Code Example

Validation error: The text field in the ContentBlock object at messages.21.content.0 is blank.
Add text to the text field, and try again.

---

{"type": "message", "message": {"role": "user", "content": [{"type": "text", "text": ""}]}}
RAW_BUFFERClick to expand / collapse

Bug

Bedrock/Anthropic API rejects conversations containing user messages with blank text content blocks:

Validation error: The text field in the ContentBlock object at messages.21.content.0 is blank.
Add text to the text field, and try again.

Root Cause

OpenClaw can inject blank role=user messages into session transcripts — observed during /new//reset transitions and possibly other runtime events. The session JSONL ends up with entries like:

{"type": "message", "message": {"role": "user", "content": [{"type": "text", "text": ""}]}}

The existing fix (#71627 / 930d81aa41) sanitizes blank assistant content blocks but blank user text blocks pass through unchecked and poison the Bedrock Converse replay.

Impact

  • Affects any session that accumulates a blank user message in its transcript
  • Error persists across /new if the blank message was written before the reset boundary
  • Cascades through all fallback models (Opus → Sonnet → Haiku all reject it)
  • Session file repair (session-file-repair.ts) also only checks assistant messages

Proposed Fix

Two changes needed:

  1. src/agents/pi-embedded-runner/replay-history.ts: Add a sanitizeBlankUserTextContent() pass inside normalizeAssistantReplayContent() that filters out blank text blocks from user messages and drops entirely-blank user messages from replay.

  2. src/agents/session-file-repair.ts: Add isUserEntryWithBlankTextContent() to detect and drop blank user messages during on-disk repair.

Environment

  • OpenClaw 2026.4.26 (09a635a)
  • Provider: amazon-bedrock (Claude Opus 4.6, Sonnet 4.5, Haiku 4.5)
  • Channel: Telegram

extent analysis

TL;DR

Sanitize blank user text content blocks in the replay-history.ts and session-file-repair.ts files to prevent Bedrock API validation errors.

Guidance

  • Modify the normalizeAssistantReplayContent() function in replay-history.ts to filter out blank text blocks from user messages.
  • Add a check in session-file-repair.ts to detect and drop blank user messages during on-disk repair.
  • Verify that the changes fix the issue by testing the updated code with a session that previously accumulated a blank user message.
  • Consider adding additional logging or error handling to catch and handle similar issues in the future.

Example

// Example of sanitizeBlankUserTextContent() function
function sanitizeBlankUserTextContent(message) {
  if (message.role === 'user' && message.content.length === 1 && message.content[0].text === '') {
    return null; // drop entirely-blank user messages
  }
  return message;
}

Notes

The proposed fix only addresses the specific issue of blank user text content blocks and may not cover other potential validation errors.

Recommendation

Apply the proposed workaround by modifying the replay-history.ts and session-file-repair.ts files to sanitize blank user text content blocks, as this directly addresses the root cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix fix(agents): sanitize blank user text content blocks during Bedrock replay [1 comments, 2 participants]