fix: use filtered messages in async _check_and_compact()#1214
Closed
thakoreh wants to merge 1 commit intoanthropics:mainfrom
Closed
fix: use filtered messages in async _check_and_compact()#1214thakoreh wants to merge 1 commit intoanthropics:mainfrom
thakoreh wants to merge 1 commit intoanthropics:mainfrom
Conversation
The async _check_and_compact() method was using self._params['messages'] instead of the filtered local 'messages' variable when building the summarization request. This caused tool_use blocks to be sent to the API without corresponding tool_result blocks, resulting in BadRequestError. Fixes anthropics#1205
Collaborator
|
#1205 was already fixed |
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
Fixes #1205
The async
_check_and_compact()method was usingself._params['messages']instead of the filtered localmessagesvariable when building the summarization request. This causedtool_useblocks to be sent to the API without correspondingtool_resultblocks, resulting inBadRequestError.Root Cause
In
src/anthropic/lib/tools/_beta_runner.py, line 478:The sync version of this method (line 218) correctly uses
*messages(the filtered variable), but the async version was using the unfilteredself._params["messages"].Fix
Changed line 478 to use the filtered
messagesvariable:Testing