High-performance, persistence-layer agnostic memory context awareness for Multi-Agent Systems.
ContextLoom is an open-source framework designed to decouple Memory from Compute. It creates a shared, persistent "Context State" residing in Redis that allows disparate LLM frameworks (DSPy, CrewAI, Agno, Google ADK) to share awareness, maintain continuity, and handle "Cold Start" data pulls from traditional databases.
Building multi-agent systems often results in "amnesic" architectures where:
- Context is siloed: An agent in CrewAI doesn't know what a DSPy module just optimized.
- Cold starts are hard: Injecting historical customer data from Postgres into a fresh agent session is manual and brittle.
- Cycles are broken: Long-running conversation flows lose coherence as context windows fill up or sessions time out.
ContextLoom acts as the cerebral cortex for your agents—a centralized, high-speed memory store that persists the state of the conversation cycle, not just the logs.
- ⚡ Redis-First Architecture: Leverages Redis for sub-millisecond context retrieval and state updates, ensuring agents don't lag.
- 🔌 Universal Connectors: "Cold Start" your context by pulling initial state automatically from PostgreSQL, MySQL, or MongoDB.
- 🤝 Framework Agnostic: Native wrappers for:
- DSPy (Signatures & Modules)
- CrewAI (Agent Memory & Task Output)
- Agno (Workflow State)
- Google GenAI SDK (ADK)
- 🔄 Cycle Management: Intelligent handling of communication loops to prevent repetition and ensure goal progression.
ContextLoom introduces the concept of Communication Cycles to maintain smarter agents.
In standard LLM interactions, context is linear. In ContextLoom, context is Cyclic and State-Aware:
- Ingest (Cold Start): The framework hydrates the Redis session with relevant entities from your SQL/NoSQL source (e.g., User Profile, last 5 orders).
- Interaction Phase: Agents read the
GlobalContext. A CrewAI researcher adds findings; a DSPy optimizer refines the prompt based on that finding. - State Snapshotting: After every interaction turn, ContextLoom calculates a "Cycle Hash".
- Why this helps: If an agent begins looping (repeating logic), ContextLoom detects the duplicate hash and flags the agent to pivot strategies.
- Persistence: The updated state is pushed back to Redis, ready for the next agent, even if that agent is running on a different server or framework.
pip install contextloom- Initialize with specific Backend
from contextloom import Loom, PostgresConnector
# Connect to Redis (Memory) and Postgres (History)
loom = Loom(
memory_backend="redis://localhost:6379",
data_source=PostgresConnector("postgresql://user:pass@localhost:5432/mydb")
)- Hydrate & Run with DSPy
import dspy
# Create a session ID
session_id = "user_123_cycle_4"
# Pull data from Postgres automatically into Redis Context
context = loom.hydrate(session_id, query="SELECT * FROM users WHERE id=123")
# DSPy Integration
class IntentClassifier(dspy.Signature):
"""Classify user intent based on Loom Context."""
context_snapshot = dspy.InputField(desc="Current state from Redis")
user_query = dspy.InputField()
intent = dspy.OutputField()
# The agent is now "Aware" of the DB data without manual injection
result = dspy.Predict(IntentClassifier)(
context_snapshot=context.get_current_state(),
user_query="Where is my order?"
)
# Update the Loom Cycle
loom.update_cycle(session_id, step="classification", data=result)