4c9628eab5
An assistant message with an empty or whitespace-only text content block — produced by context compression or certain tool-call flows — is rejected by the Anthropic Messages API with HTTP 400 "text content blocks must contain non-whitespace text". Because the blank block is stored in session history and replayed verbatim every turn, the session is permanently wedged behind the same 400. The Bedrock adapter already guards this via _safe_text() (#9486); the native Anthropic path never got the same treatment. _sanitize_replay_block() rebuilt text blocks with the raw stored text, and the _convert_assistant_message() guard only caught a fully empty block list, not a list still containing a whitespace-only text block. Add a _safe_text() helper mirroring the Bedrock one and apply it at both points: the ordered-blocks replay path and a final in-place walk of the converted content list. Both are self-healing — sessions that stored blank blocks recover on the next API call. Only text blocks are coerced; thinking/tool_use/image blocks are untouched. Fixes #69512