Context
I noticed something that seems inconsistent with how parallel tool calls should be handled. I'd appreciate clarification on whether this is intended behavior or a potential issue.
The Observation
In constructScratchPad, tool calls are grouped by comparing the Log field:
func (o *OpenAIFunctionsAgent) constructScratchPad(steps []schema.AgentStep) []llms.ChatMessage {
// ...
for i, step := range steps {
if i == 0 || step.Action.Log != steps[i-1].Action.Log {
// Start a new group
}
}
}
However, in ParseOutput, each tool call gets a unique Log that includes the tool name:
func (o *OpenAIFunctionsAgent) ParseOutput(contentResp *llms.ContentResponse) (
[]schema.AgentAction, *schema.AgentFinish, error,
) {
actions = append(actions, schema.AgentAction{
Tool: functionName,
ToolInput: toolInput,
Log: fmt.Sprintf("Invoking: %s with %s %s", functionName, toolInputStr, contentMsg),
ToolID: toolCall.ID,
})
}
The Issue: Even when multiple tool calls come from the same LLM response, each has a different Log (e.g., "Invoking: search..." vs "Invoking: calculator..."). This means step.Action.Log != steps[i-1].Action.Log is always true, causing each tool call to be treated as a separate group.
Example
When LLM returns parallel tool calls [search, calculator]:
Expected:
AI Message (ToolCalls: [search, calculator])
Tool Result (search result)
Tool Result (calculator result)
Actual:
AI Message (ToolCalls: [search, calculator])
Tool Result (search result)
AI Message (ToolCalls: [search, calculator]) ← Duplicate AI message
Tool Result (calculator result)
Context
I noticed something that seems inconsistent with how parallel tool calls should be handled. I'd appreciate clarification on whether this is intended behavior or a potential issue.
The Observation
In
constructScratchPad, tool calls are grouped by comparing theLogfield:However, in
ParseOutput, each tool call gets a uniqueLogthat includes the tool name:The Issue: Even when multiple tool calls come from the same LLM response, each has a different
Log(e.g.,"Invoking: search..."vs"Invoking: calculator..."). This meansstep.Action.Log != steps[i-1].Action.Logis always true, causing each tool call to be treated as a separate group.Example
When LLM returns parallel tool calls
[search, calculator]:Expected:
Actual: