feat: Add S3 chat memory repository implementation#5091
feat: Add S3 chat memory repository implementation#5091ybezsonov wants to merge 12 commits intospring-projects:mainfrom
Conversation
- Add S3ChatMemoryRepository with CRUD operations for chat history - Implement S3ChatMemoryConfig with builder pattern and validation - Add Spring Boot auto-configuration for integration - Include test suite (22 tests total): - Property-based tests with jqwik for edge cases - Integration tests with Testcontainers and LocalStack - AutoConfiguration tests for Spring Boot integration - Add documentation Resolves: spring-projects#5088 Signed-off-by: Yuriy Bezsonov <ybezsonov@gmail.com>
…epository Signed-off-by: Yuriy Bezsonov <ybezsonov@gmail.com>
- Add @nullable annotations to Builder fields in S3ChatMemoryConfig - Add @nullable to extractConversationId return type in S3ChatMemoryRepository - Add @NullMarked annotation to package-info.java - Remove misplaced AutoConfiguration.imports file from core module Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
...c/main/java/org/springframework/ai/autoconfigure/chat/memory/repository/s3/package-info.java
Show resolved
Hide resolved
...a/org/springframework/ai/autoconfigure/chat/memory/repository/s3/S3ChatMemoryProperties.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/springframework/ai/chat/memory/repository/s3/S3ChatMemoryRepositoryIT.java
Show resolved
Hide resolved
memory/repository/spring-ai-model-chat-memory-repository-s3/pom.xml
Outdated
Show resolved
Hide resolved
…module - Add @NullMarked annotation to package-info.java - Add @nullable to getBucketName() getter (field without default) - Remove duplicate maven-compiler-plugin configuration (inherited from parent) Signed-off-by: Yuriy Bezsonov <ybezsonov@gmail.com>
Signed-off-by: Yuriy Bezsonov <ybezsonov@gmail.com>
Signed-off-by: Yuriy Bezsonov <ybezsonov@gmail.com>
...3/src/main/java/org/springframework/ai/chat/memory/repository/s3/S3ChatMemoryRepository.java
Outdated
Show resolved
Hide resolved
...3/src/main/java/org/springframework/ai/chat/memory/repository/s3/S3ChatMemoryRepository.java
Show resolved
Hide resolved
…ce notes - Document AWS SDK for Java 2.x requirement (v1 not supported) - Add performance note about findConversationIds() pagination at scale - Use ChatMemory.DEFAULT_CONVERSATION_ID for null/empty conversation IDs Signed-off-by: Yuriy Bezsonov <ybezsonov@gmail.com>
|
Hey @ybezsonov, I got one more follow-up question – is there any way to support dynamic key prefixes, or would that be too complex to add? For example, if we wanted to organize chat history like This would be helpful for multi-tenant scenarios or when we need to partition history by different business dimensions without creating separate repository instances for each combination. Thanks! |
Hi @akukuruza, This is an interesting idea, and multi-tenancy is a very valid use case. I don't know about the date, but I think sessionId could be useful in this case. Some time ago, I implemented short-term and long-term memory with Spring AI https://dev.to/yuriybezsonov/a-practical-guide-to-building-ai-agents-with-java-and-spring-ai-part-2-add-memory-odn and recently updated it to managed memory with AgentCore https://dev.to/yuriybezsonov/ai-agent-memory-made-easy-amazon-bedrock-agentcore-memory-with-spring-ai-3bng. I will review them all and come up with a solution which should cover multi-tenancy and be ready for different types of memory - similar to namespaces in AgentCore, I think. |
Appreciate your work on this! The way I see it, adding a |
Add optional keyResolver and conversationIdExtractor functions to S3ChatMemoryConfig, enabling hierarchical S3 key structures at runtime. This supports multi-tenant scenarios and business-dimension partitioning without requiring separate repository instances per namespace. When neither function is set, existing static keyPrefix behavior is preserved. When set, both must be provided together (validated at build time). The keyPrefix continues to serve as the listing base for findConversationIds(). Signed-off-by: Yuriy Bezsonov <ybezsonov@gmail.com>
Add S3ChatMemoryRepository with CRUD operations for chat history
Features:
Test suite (15 integration tests):
Documentation:
Resolves: #5088