fix(core): handle pending tool calls when maxIters reached (#1005)#1012
Open
Fancy-hjyp wants to merge 2 commits intoagentscope-ai:mainfrom
Open
fix(core): handle pending tool calls when maxIters reached (#1005)#1012Fancy-hjyp wants to merge 2 commits intoagentscope-ai:mainfrom
Fancy-hjyp wants to merge 2 commits intoagentscope-ai:mainfrom
Conversation
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
fix #1005
Problem
When maxIters is reached with pending tool calls (e.g., tool execution timed
out or failed to respond), the agent enters the summarizing phase but leaves
uncompleted tool calls in memory.
This causes
IllegalStateExceptionon the next user message:Cannot add messages without tool results when pending tool calls exist.
Pending IDs: [call_638e428da2cf48ceb8b05762]
Root Cause
The
summarizing()method doesn't handle pending tool calls before generatingthe summary. When the user sends a new message,
doCall()detects pendingtool calls but the message doesn't contain tool results, triggering the
validation error.
Solution
In
summarizing(), automatically add errorToolResultBlocks for all pendingtool calls before generating the summary. The error message indicates the
tool was cancelled due to max iterations limit.
Changes
summarizing()to handle pending toolcalls
testSecondCallAfterMaxItersWithPendingToolCallsto verify the fixTesting