( messages: Message[], model: string, )
| 3812 | } |
| 3813 | |
| 3814 | function 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 | |
| 3835 | function getOutputTokenUsageAttachment(): Attachment[] { |
| 3836 | if (feature('TOKEN_BUDGET')) { |
no test coverage detected