* Check if messages contain thinking blocks
( messages: Anthropic.Beta.Messages.BetaMessageParam[], )
| 36 | * Check if messages contain thinking blocks |
| 37 | */ |
| 38 | function hasThinkingBlocks( |
| 39 | messages: Anthropic.Beta.Messages.BetaMessageParam[], |
| 40 | ): boolean { |
| 41 | for (const message of messages) { |
| 42 | if (message.role === 'assistant' && Array.isArray(message.content)) { |
| 43 | for (const block of message.content) { |
| 44 | if ( |
| 45 | typeof block === 'object' && |
| 46 | block !== null && |
| 47 | 'type' in block && |
| 48 | (block.type === 'thinking' || block.type === 'redacted_thinking') |
| 49 | ) { |
| 50 | return true |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | return false |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Strip tool search-specific fields from messages before sending for token counting. |
no outgoing calls
no test coverage detected