fix(chat): remove unused Anthropic token estimation logic - #385
Conversation
Removed outdated logic for estimating prompt tokens when usage data is incomplete for the Anthropic provider. This simplifies and cleans up the chat token handling code.
WalkthroughThe change removes logic that estimated prompt tokens for Anthropic streaming responses when only output tokens were available. The code previously inferred prompt token counts by dividing message content lengths, but this estimation step is now deleted. No other modifications to the streaming response handling or exported entities were made. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Gateway
participant Anthropic
Client->>Gateway: Send streaming chat request
Gateway->>Anthropic: Forward request
Anthropic-->>Gateway: Stream chunk (may lack prompt_tokens)
Gateway-->>Client: Forward chunk without estimating prompt_tokens
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Claude finished @steebchen's task —— View job Code Review Complete ✅Reviewing PR #385: "fix(chat): remove unused Anthropic token estimation logic" Tasks:
Review Summary✅ This is a clean, safe refactoring that removes outdated workaround code. AnalysisWhat was removed:
Why this removal is safe:
RecommendationApprove and merge - This is a clean refactoring that removes unused code without introducing any functional issues. Optional follow-up: Consider adding monitoring to track if Anthropic ever provides incomplete usage data in production, which would validate that this estimation logic is indeed no longer needed. |
This reverts commit ed49458.
Removed outdated logic for estimating prompt tokens when usage data is incomplete for the Anthropic provider. This simplifies and cleans up the chat token handling code.
Summary by CodeRabbit