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

Function hasThinkingBlocks

src/services/tokenEstimation.ts:38–56  ·  view source on GitHub ↗

* Check if messages contain thinking blocks

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

Source from the content-addressed store, hash-verified

36 * Check if messages contain thinking blocks
37 */
38function 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.

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected