( messages: Message[], model: string, )
| 3805 | } |
| 3806 | |
| 3807 | function getTokenUsageAttachment( |
| 3808 | messages: Message[], |
| 3809 | model: string, |
| 3810 | ): Attachment[] { |
| 3811 | if (!isEnvTruthy(process.env.CLAUDE_CODE_ENABLE_TOKEN_USAGE_ATTACHMENT)) { |
| 3812 | return [] |
| 3813 | } |
| 3814 | |
| 3815 | const contextWindow = getEffectiveContextWindowSize(model) |
| 3816 | const usedTokens = tokenCountFromLastAPIResponse(messages) |
| 3817 | |
| 3818 | return [ |
| 3819 | { |
| 3820 | type: 'token_usage', |
| 3821 | used: usedTokens, |
| 3822 | total: contextWindow, |
| 3823 | remaining: contextWindow - usedTokens, |
| 3824 | }, |
| 3825 | ] |
| 3826 | } |
| 3827 | |
| 3828 | function getOutputTokenUsageAttachment(): Attachment[] { |
| 3829 | if (feature('TOKEN_BUDGET')) { |
no test coverage detected