MCPcopy
hub / github.com/claude-code-best/claude-code / hasThinkingBlocks

Function hasThinkingBlocks

src/services/tokenEstimation.ts:45–63  ·  view source on GitHub ↗

* Check if messages contain thinking blocks

(
  messages: Anthropic.Beta.Messages.BetaMessageParam[],
)

Source from the content-addressed store, hash-verified

43 * Check if messages contain thinking blocks
44 */
45function hasThinkingBlocks(
46 messages: Anthropic.Beta.Messages.BetaMessageParam[],
47): boolean {
48 for (const message of messages) {
49 if (message.role === 'assistant' && Array.isArray(message.content)) {
50 for (const block of message.content) {
51 if (
52 typeof block === 'object' &&
53 block !== null &&
54 'type' in block &&
55 (block.type === 'thinking' || block.type === 'redacted_thinking')
56 ) {
57 return true
58 }
59 }
60 }
61 }
62 return false
63}
64
65/**
66 * Strip tool search-specific fields from messages before sending for token counting.

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected