Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ private static ToolContext buildToolContext(Prompt prompt, AssistantMessage assi
&& !CollectionUtils.isEmpty(toolCallingChatOptions.getToolContext())) {
toolContextMap = new HashMap<>(toolCallingChatOptions.getToolContext());

List<Message> messageHistory = new ArrayList<>(prompt.copy().getInstructions());
messageHistory.add(new AssistantMessage(assistantMessage.getText(), assistantMessage.getMetadata(),
assistantMessage.getToolCalls()));

Comment on lines -156 to -159
Copy link
Contributor Author

@YunKuiLu YunKuiLu Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The messageHistory in the buildToolContext method is actually unused. The real messageHistory construction happens in the buildConversationHistoryBeforeToolExecution method.

private static List<Message> buildConversationHistoryBeforeToolExecution(Prompt prompt,
			AssistantMessage assistantMessage) {
  List<Message> messageHistory = new ArrayList<>(prompt.copy().getInstructions());
  messageHistory.add(new AssistantMessage(assistantMessage.getText(), assistantMessage.getMetadata(),
		  assistantMessage.getToolCalls()));
  return messageHistory;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YunKuiLu Good catch. Thanks for the cleanup!

toolContextMap.put(ToolContext.TOOL_CALL_HISTORY,
buildConversationHistoryBeforeToolExecution(prompt, assistantMessage));
}
Expand Down