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

Function getAssistantMessageId

src/utils/tokens.ts:28–37  ·  view source on GitHub ↗

* Get the API response id for an assistant message with real (non-synthetic) usage. * Used to identify split assistant records that came from the same API response — * when parallel tool calls are streamed, each content block becomes a separate * AssistantMessage record, but they all share the sa

(message: Message)

Source from the content-addressed store, hash-verified

26 * AssistantMessage record, but they all share the same message.id.
27 */
28function getAssistantMessageId(message: Message): string | undefined {
29 if (
30 message?.type === 'assistant' &&
31 'id' in message.message &&
32 message.message.model !== SYNTHETIC_MODEL
33 ) {
34 return message.message.id
35 }
36 return undefined
37}
38
39/**
40 * Calculate total context window tokens from an API response's usage data.

Callers 1

tokenCountWithEstimationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected