This is a small Java 25 CLI demo for durable AI agent memory with LangChain4j, OpenAI, and Oracle AI Vector Search.
The app stores seed memories as embeddings in Oracle, retrieves the most relevant memories for a question, and sends the retrieved memory context to a chat model. Retrieved memories are treated as context, not instructions.
- Java 25
- Maven 3.9+
- Docker, or an existing Oracle AI Database / Oracle Database with vector support
OPENAI_API_KEY
Log in to Oracle Container Registry first if your Docker client has not accepted the image terms.
docker compose up -dWait until the database is ready, then create the tutorial user:
docker exec -i oracle-memory-db bash -lc 'sqlplus -s sys/Oracle_4U_demo@localhost:1521/FREEPDB1 as sysdba' < sql/setup_user.sqlsource .env.exampleReplace OPENAI_API_KEY with a real key. If you are using another database, update ORACLE_JDBC_URL, ORACLE_USER, and ORACLE_PASSWORD.
mvn -q compile exec:javaExpected shape of the output:
Question:
What should I do on my first weekend in Paris?
Retrieved memories:
1. score=...
The traveler is visiting Paris for the first time and wants a relaxed weekend plan.
...
Answer:
Start with one major museum, one classic viewpoint, and time to wander...
The follow-up article uses a second entry point that keeps the original semantic memory demo intact and adds working, episodic, procedural, and relationship tables.
export MEMORY_SESSION_ID="paris-weekend"
export MEMORY_QUESTION="What should I do on my first weekend in Paris?"
mvn -q compile exec:java -Dexec.mainClass=dev.redstack.demo.memory.MultiMemoryAgentAppThis run writes:
- Working memory to
AGENT_WORKING_MEMORYas JSON - Semantic memory to
AGENT_MEMORY_STOREthroughOracleEmbeddingStore - Episodic memory to
AGENT_EPISODES - Procedural memory to
AGENT_PROCEDURES - Memory relationships to
AGENT_MEMORY_EDGES
It also prints a memory plan before the answer so you can see which memory types were selected for the question and which ones were skipped.
To remove only the demo user and its objects:
docker exec -i oracle-memory-db bash -lc 'sqlplus -s sys/Oracle_4U_demo@localhost:1521/FREEPDB1 as sysdba' < sql/drop_user.sqlTo stop the database container:
docker compose downAdd -v only when you also want to remove the local database volume.