( messages: Message[], model: string, )
| 3887 | } |
| 3888 | |
| 3889 | function 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 | |
| 3910 | function getOutputTokenUsageAttachment(): Attachment[] { |
| 3911 | if (feature('TOKEN_BUDGET')) { |
no test coverage detected