From fed65568bbfca0ee21a45f5546c6aefcd4557026 Mon Sep 17 00:00:00 2001 From: Carey Payette Date: Sat, 21 Dec 2024 20:59:41 -0500 Subject: [PATCH] Fix message history for LangGraphReactAgent and ExternalWorkflow path --- .../agents/langchain_knowledge_management_agent.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/python/PythonSDK/foundationallm/langchain/agents/langchain_knowledge_management_agent.py b/src/python/PythonSDK/foundationallm/langchain/agents/langchain_knowledge_management_agent.py index 5e70c574a..32dcaec33 100644 --- a/src/python/PythonSDK/foundationallm/langchain/agents/langchain_knowledge_management_agent.py +++ b/src/python/PythonSDK/foundationallm/langchain/agents/langchain_knowledge_management_agent.py @@ -462,7 +462,11 @@ async def invoke_async(self, request: KnowledgeManagementCompletionRequest) -> C # Define the graph graph = create_react_agent(llm, tools=tools, state_modifier=self.prompt.prefix) - messages = self._build_conversation_history_message_list(request.message_history, agent.conversation_history_settings.max_history) + if agent.conversation_history_settings.enabled: + messages = self._build_conversation_history_message_list(request.message_history, agent.conversation_history_settings.max_history) + else: + messages = [] + messages.append(HumanMessage(content=parsed_user_prompt)) response = await graph.ainvoke( @@ -526,8 +530,11 @@ async def invoke_async(self, request: KnowledgeManagementCompletionRequest) -> C self.user_identity, self.config) - # Get message history - messages = self._build_conversation_history_message_list(request.message_history, agent.conversation_history_settings.max_history) + # Get message history + if agent.conversation_history_settings.enabled: + messages = self._build_conversation_history_message_list(request.message_history, agent.conversation_history_settings.max_history) + else: + messages = [] response = await workflow.invoke_async( operation_id=request.operation_id,