Memory and Belief Context
ASTRA offers several kinds of retained information. Choose them according to what must survive and who decides how it is used.
Mechanism |
Purpose |
What it does not imply |
|---|---|---|
Ordinary beliefs |
Current agent knowledge and application state |
Automatic inclusion in an LLM prompt |
BelRAG |
Render selected belief-derived context for a model |
Persistent episodic storage |
|
Recover data from an agent’s previous life |
Resumption of its old execution state |
|
Recall and retain scoped reasoning episodes |
Automatic trust in recalled information |
GUI history |
Inspect recorded system states |
Restoring the running system |
Restart memory
The Memory module provides weak recovery. A restarted agent starts afresh and can consult remembered beliefs and goals, then decide which to restore or pursue. memory.keep() enables recording for the calling agent. This is independent of MCP and LLM use.
Give a reasoning run a context
In an agent extending ReActTools, import astra.langchain4j.memory.* and create a fresh context for each solve:
MemoryScope scope = reasoningMemory.scope("orders", "solver", "customer-42");
ReasoningContext context = reasoningMemory.context(scope, 4096);
!solveWithMemory(context, question, string answer, string outcome);
The scope has application, agent and scope identifiers. Use them to separate unrelated work. A context belongs to one run; do not reuse it for another solve. The budget is measured in characters, not model tokens. Structured conversation trimming removes whole completed tool exchanges while preserving the required conversation structure; inability to fit produces exhaustion.
Select evidence explicitly
ReActCore recalls up to four candidate episodes when a run has a context, then calls !selectRecall(run, candidates). Its default selection plan does nothing. Override it to select applicable candidates using reasoningMemory.select(run, candidates, id).
Selection checks scope, expiry and the stored revision. Selected episodes enter the structured conversation as labelled historical evidence. They are neither current facts nor permission to call a tool. A past successful action does not establish that the same action is appropriate now.
The memory example shows selection, independently verified retention, recall after tool withdrawal and forgetting, with a scripted model and no provider key.
Retain verified outcomes
Override !retainRun(run, question, answer, outcome) to apply an application policy. Its default plan also does nothing. reasoningMemory.remember(...) accepts a task, summary, verification record and lifetime in milliseconds; zero means no expiry. A successful verification record requires a completed run, but the application must supply the independent check that supports that record.
Do not use the model’s claim of success as the verifier. Check a receipt, calculation or resulting service state. Failed-task evidence can be useful too, provided its verification record and summary accurately describe the failure.
The default store is bounded and in memory. It does not survive process restart. Java integrations can supply a ReasoningMemoryStore; durable storage is an application integration rather than a built-in persistence guarantee. forget(scope, id, revision) removes a particular stored revision.
Combine beliefs with episodic evidence
BelRAG supplies current belief-derived context; episodic memory supplies historical evidence. Keep their roles clear in the prompt. BelRAG.render(template) returns rendered text for consumers such as structured chat; see Prompts, responses and beliefs. The application decides which beliefs and episodes are relevant and checks recalled information before acting.