-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Revert "Fix token usage / cost often being underreported" #7039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This reverts commit b30372d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this revert! I've reviewed the changes and this is a clean revert that properly prioritizes user experience over perfect cost reporting. The decision to favor immediate interruption makes sense given user feedback. I have a few suggestions for consideration below.
| // PREV: We need to let the request finish for openrouter to | ||
| // get generation details. | ||
| // UPDATE: It's better UX to interrupt the request at the | ||
| // cost of the API cost not being retrieved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment here explaining the trade-off decision. Something like:
| // cost of the API cost not being retrieved. | |
| // PREV: We need to let the request finish for openrouter to | |
| // get generation details. | |
| // UPDATE: It's better UX to interrupt the request at the | |
| // cost of the API cost not being retrieved. | |
| // This prioritizes user experience (immediate interruption) over | |
| // perfect cost tracking based on user feedback. |
This would help future developers understand why this approach was chosen.
| // anyways, so it remains solely for legacy purposes to keep track | ||
| // of prices in tasks from history (it's worth removing a few months | ||
| // from now). | ||
| const updateApiReqMsg = (cancelReason?: ClineApiReqCancelReason, streamingFailedMessage?: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the lastApiReqIndex < 0 check could potentially cause issues if this function is called with an invalid index. Consider keeping this defensive check even though the background processing is removed:
| const updateApiReqMsg = (cancelReason?: ClineApiReqCancelReason, streamingFailedMessage?: string) => { | |
| const updateApiReqMsg = (cancelReason?: ClineApiReqCancelReason, streamingFailedMessage?: string) => { | |
| if (lastApiReqIndex < 0 || !this.clineMessages[lastApiReqIndex]) { | |
| return | |
| } | |
| const existingData = JSON.parse(this.clineMessages[lastApiReqIndex].text || "{}") |
| break | ||
| } | ||
|
|
||
| // PREV: We need to let the request finish for openrouter to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment here specifically mentions OpenRouter, but this behavior affects all providers that return usage data at the end of streams. Consider making it more generic:
| // PREV: We need to let the request finish for openrouter to | |
| // PREV: We need to let the request finish for providers to | |
| // get complete usage/generation details. | |
| // UPDATE: It's better UX to interrupt the request at the | |
| // cost of the API cost not being retrieved. |
Reverts #6122
After using this for a bit, I agree with the previous comment that it's better UX to interrupt the request than to get the cost perfect.
Important
Reverts token usage reporting improvements to prioritize user experience by interrupting requests instead of perfecting cost reporting.
Task.ts, opting to interrupt requests instead.DEFAULT_USAGE_COLLECTION_TIMEOUT_MSfromglobal-settings.ts.drainStreamInBackgroundToFindAllUsagefunction and related logic inTask.ts.recursivelyMakeClineRequestsinTask.tsto handle request interruptions without background usage collection.This description was created by
for 015b876. You can customize this summary. It will automatically update as commits are pushed.