Skip to content

refactor(agentic): remove StoreMemoryCommand and ForgetMemoryCommand#320

Merged
jwijgerd merged 1 commit intomainfrom
copilot/refactor-forgetmemory-and-storememory
Apr 10, 2026
Merged

refactor(agentic): remove StoreMemoryCommand and ForgetMemoryCommand#320
jwijgerd merged 1 commit intomainfrom
copilot/refactor-forgetmemory-and-storememory

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 10, 2026

StoreMemoryCommand and ForgetMemoryCommand are no longer needed — MemoryStoredEvent and MemoryRevokedEvent are now generated directly by the Embabel agent layer (via its memory management tools), bypassing the command bus entirely.

Removed

  • StoreMemoryCommand.java and ForgetMemoryCommand.java deleted
  • BUILTIN_COMMAND_TYPES constant removed from AkcesAgenticAggregateController
  • Built-in command schema registration removed from registerBuiltinSchemas() (now registers only built-in event schemas)
  • Built-in commands no longer published to Akces-Control topic in publishControlRecord()
  • Built-in command lookup removed from resolveType()

Sliding-window eviction removed from runtime layer

AgenticAggregatePartition.enforceMemorySlidingWindow() is deleted along with its maxMemories field — the Embabel agent's LearnFromProcessGoal is responsible for enforcing memory capacity bounds by producing MemoryRevokedEvent directly.

Constructor signatures changed

  • AkcesAgenticAggregateControllermaxMemories parameter dropped
  • AgenticAggregatePartitionmaxMemories parameter dropped
  • AgenticAggregateBeanFactoryPostProcessor — no longer passes agenticInfo.maxMemories() to the controller bean definition

Note: maxMemories remains on @AgenticAggregateInfo for use by the Embabel agent layer.

Documentation updated

  • FRAMEWORK_OVERVIEW.md — "Built-in commands" row updated; memory section updated to reflect Embabel ownership
  • Javadoc on MemoryRevokedEvent, MemorySlidingWindowTest, and the affected runtime classes updated

@jwijgerd jwijgerd marked this pull request as ready for review April 10, 2026 10:38
Copilot AI review requested due to automatic review settings April 10, 2026 10:38
@jwijgerd jwijgerd merged commit 18fc54c into main Apr 10, 2026
9 checks passed
@jwijgerd jwijgerd deleted the copilot/refactor-forgetmemory-and-storememory branch April 10, 2026 10:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the agentic memory subsystem to remove the StoreMemoryCommand/ForgetMemoryCommand pathway and runtime-layer sliding-window enforcement, shifting memory add/revoke responsibilities fully to the Embabel agent layer (which emits MemoryStoredEvent / MemoryRevokedEvent directly).

Changes:

  • Deleted StoreMemoryCommand and ForgetMemoryCommand, and removed controller support for built-in command schemas/control-record publication.
  • Removed AgenticAggregatePartition’s post-command sliding-window eviction (and maxMemories wiring) from the runtime layer.
  • Updated tests and documentation to reflect that memory revoke/eviction events are produced by the Embabel layer.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
main/agentic/src/main/java/org/elasticsoftware/akces/agentic/runtime/AkcesAgenticAggregateController.java Drops built-in command registration/publication and removes maxMemories from construction/wiring.
main/agentic/src/main/java/org/elasticsoftware/akces/agentic/runtime/AgenticAggregatePartition.java Removes runtime-layer sliding-window enforcement after command processing.
main/agentic/src/main/java/org/elasticsoftware/akces/agentic/events/MemoryRevokedEvent.java Updates Javadoc to reflect Embabel-owned memory revocation/eviction.
main/agentic/src/main/java/org/elasticsoftware/akces/agentic/commands/StoreMemoryCommand.java Deleted (built-in memory storage no longer routed via command bus).
main/agentic/src/main/java/org/elasticsoftware/akces/agentic/commands/ForgetMemoryCommand.java Deleted (built-in memory revocation no longer routed via command bus).
main/agentic/src/main/java/org/elasticsoftware/akces/agentic/beans/AgenticAggregateBeanFactoryPostProcessor.java Stops passing maxMemories into the controller constructor.
main/agentic/src/test/java/org/elasticsoftware/akces/agentic/runtime/MemorySlidingWindowTest.java Updates commentary to align with Embabel emitting revoke events (test continues to simulate the window via events).
FRAMEWORK_OVERVIEW.md Updates docs: no built-in memory commands; built-in memory events remain; Embabel owns eviction.

