Recursive Episodic Memory for AI Agents — persistent memory infrastructure
Project description
REM Python SDK
rem-memory is the official Python SDK for REM (Recursive Episodic Memory) — an open-source memory layer for AI agents.
Installation
pip install rem-memory
Quick start
import asyncio
from rem_memory import REMClient
async def main():
async with REMClient(api_key="rem_sk_...") as client:
# Write a memory episode
result = await client.write(
content="User prefers TypeScript with strict mode for all new projects.",
agent_id="agent_cursor",
user_id="user_alice",
)
print(result.episode_id)
# Retrieve relevant memories
memories = await client.retrieve(
query="Does the user prefer TypeScript or JavaScript?",
agent_id="agent_cursor",
top_k=5,
)
for m in memories.episodes:
print(m.intent, m.importance_score)
asyncio.run(main())
Configuration
| Parameter | Default | Description |
|---|---|---|
api_key |
— | Your REM API key (X-API-Key header) |
base_url |
http://localhost:8080 |
Base URL of the REM Go API |
timeout |
30 |
Request timeout in seconds |
Environment variables are also supported:
export REM_API_KEY=rem_sk_...
export REM_BASE_URL=http://localhost:8080
Integrations
LangChain
from rem_memory.integrations.langchain import REMMemory
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI
memory = REMMemory(
api_key="rem_sk_...",
agent_id="agent_cursor",
user_id="user_alice",
)
chain = ConversationChain(llm=ChatOpenAI(), memory=memory)
response = chain.predict(input="What are my coding preferences?")
AutoGen
from rem_memory.integrations.autogen import REMMemoryStore
from autogen import ConversableAgent
memory_store = REMMemoryStore(
api_key="rem_sk_...",
agent_id="agent_autogen",
)
agent = ConversableAgent(
name="assistant",
system_message="You are a helpful coding assistant.",
)
# Inject past memories into system prompt
context = await memory_store.get_context(query="user coding preferences")
API Reference
REMClient
write(content, agent_id, user_id, session_id?, metadata?)
Write a raw interaction to episodic memory. Returns WriteResult.
retrieve(query, agent_id, top_k?, include_semantic?)
Retrieve semantically relevant episodes and facts. Returns RetrieveResult.
get_agent(agent_id)
Fetch agent metadata. Returns Agent.
list_agents()
List all agents. Returns List[Agent].
list_episodes(agent_id, limit?, offset?)
Page through raw episodes for an agent. Returns List[Episode].
list_semantic_memories(agent_id)
Fetch all consolidated semantic memories. Returns List[SemanticMemory].
Development
cd sdk/python
pip install -e ".[dev]"
pytest
License
MIT © REM Contributors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rem_memory-0.1.0.tar.gz.
File metadata
- Download URL: rem_memory-0.1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fa5ebd93688fd5dcc9e6dd94ef147cd379706de03a790399fd51adb3b16a539
|
|
| MD5 |
2994ad5f556d1004182b627bb7f07e3c
|
|
| BLAKE2b-256 |
04b6030104bcd89d91cbbd87b761aa5b0d0dc600139125b2ed58bc6fdbe950d0
|
File details
Details for the file rem_memory-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rem_memory-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b27a7850187d505563108c3323d3f4ee4b725118c3ff6ffdeb7e387fd36d577d
|
|
| MD5 |
b949edc33f70a58e3ce7a2a91d7838b4
|
|
| BLAKE2b-256 |
8bbd201e3a4bf48bd3700838ce989575186306e26621536d8e58cbb723934418
|