From e42a31feb855bdd9db06f474df35811ecb3bb644 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Sat, 13 Sep 2025 23:16:18 +0200 Subject: [PATCH] [Agent] Rename MemoryProviderInterface::loadMemory to load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify the method name by removing the redundant 'Memory' prefix. This improves readability and follows interface naming conventions. Changes: - MemoryProviderInterface::loadMemory() → load() - Updated all implementations and usages - All tests passing --- src/agent/src/Memory/EmbeddingProvider.php | 2 +- src/agent/src/Memory/MemoryInputProcessor.php | 2 +- src/agent/src/Memory/MemoryProviderInterface.php | 2 +- src/agent/src/Memory/StaticMemoryProvider.php | 2 +- src/agent/tests/Memory/EmbeddingProviderTest.php | 10 +++++----- src/agent/tests/Memory/MemoryInputProcessorTest.php | 10 +++++----- src/agent/tests/Memory/StaticMemoryProviderTest.php | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/agent/src/Memory/EmbeddingProvider.php b/src/agent/src/Memory/EmbeddingProvider.php index ce2341b8b..e68a1b691 100644 --- a/src/agent/src/Memory/EmbeddingProvider.php +++ b/src/agent/src/Memory/EmbeddingProvider.php @@ -32,7 +32,7 @@ public function __construct( ) { } - public function loadMemory(Input $input): array + public function load(Input $input): array { $messages = $input->messages->getMessages(); /** @var MessageInterface|null $userMessage */ diff --git a/src/agent/src/Memory/MemoryInputProcessor.php b/src/agent/src/Memory/MemoryInputProcessor.php index 5ea36bc84..c70ad5da2 100644 --- a/src/agent/src/Memory/MemoryInputProcessor.php +++ b/src/agent/src/Memory/MemoryInputProcessor.php @@ -52,7 +52,7 @@ public function processInput(Input $input): void $memory = ''; foreach ($this->memoryProviders as $provider) { - $memoryMessages = $provider->loadMemory($input); + $memoryMessages = $provider->load($input); if (0 === \count($memoryMessages)) { continue; diff --git a/src/agent/src/Memory/MemoryProviderInterface.php b/src/agent/src/Memory/MemoryProviderInterface.php index ca32f0ed3..a0b8361d2 100644 --- a/src/agent/src/Memory/MemoryProviderInterface.php +++ b/src/agent/src/Memory/MemoryProviderInterface.php @@ -21,5 +21,5 @@ interface MemoryProviderInterface /** * @return list */ - public function loadMemory(Input $input): array; + public function load(Input $input): array; } diff --git a/src/agent/src/Memory/StaticMemoryProvider.php b/src/agent/src/Memory/StaticMemoryProvider.php index b11e826e9..99ed03db2 100644 --- a/src/agent/src/Memory/StaticMemoryProvider.php +++ b/src/agent/src/Memory/StaticMemoryProvider.php @@ -28,7 +28,7 @@ public function __construct(string ...$memory) $this->memory = $memory; } - public function loadMemory(Input $input): array + public function load(Input $input): array { if (0 === \count($this->memory)) { return []; diff --git a/src/agent/tests/Memory/EmbeddingProviderTest.php b/src/agent/tests/Memory/EmbeddingProviderTest.php index bb7ab8674..6c5df1f1d 100644 --- a/src/agent/tests/Memory/EmbeddingProviderTest.php +++ b/src/agent/tests/Memory/EmbeddingProviderTest.php @@ -55,7 +55,7 @@ public function testItIsDoingNothingWithEmptyMessageBag() $store, ); - $embeddingProvider->loadMemory(new Input( + $embeddingProvider->load(new Input( $this->createStub(Model::class), new MessageBag(), [], @@ -76,7 +76,7 @@ public function testItIsDoingNothingWithoutUserMessageInBag() $store, ); - $embeddingProvider->loadMemory(new Input( + $embeddingProvider->load(new Input( $this->createStub(Model::class), new MessageBag(Message::forSystem('This is a system message')), [], @@ -97,7 +97,7 @@ public function testItIsDoingNothingWhenUserMessageHasNoTextContent() $store, ); - $embeddingProvider->loadMemory(new Input( + $embeddingProvider->load(new Input( $this->createStub(Model::class), new MessageBag(Message::ofUser(new ImageUrl('foo.jpg'))), [], @@ -129,7 +129,7 @@ public function testItIsNotCreatingMemoryWhenNoVectorsFound() $store, ); - $memory = $embeddingProvider->loadMemory(new Input( + $memory = $embeddingProvider->load(new Input( $this->createStub(Model::class), new MessageBag(Message::ofUser(new Text('Have we talked about the weather?'))), [], @@ -166,7 +166,7 @@ public function testItIsCreatingMemoryWithFoundVectors() $store, ); - $memory = $embeddingProvider->loadMemory(new Input( + $memory = $embeddingProvider->load(new Input( $this->createStub(Model::class), new MessageBag(Message::ofUser(new Text('Have we talked about the weather?'))), [], diff --git a/src/agent/tests/Memory/MemoryInputProcessorTest.php b/src/agent/tests/Memory/MemoryInputProcessorTest.php index e571d9005..c5ac3f8de 100644 --- a/src/agent/tests/Memory/MemoryInputProcessorTest.php +++ b/src/agent/tests/Memory/MemoryInputProcessorTest.php @@ -64,12 +64,12 @@ public function testItIsAddingMemoryToSystemPrompt() { $firstMemoryProvider = $this->createMock(MemoryProviderInterface::class); $firstMemoryProvider->expects($this->once()) - ->method('loadMemory') + ->method('load') ->willReturn([new Memory('First memory content')]); $secondMemoryProvider = $this->createMock(MemoryProviderInterface::class); $secondMemoryProvider->expects($this->once()) - ->method('loadMemory') + ->method('load') ->willReturn([]); $memoryInputProcessor = new MemoryInputProcessor( @@ -106,7 +106,7 @@ public function testItIsAddingMemoryToSystemPromptEvenItIsEmpty() { $firstMemoryProvider = $this->createMock(MemoryProviderInterface::class); $firstMemoryProvider->expects($this->once()) - ->method('loadMemory') + ->method('load') ->willReturn([new Memory('First memory content')]); $memoryInputProcessor = new MemoryInputProcessor($firstMemoryProvider); @@ -136,7 +136,7 @@ public function testItIsAddingMultipleMemoryFromSingleProviderToSystemPrompt() { $firstMemoryProvider = $this->createMock(MemoryProviderInterface::class); $firstMemoryProvider->expects($this->once()) - ->method('loadMemory') + ->method('load') ->willReturn([new Memory('First memory content'), new Memory('Second memory content')]); $memoryInputProcessor = new MemoryInputProcessor($firstMemoryProvider); @@ -167,7 +167,7 @@ public function testItIsNotAddingAnythingIfMemoryWasEmpty() { $firstMemoryProvider = $this->createMock(MemoryProviderInterface::class); $firstMemoryProvider->expects($this->once()) - ->method('loadMemory') + ->method('load') ->willReturn([]); $memoryInputProcessor = new MemoryInputProcessor($firstMemoryProvider); diff --git a/src/agent/tests/Memory/StaticMemoryProviderTest.php b/src/agent/tests/Memory/StaticMemoryProviderTest.php index ecfbbbeb0..6c82b94d8 100644 --- a/src/agent/tests/Memory/StaticMemoryProviderTest.php +++ b/src/agent/tests/Memory/StaticMemoryProviderTest.php @@ -33,7 +33,7 @@ public function testItsReturnsNullWhenNoFactsAreProvided() { $provider = new StaticMemoryProvider(); - $memory = $provider->loadMemory(new Input( + $memory = $provider->load(new Input( $this->createStub(Model::class), new MessageBag(), [] @@ -49,7 +49,7 @@ public function testItDeliversFormattedFacts() $fact2 = 'Water is wet', ); - $memory = $provider->loadMemory(new Input( + $memory = $provider->load(new Input( $this->createStub(Model::class), new MessageBag(), []