Comment on lines +391 to 395
// Collect aggregate command types for the service record
List<AggregateServiceCommandType> allCommands = new ArrayList<>();
BUILTIN_COMMAND_TYPES.forEach(ct ->
allCommands.add(new AggregateServiceCommandType(
ct.typeName(), ct.version(), ct.create(),
"commands." + ct.typeName())));
aggregateRuntime.getLocalCommandTypes().forEach(ct ->
allCommands.add(new AggregateServiceCommandType(
ct.typeName(), ct.version(), ct.create(),
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In publishControlRecord(), producedEvents is built later by combining BUILTIN_EVENT_TYPES with aggregateRuntime.getProducedDomainEventTypes(). Since AgenticAggregateRuntimeFactory already adds the memory event types (MEMORY_STORED/REVOKED) into the runtime’s produced domain events, this results in duplicate memory event entries in the AggregateServiceRecord. Consider de-duplicating the produced event list (e.g., by (typeName, version)) or removing the built-in add to avoid duplicates in service discovery.

Copilot uses AI. Check for mistakes.
Comment on lines 273 to 278
private void registerBuiltinSchemas() {
logger.info("Registering built-in agentic schemas for {}Aggregate",
aggregateRuntime.getName());
for (CommandType<?> commandType : BUILTIN_COMMAND_TYPES) {
try {
aggregateRuntime.registerAndValidate(commandType, schemaRegistry);
} catch (IncompatibleSchemaException e) {
logger.warn("Built-in command schema {} is incompatible — attempting force-register",
commandType.typeName(), e);
try {
aggregateRuntime.registerAndValidate(commandType, schemaRegistry, true);
} catch (Exception ex) {
logger.error("Failed to force-register built-in command schema {}",
commandType.typeName(), ex);
throw new RuntimeException("Failed to register built-in command schema: "
+ commandType.typeName(), ex);
}
} catch (Exception e) {
throw new RuntimeException("Failed to register built-in command schema: "
+ commandType.typeName(), e);
}
}
for (DomainEventType<?> eventType : BUILTIN_EVENT_TYPES) {
try {
aggregateRuntime.registerAndValidate(eventType, schemaRegistry);
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registerBuiltinSchemas() registers the memory event schemas from BUILTIN_EVENT_TYPES, but registerAggregateSchemas() later iterates aggregateRuntime.getProducedDomainEventTypes(), which (per AgenticAggregateRuntimeFactory) already includes MEMORY_STORED_TYPE and MEMORY_REVOKED_TYPE. This causes redundant registration/validation attempts for the same schemas. Consider registering event schemas from a single de-duplicated source, or explicitly excluding the built-in memory types from one of the passes to avoid duplicate work and confusing logs.

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +41
* Tests the sliding-window memory eviction logic in the state transition layer.
* The eviction algorithm is exercised by simulating the sequence of events that are
* produced by the Embabel layer during the agent's memory management process.
*
* <p>The partition enforces the limit by issuing {@link org.elasticsoftware.akces.agentic.commands.ForgetMemoryCommand}
* for the oldest entry (first in the list) until the count drops to the allowed window.
* Each {@code ForgetMemoryCommand} produces a {@link MemoryRevokedEvent} that updates
* the state through the built-in event-sourcing handler in
* <p>Memory revocation is handled by the Embabel agent (via its memory management tools),
* which produces {@link MemoryRevokedEvent} directly. Each such event updates the
* state through the built-in event-sourcing handler in
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated class Javadoc says this test covers “sliding-window memory eviction logic in the state transition layer” and that the eviction algorithm is “produced by the Embabel layer”. However the eviction loop is not part of the state-transition code under test; it’s implemented in this test via enforceWindow() by manually generating MemoryRevokedEvents. Consider rewording the Javadoc to clarify that the test validates memory state transitions when the Embabel layer emits revoke events, rather than testing an eviction algorithm in the runtime/state layer.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants