Skip to content

Commit e5efe3a

Browse files
committed
fix(tools): use modified messages list in async compaction
The async `_check_and_compact()` method was incorrectly using `self._params["messages"]` instead of the local `messages` variable when building the compaction request. This caused the async version to ignore all the filtering logic that removes tool_use blocks from the last assistant message before compaction, potentially sending invalid API requests. The sync version correctly uses `*messages` (line 203), while the async version was using `*self._params["messages"]` (line 454).
1 parent 9b5ab24 commit e5efe3a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/anthropic/lib/tools/_beta_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ async def _check_and_compact(self) -> bool:
451451
messages.pop()
452452

453453
messages = [
454-
*self._params["messages"],
454+
*messages,
455455
BetaMessageParam(
456456
role="user",
457457
content=self._compaction_control.get("summary_prompt", DEFAULT_SUMMARY_PROMPT),

0 commit comments

Comments
 (0)