fix: properly reset cost limit tracking when user clicks "Reset and Continue"#6890
Merged
fix: properly reset cost limit tracking when user clicks "Reset and Continue"#6890
Conversation
…ontinue" - Track the message index at the time of cost reset - Only calculate costs from messages after the reset point - Prevents the issue where cost limit immediately triggers again after reset Fixes #6889
Collaborator
|
This logic feels a lot messier than it needs to be. It seems like we should use the same approach and methods for tracking number of requests and total cost. |
…dler - Use consistent message-based tracking for both request count and cost limit - Track reset point using lastResetMessageIndex for both limits - Calculate request count from API messages similar to cost calculation - Simplify logic by removing separate tracking mechanisms - Update tests to match new message-based counting approach This addresses review feedback about inconsistent tracking approaches between request counting and cost tracking.
Collaborator
|
@mrubens Can you please take a look? |
mrubens
approved these changes
Oct 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #6889 where the cost limit was not being properly reset when users clicked "Reset and Continue" after hitting the auto-approved cost limit.
Problem
When a user hit the cost limit and clicked "Reset and Continue", the cost would immediately trigger the limit again on the next API request because the total cost was still being calculated from all messages in the conversation history.
Solution
The fix tracks the message index at the time of cost reset and only calculates costs from messages after that reset point. This ensures that:
Changes
costResetMessageIndextracking inAutoApprovalHandlerTesting
Fixes #6889
Important
Fixes cost limit reset issue in
AutoApprovalHandlerby tracking message index at reset and updating cost calculations accordingly.AutoApprovalHandlerby trackinglastResetMessageIndex.lastResetMessageIndexto track message index at reset inAutoApprovalHandler.checkRequestLimit()andcheckCostLimit()to use messages after reset.resetRequestCount()to resetlastResetMessageIndexand cost tracking.AutoApprovalHandler.spec.tsfor cost reset functionality.This description was created by
for 07283bf. You can customize this summary. It will automatically update as commits are pushed.