MCPcopy Create free account
hub / github.com/Noumena-Network/code / getTokenUsageAttachment

Function getTokenUsageAttachment

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

Source from the content-addressed store, hash-verified

3812}
3813
3814function getTokenUsageAttachment(
3815 messages: Message[],
3816 model: string,
3817): Attachment[] {
3818 if (!isEnvTruthy(process.env.CLAUDE_CODE_ENABLE_TOKEN_USAGE_ATTACHMENT)) {
3819 return []
3820 }
3821
3822 const contextWindow = getEffectiveContextWindowSize(model)
3823 const usedTokens = tokenCountFromLastAPIResponse(messages)
3824
3825 return [
3826 {
3827 type: 'token_usage',
3828 used: usedTokens,
3829 total: contextWindow,
3830 remaining: contextWindow - usedTokens,
3831 },
3832 ]
3833}
3834
3835function getOutputTokenUsageAttachment(): Attachment[] {
3836 if (feature('TOKEN_BUDGET')) {

Callers 1

getAttachmentsFunction · 0.85

Calls 3

isEnvTruthyFunction · 0.90

Tested by

no test coverage detected