- Only consider API requests with valid token information
- Skip messages with invalid/missing token data
- Prevent counter from resetting on action approval messages
- Ensure both tokensIn and tokensOut are valid numbers
This makes the context token counter more stable and accurate
by only updating on valid API responses with complete token data.
- Only update context tokens when both input and output tokens are non-zero
- Keep previous context token count when API calls fail
- Avoid resetting counter on partial or failed responses
This makes the context token counter more resilient against edge cases
and provides more accurate context size tracking during API failures.
- Add contextTokens to ApiMetrics interface
- Calculate context size using last API request's tokens
- Display context token count in TaskHeader below total tokens
- Use exact token counts instead of character estimation
This helps users track the total size of their conversation context,
which is useful for managing context window limits.