* Check if an assistant message has only whitespace-only text content blocks. * Returns true if all content blocks are text blocks with only whitespace. * Returns false if there are any non-text blocks (like tool_use) or text with actual content.
(
content: Array<{ type: string; text?: string }>,
)
| 4833 | * Returns false if there are any non-text blocks (like tool_use) or text with actual content. |
| 4834 | */ |
| 4835 | function hasOnlyWhitespaceTextContent( |
| 4836 | content: Array<{ type: string; text?: string }>, |
| 4837 | ): boolean { |
| 4838 | if (content.length === 0) { |
| 4839 | return false |
| 4840 | } |
| 4841 | |
| 4842 | for (const block of content) { |
| 4843 | // If there's any non-text block (tool_use, thinking, etc.), the message is valid |
| 4844 | if (block.type !== 'text') { |
| 4845 | return false |
| 4846 | } |
| 4847 | // If there's a text block with non-whitespace content, the message is valid |
| 4848 | if (block.text !== undefined && block.text.trim() !== '') { |
| 4849 | return false |
| 4850 | } |
| 4851 | } |
| 4852 | |
| 4853 | // All blocks are text blocks with only whitespace |
| 4854 | return true |
| 4855 | } |
| 4856 | |
| 4857 | /** |
| 4858 | * Filter out assistant messages with only whitespace-only text content. |
no outgoing calls
no test coverage detected