Memory¶
This docs was updated at: 2026-02-23
com.paragon.agents.Memory ยท Interface
Interface for agent long-term memory storage with user isolation.
Memory provides persistent storage for agent knowledge that persists across sessions. All operations are scoped by userId to ensure data isolation between users.
Memory is exposed to the agent as tools via MemoryTool. The userId is passed securely
by the developer in Agent.interact(input, context, userId), NOT by the LLM, to prevent
prompt injection attacks.
Example usage:
Memory storage = InMemoryMemory.create();
Agent agent = Agent.builder()
.addMemoryTools(storage) // Adds memory as tools
.build();
// userId passed by developer - secure!
agent.interact("Remember my preference", context, "user-123");
See Also
MemoryEntryMemoryToolInMemoryMemory
Since: 1.0
Methods¶
add¶
Adds a new memory entry for a user.
Parameters
| Name | Description |
|---|---|
userId |
the user ID (for isolation) |
entry |
the memory to add |
add¶
Adds a memory with just content for a user.
Parameters
| Name | Description |
|---|---|
userId |
the user ID |
content |
the memory content |
retrieve¶
Retrieves memories relevant to a query for a user.
Parameters
| Name | Description |
|---|---|
userId |
the user ID |
query |
the search query |
limit |
maximum number of memories to return |
Returns
list of relevant memories, ordered by relevance
update¶
Updates an existing memory entry for a user.
Parameters
| Name | Description |
|---|---|
userId |
the user ID |
id |
the memory ID to update |
entry |
the new memory content |
Throws
| Type | Condition |
|---|---|
IllegalArgumentException |
if memory with ID doesn't exist for this user |
delete¶
Deletes a memory by ID for a user.
Parameters
| Name | Description |
|---|---|
userId |
the user ID |
id |
the memory ID to delete |
Returns
true if memory was deleted, false if not found
all¶
Returns all stored memories for a user.
Parameters
| Name | Description |
|---|---|
userId |
the user ID |
Returns
list of all memories for this user
size¶
Returns the number of stored memories for a user.
Parameters
| Name | Description |
|---|---|
userId |
the user ID |
Returns
memory count for this user
clear¶
Clears all memories for a user.
Parameters
| Name | Description |
|---|---|
userId |
the user ID |
clearAll¶
Clears all memories for all users.