fix: search entire condensed region for tool_use blocks (ROO-520) #10755
+95
−19
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.
Problem
After multiple condensations, tool_use blocks preserved in earlier summary messages can end up outside the bounded search window of
N_MESSAGES_TO_KEEP(3 messages). This causes orphanedtool_resultblocks that trigger 400 errors from the API:Root Cause
The bounded search in
getKeepMessagesWithToolBlockswas too restrictive:After multiple condensations,
tool_useblocks can be in earlier summary messages that are outside this window.Solution
Changed the search to cover the entire condensed region:
Tests
Added two new tests:
should find tool_use even when it is far back in the message history (ROO-520 fix)should find tool_use in previous summary message after multiple condensations (ROO-520)Fixes: https://linear.app/roocode/issue/ROO-520
Important
Expands search in
getKeepMessagesWithToolBlocksto cover entire condensed region, fixing orphanedtool_resultblocks and preventing 400 API errors.getKeepMessagesWithToolBlocksto cover entire condensed region, ensuringtool_useblocks are found even if far back in history.tool_resultblocks and 400 API errors.should find tool_use even when it is far back in the message history (ROO-520 fix)inindex.spec.ts.should find tool_use in previous summary message after multiple condensations (ROO-520)inindex.spec.ts.This description was created by
for 04fc2a0. You can customize this summary. It will automatically update as commits are pushed.