Package akka.javasdk.agent
Interface MemoryProvider
- All Known Implementing Classes:
MemoryProvider.CustomMemoryProvider,MemoryProvider.Disabled,MemoryProvider.FromConfig,MemoryProvider.InterceptedMemoryProvider,MemoryProvider.LimitedWindowMemoryProvider
public sealed interface MemoryProvider
permits MemoryProvider.FromConfig, MemoryProvider.Disabled, MemoryProvider.LimitedWindowMemoryProvider, MemoryProvider.CustomMemoryProvider, MemoryProvider.InterceptedMemoryProvider
Interface for configuring memory management in agent systems.
MemoryProvider defines how session history is stored and retrieved during agent interactions. It offers several implementation strategies:
- Configuration-based memory management via
MemoryProvider.FromConfig - Disabled memory (no history) via
MemoryProvider.Disabled - Limited window memory management via
MemoryProvider.LimitedWindowMemoryProvider - Custom memory implementation via
MemoryProvider.CustomMemoryProvider - Interceptor-wrapped memory via
MemoryProvider.InterceptedMemoryProvider
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordMemory provider that uses a custom SessionMemory implementation.static final recordDisabled memory provider, which does not store or retrieve contextual history.static final recordConfiguration-based memory provider that reads settings from the specified path.static final classMemory provider that wraps anotherMemoryProviderwith aSessionMemoryInterceptor.static final recordMemory provider that limits session history based on size or message count. -
Method Summary
Modifier and TypeMethodDescriptioncustom(SessionMemory sessionMemory) Creates a custom memory provider using the specified SessionMemory implementation.static MemoryProviderCreates a configuration-based memory provider based on configuration defaults.static MemoryProviderfromConfig(String configPath) Creates a memory provider based on configuration settings.Creates a limited window memory provider with default settings.static MemoryProvider.Disablednone()Disabled memory provider, which does not store or retrieve contextual history.default MemoryProviderwithInterceptor(SessionMemoryInterceptor interceptor) Wraps this provider with aSessionMemoryInterceptorthat interceptsaddInteractioncalls.
-
Method Details
-
fromConfig
Creates a configuration-based memory provider based on configuration defaults.- Returns:
- A configuration-based memory provider
-
fromConfig
Creates a memory provider based on configuration settings.- Parameters:
configPath- Path to the configuration. If empty, uses the default path "akka.javasdk.agent.memory"- Returns:
- A configuration-based memory provider
-
withInterceptor
Wraps this provider with aSessionMemoryInterceptorthat interceptsaddInteractioncalls. The underlying read/write behavior of this provider is preserved on the delegate exposed to the interceptor.Calling
withInterceptoron a provider that already has an interceptor replaces the existing interceptor; interceptors are not chained.- Parameters:
interceptor- The interceptor to apply- Returns:
- A memory provider that invokes the interceptor on writes
-
none
Disabled memory provider, which does not store or retrieve contextual history.- Returns:
- A memory provider without memory.
-
limitedWindow
Creates a limited window memory provider with default settings.The default settings are:
- Include all session history in each interaction with the model
- Record all interactions into memory
- Returns:
- A new limited window memory provider with default settings
-
custom
Creates a custom memory provider using the specified SessionMemory implementation.This allows for complete customization of memory management behavior.
- Parameters:
sessionMemory- The custom SessionMemory implementation- Returns:
- A new custom memory provider
-