ContextLoom
ContextLoom is the shared "brain" for multi-agent systems. It weaves together memory threads from frameworks like DSPy and CrewAI into a unified, persistent context, powered by Redis and hydrated from your existing databases.
Install / Use
/learn @danielckv/ContextLoomREADME
ContextLoom 🧶
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.
<img width="949" height="552" alt="image" src="https://github.com/user-attachments/assets/0e408458-fd71-462e-b7a9-bb51e092c1c0" />🚀 Why ContextLoom?
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.
✨ Key Features
- ⚡ 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.
🧠 The "Cycle" of Communication
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.
🛠️ Installation
pip install contextloom
💻 Usage Example
- 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)
Architecture
<img width="634" height="1652" alt="image" src="https://github.com/user-attachments/assets/d08d64fe-79e2-45ac-8dd3-29cc20f3f3c5" />Related Skills
feishu-drive
348.5k|
things-mac
348.5kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
348.5kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
postkit
PostgreSQL-native identity, configuration, metering, and job queues. SQL functions that work with any language or driver
