Fix duplicate AI messages for parallel tool calls (#1463)#1475
Open
VishnuVV27 wants to merge 1 commit into
Open
Fix duplicate AI messages for parallel tool calls (#1463)#1475VishnuVV27 wants to merge 1 commit into
VishnuVV27 wants to merge 1 commit into
Conversation
Signed-off-by: vishnuvv27 <vardhanvishnu520@gmail.com>
59f2cd3 to
1fc09d0
Compare
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.
PR Checklist
agents: fix duplicate AI messages for parallel tool callsgolangci-lintchecks.Description
This PR resolves issue #1463 where the OpenAIFunctionsAgent generated multiple duplicate AI messages in the conversation history (scratchpad) when the LLM returned multiple tool calls in a single response turn.
The Fix:
The constructScratchPad function groups sequential tool calls into a single
AIChatMessageonly if they share the same Log string. Previously, ParseOutput generated a unique Log for every tool call (stating only one tool at a time), which caused the grouping logic to fail and create multiple AI message turns.I refactored ParseOutput to generate a
sharedLogstring that summarizes all tools being invoked in that response. By making the Log identical for all actions in a choice, constructScratchPad now correctly collapses them into a single message with multiple ToolCalls.Verification:
Fixes #1463