fix: update request handling to use currentQueueAuthIndex#195
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes request forwarding and usage-attempt tracking to use the auth index associated with the active message queue (rather than the global currentAuthIndex), improving correctness when retries/account switching occur mid-request.
Changes:
- Forward requests and record usage attempts using
currentQueueAuthIndexduring streaming/retry loops. - Pass an explicit auth index into
_forwardRequest(...)and update its implementation to look up the correct WebSocket connection. - For count-token style non-streaming requests, derive the auth index from
ConnectionRegistry.getAuthIndexForRequest(requestId)and use it consistently for tracking + forwarding.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request updates the way authentication indices are handled when forwarding requests and recording usage statistics in the
RequestHandlerclass. Instead of always using the current authentication index (currentAuthIndex), the code now consistently uses the specific authentication index associated with each request. This change ensures that requests are correctly attributed to the proper authentication context, improving accuracy in both request forwarding and usage tracking.Key changes:
Authentication Index Handling:
_forwardRequestandrecordAttemptnow use the authentication index specific to the current request (e.g.,currentQueueAuthIndexormessageQueueAuthIndex) instead of the globalcurrentAuthIndex. This ensures requests are routed and tracked using the correct authentication context. [1] [2] [3] [4] [5] [6] [7]Method Signature Update:
_forwardRequestmethod now accepts an optionalauthIndexparameter (defaulting tocurrentAuthIndex) and uses it to select the appropriate connection for forwarding requests, rather than always using the global index.Error Handling Improvement:
authIndexused, making debugging easier and error reporting more accurate.