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

Function getTokenUsageAttachment

src/utils/attachments.ts:3889–3908  ·  view source on GitHub ↗
(
  messages: Message[],
  model: string,
)

Source from the content-addressed store, hash-verified

3887}
3888
3889function getTokenUsageAttachment(
3890 messages: Message[],
3891 model: string,
3892): Attachment[] {
3893 if (!isEnvTruthy(process.env.CLAUDE_CODE_ENABLE_TOKEN_USAGE_ATTACHMENT)) {
3894 return []
3895 }
3896
3897 const contextWindow = getEffectiveContextWindowSize(model)
3898 const usedTokens = tokenCountFromLastAPIResponse(messages)
3899
3900 return [
3901 {
3902 type: 'token_usage',
3903 used: usedTokens,
3904 total: contextWindow,
3905 remaining: contextWindow - usedTokens,
3906 },
3907 ]
3908}
3909
3910function getOutputTokenUsageAttachment(): Attachment[] {
3911 if (feature('TOKEN_BUDGET')) {

Callers 1

getAttachmentsFunction · 0.85

Calls 3

isEnvTruthyFunction · 0.70

Tested by

no test coverage detected