Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: wrong order of history prompts in ReAct agent mode (#5236)
sino4f0488abb538
diff --git a/api/core/agent/cot_agent_runner.py b/api/core/agent/cot_agent_runner.pyindex 141ba2c252d..20d924ddc70 100644--- a/api/core/agent/cot_agent_runner.py+++ b/api/core/agent/cot_agent_runner.py@@ -379,7 +379,7 @@ class CotAgentRunner(BaseAgentRunner, ABC):organize historic prompt messages"""result: list[PromptMessage] = []- scratchpad: list[AgentScratchpadUnit] = []+ scratchpads: list[AgentScratchpadUnit] = []current_scratchpad: AgentScratchpadUnit = Noneself.history_prompt_messages = AgentHistoryPromptTransform(@@ -391,13 +391,15 @@ class CotAgentRunner(BaseAgentRunner, ABC):for message in self.history_prompt_messages:if isinstance(message, AssistantPromptMessage):- current_scratchpad = AgentScratchpadUnit(- agent_response=message.content,- thought=message.content or 'I am thinking about how to help you',- action_str='',- action=None,- observation=None,- )+ if not current_scratchpad:+ current_scratchpad = AgentScratchpadUnit(+ agent_response=message.content,+ thought=message.content or 'I am thinking about how to help you',+ action_str='',+ action=None,+ observation=None,+ )+ scratchpads.append(current_scratchpad)if message.tool_calls:try:current_scratchpad.action = AgentScratchpadUnit.Action(@@ -409,24 +411,23 @@ class CotAgentRunner(BaseAgentRunner, ABC):)except:pass-- scratchpad.append(current_scratchpad)elif isinstance(message, ToolPromptMessage):if current_scratchpad:current_scratchpad.observation = message.contentelif isinstance(message, UserPromptMessage):- result.append(message)-- if scratchpad:+ if scratchpads:result.append(AssistantPromptMessage(- content=self._format_assistant_message(scratchpad)+ content=self._format_assistant_message(scratchpads)))+ scratchpads = []+ current_scratchpad = None++ result.append(message)- scratchpad = []- if scratchpad:+ if scratchpads:result.append(AssistantPromptMessage(- content=self._format_assistant_message(scratchpad)+ content=self._format_assistant_message(scratchpads)))return result\ No newline at end of file