Scoped Memory for Agent Systems: Cross-Run Persistence Without Global State AgentEnsemble has introduced named memory scopes for agent systems, enabling cross-run persistence without global shared state. The framework allows each task to declare which memory scopes it reads from and writes to, with scope names serving as isolation boundaries that control which context an agent receives. Two built-in implementations are available: an in-memory store for development and an embedding-based store using semantic similarity search for durable, production use. Most agent frameworks treat each run as stateless. The agent starts fresh, does its work, and the output is consumed by whatever called it. If you run the same workflow again next week, the agent has no memory of what it produced last time. For some use cases that is fine. For others -- recurring research tasks, iterative drafting, accumulated domain knowledge -- you want the agent to remember what it learned in previous runs and build on it. The question is how to add cross-run memory without introducing global shared state that makes the system hard to reason about. AgentEnsemble https://github.com/AgentEnsemble/agentensemble uses named memory scopes. Each task declares which scopes it reads from and writes to. A task can only see memory from scopes it explicitly declares. MemoryStore store = MemoryStore.inMemory ; Task researchTask = Task.builder .description "Research current AI trends" .expectedOutput "A research report" .agent researcher .memory "ai-research" .build ; Ensemble.builder .agent researcher .task researchTask .memoryStore store .build .run ; After the run, the task's output is stored in the "ai-research" scope. On a second run with the same store, the agent's prompt automatically includes entries from the first run under a Memory: ai-research section. The scope name is the isolation boundary. Task A storing into "research" and task B declaring only "drafts" means task B never sees task A's output. This is not a security mechanism -- it is an attention mechanism. It controls what context an agent receives, keeping prompts focused on relevant history rather than everything that ever happened. The mechanics are straightforward: MemoryStore across runs, agents in later runs automatically see outputs from earlier runs.The prompt injection looks like this: Memory: ai-project The following information from scope "ai-project" may be relevant: --- Research findings from previous run: AI is accelerating in healthcare... --- Task Analyse the research findings There is no magic retrieval. The framework puts the memory content into the prompt, and the LLM uses it or ignores it during reasoning. MemoryStore has two built-in implementations: In-memory stores entries in insertion order per scope. Retrieval returns the most recent entries without semantic search. Suitable for development, testing, and single-JVM runs. Entries do not survive JVM restarts. MemoryStore store = MemoryStore.inMemory ; Embedding-based stores entries via an embedding model and retrieves them via semantic similarity search. The backing EmbeddingStore controls durability -- Chroma, Qdrant, Pinecone, pgvector, or any LangChain4j-compatible store. EmbeddingModel embeddingModel = OpenAiEmbeddingModel.builder .apiKey System.getenv "OPENAI API KEY" .modelName "text-embedding-3-small" .build ; EmbeddingStore