Skip to content

Commit 8f3f56c

Browse files
committed
[Agent] Reorder memory and system prompt sections
- Memory content now appears first, followed by system prompt - Added "# System Prompt" headline separator between sections - Updated tests to reflect new message ordering 🤖 Generated with [Claude Code](https://claude.ai/code)
1 parent 13c70ed commit 8f3f56c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/agent/src/Memory/MemoryInputProcessor.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ public function processInput(Input $input): void
7070
}
7171

7272
$systemMessage = $input->messages->getSystemMessage()->content ?? '';
73+
74+
$combinedMessage = self::MEMORY_PROMPT_MESSAGE.$memory;
7375
if ('' !== $systemMessage) {
74-
$systemMessage .= \PHP_EOL.\PHP_EOL;
76+
$combinedMessage .= \PHP_EOL.\PHP_EOL.'# System Prompt'.\PHP_EOL.\PHP_EOL.$systemMessage;
7577
}
7678

7779
$messages = $input->messages
7880
->withoutSystemMessage()
79-
->prepend(Message::forSystem($systemMessage.self::MEMORY_PROMPT_MESSAGE.$memory));
81+
->prepend(Message::forSystem($combinedMessage));
8082

8183
$input->messages = $messages;
8284
}

src/agent/tests/Memory/MemoryInputProcessorTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ public function testItIsAddingMemoryToSystemPrompt()
8686
$this->assertArrayNotHasKey('use_memory', $input->getOptions());
8787
$this->assertSame(
8888
<<<MARKDOWN
89-
You are a helpful and kind assistant.
90-
9189
# Conversation Memory
9290
This is the memory I have found for this conversation. The memory has more weight to answer user input,
9391
so try to answer utilizing the memory as much as possible. Your answer must be changed to fit the given
9492
memory. If the memory is irrelevant, ignore it. Do not reply to the this section of the prompt and do not
9593
reference it as this is just for your reference.
9694
9795
First memory content
96+
97+
# System Prompt
98+
99+
You are a helpful and kind assistant.
98100
MARKDOWN,
99101
$input->messages->getSystemMessage()->content,
100102
);

0 commit comments

Comments
 (0)