refactor(claude-kiro): improve token counting accuracy using API contextUsagePercentage
Replace client-side token estimation with server-provided contextUsagePercentage for accurate input token calculation. This eliminates discrepancies between estimated and actual token counts by using the API's native context window measurement. Key changes: - Add contextUsage event parsing in AWS Event Stream buffer - Calculate input tokens from contextUsagePercentage in both streaming and non-streaming responses - Deprecate estimateInputTokens() method in favor of API-provided metrics - Import CLAUDE_DEFAULT_MAX_TOKENS for context window calculations - Add fallback error handling when contextUsagePercentage is not received - Fix code formatting and whitespace consistency throughout the file
This commit is contained in:
parent
ea2ae2169c
commit
89bc0ee6f8
1 changed files with 359 additions and 281 deletions
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue