Rice provides a serverless backend purpose-built for managing agent context, state, and memory—so you can focus on building intelligent behavior, not infrastructure.
For the fastest way to get started, we recommend using the Rice Agents framework. It provides a set of high-level abstractions for building agents that natively leverage RiceDB's features.
pip install git+https://github.com/rice-ai-hq/rice_agents.git
A typical Rice-powered agent operates in a loop:
One of Rice's most powerful features for agents is the Working Memory layer. This allows agents to store ephemeral context without the overhead of re-embedding or polluting the long-term Hyper Vector store.
| Feature | Use "Working Memory" (Scratchpad) | Use "Long-Term Memory" (Hyper Vectors) |
|---|---|---|
| Data Type | Conversation history, current task status, intermediate thoughts. | Docs, knowledge base, past experiences. |
| Retention | Short-term (minutes to days). | Long-term (permanent). |
| Search | Time-ordered, Exact match. | Semantic similarity. |
| Speed | Extremely fast (no embedding). | Fast (requires embedding). |
Here is how you might structure a simple agent loop using RiceDB directly.
from ricedb import RiceDBClient
client = RiceDBClient("localhost")
client.connect()
SESSION_ID = "task-alpha-1"
def agent_loop(user_input):
# 1. OBSERVE: Add user input to memory
client.memory.add(
session_id=SESSION_ID,
agent="user",
content=user_input
)
# 2. RECALL: Get recent history + relevant long-term knowledge
recent_history = client.memory.get(session_id=SESSION_ID, limit=5)
# Search long-term memory for context
knowledge = client.search(
query=user_input,
user_id=1,
k=2
)
# 3. ACT: (Pseudo-code for LLM call)
# prompt = construct_prompt(recent_history, knowledge)
# response = llm.generate(prompt)
response = f"Processed: {user_input} based on {len(knowledge)} docs."
# 4. REFLECT: Store response back to memory
client.memory.add(
session_id=SESSION_ID,
agent="bot",
content=response
)
return response
# Run the loop
print(agent_loop("What is the status of Project X?"))
Rice facilitates coordination between multiple agents using shared memory spaces and Pub/Sub.
session_id in memory to share progress.# Example: Watch for updates (gRPC only)
for update in client.memory.watch("task-123"):
print(f"New activity: {update['content']}")
# Trigger reaction logic...