Feature
Feature companion object that allows installing the AgentMemory feature in an agent.
This object implements AIAgentFeature to provide the necessary functionality for integrating memory capabilities into an agent.
To install the AgentMemory feature in your agent:
val agent = AIAgents(
strategy = myStrategy,
promptExecutor = myExecutor
) {
// Install memory feature with custom configuration
install(AgentMemory) {
// Configure memory provider (required)
memoryProvider = LocalFileMemoryProvider(
config = LocalMemoryConfig("my-agent-memory"),
storage = SimpleStorage(JVMFileSystemProvider),
root = Path("memory/data")
)
// Configure scope names (optional)
featureName = "bank-assistant"
productName = "my-bank"
organizationName = "my-company"
}
}
Content copied to clipboard
Example usage within an agent node:
val rememberUserPreference by node {
withMemory {
// Save a fact about user preference
agentMemory.save(
fact = SingleFact(
concept = Concept("preferred-language", "User's preferred programming language"),
value = "Kotlin"
),
subject = MemorySubjects.User,
scope = MemoryScope.Product("my-ide")
)
}
}
Content copied to clipboard