diff --git a/src/Agent/Tool/ToolUseAgent.php b/src/Agent/Tool/ToolUseAgent.php index 629e585..c8c049c 100644 --- a/src/Agent/Tool/ToolUseAgent.php +++ b/src/Agent/Tool/ToolUseAgent.php @@ -249,12 +249,7 @@ protected function call(?UserMessage $input = null, bool $stream = false): Gener while (true) { // 合并系统消息和普通消息 - $systemMessages = $this->memory->getSystemMessages(); - if (! empty($systemMessages)) { - $messages = array_merge([end($systemMessages)], $this->memory->getMessages()); - } else { - $messages = $this->memory->getMessages(); - } + $messages = array_merge($this->memory->getSystemMessages(), $this->memory->getMessages()); if (! $stream) { $response = $this->model->chat( diff --git a/src/Memory/MemoryManager.php b/src/Memory/MemoryManager.php index 9561d45..dac95c7 100644 --- a/src/Memory/MemoryManager.php +++ b/src/Memory/MemoryManager.php @@ -110,12 +110,7 @@ public function getProcessedMessages(): array } // 合并系统消息和普通消息 - $systemMessages = $this->getSystemMessages(); - if (! empty($systemMessages)) { - $allMessages = array_merge([end($systemMessages)], $this->getMessages()); - } else { - $allMessages = $this->getMessages(); - } + $allMessages = array_merge($this->getSystemMessages(), $this->getMessages()); // 如果有策略,应用策略处理 if ($this->policy !== null) {