fix(agents): subgraphWithTask & subtask missing tool results in prompt if other tools where requested along with finish tool#1971
Merged
EugeneTheDev merged 4 commits intodevelopfrom May 8, 2026
Conversation
… tools where requested along with finish tool
serge-p7v
reviewed
May 8, 2026
Amaneusz
reviewed
May 8, 2026
Amaneusz
reviewed
May 8, 2026
| result(toolCall.id, toolCall.tool, toolCall.content) | ||
| } | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
I think removing this might need more attention
executeFinishToolis called fromAIAgentFunctionalContextBaseCommon.executeMultipleToolsHacked- which is called from two places:
subtaskWithSingleToolModeandsubtaskWithMultiToolMode
Both of these return immediately when the finish result is available:
// this happens in subtaskWithMultiToolMode
toolResults.firstOrNull { it.tool == finishTool.descriptor.name }
?.let { finishResult ->
return finishResult.toSafeResult(finishTool, config.serializer).asSuccessful().result
}
They don't have their version of finalizeTask that would append to prompt before returning, appending happened in this removed part here (so for these two scenarios we would end up with Tool.Call but without Tool.Result)
Collaborator
Author
There was a problem hiding this comment.
Good catch, thanks, I will address it
Collaborator
Author
There was a problem hiding this comment.
Updated subtasks in functional context too, added tests to verify
serge-p7v
approved these changes
May 8, 2026
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.
In
subgraphWithTaskmodels can sometimes request other tools along with the finish tool. Previously, other tool results were ignored and not added to prompt, which led to error, since prompts can't have tool calls without matching tool results. Updated thesubgraphWithTasklogic to append all tool results when the finish tool was called