Feature Request: Enhanced Memory Management for Multi-Agent Systems
Description
While working with LightAgent's multi-agent collaboration features, I noticed an opportunity to enhance the memory management system when multiple agents are interacting within the same context. Currently, each agent maintains its own memory state through the CustomMemory class, but there could be benefits to implementing a shared memory pool for related agents in a swarm.
Proposed Solution
-
Implement a
SharedMemoryPoolclass that can:- Maintain a centralized memory store for agent swarms
- Handle memory conflicts between agents
- Provide memory isolation when needed
- Support memory synchronization across agents
-
Add configuration options for:
- Memory sharing policies
- Access control between agents
- Memory retention strategies
- Cross-agent memory querying
Expected Benefits
- Improved collaboration between agents through shared context
- Reduced memory redundancy across agents
- Better handling of complex multi-agent scenarios
- More efficient resource utilization
Example Implementation
from LightAgent import LightSwarm, LightAgent
# Proposed usage
swarm = LightSwarm(shared_memory=True)
agent_a = LightAgent(
name="Agent A",
memory_pool="shared_pool_1", # Specify shared memory pool
role="Receptionist"
)
agent_b = LightAgent(
name="Agent B",
memory_pool="shared_pool_1", # Same pool for shared context
role="Technical Support"
)
swarm.register_agent(agent_a, agent_b)
Questions
- Would this feature align with LightAgent's lightweight design philosophy?
- Are there any potential performance implications to consider?
- How should we handle memory consistency across different model backends?
Environment
- LightAgent version: 0.2.7
- Python version: 3.8+
- Operating System: Linux/MacOS/Windows
Additional Context
This feature request is inspired by real-world usage patterns in customer service scenarios where multiple specialized agents need to maintain consistent context while handling user inquiries.
Let me know if any additional information would be helpful!
Great idea! The SharedMemoryPool aligns with LightAgent's lightweight philosophy and could be added as an optional module. We'll explore performance optimizations (like async sync) and backend-specific memory consistency solutions. This is now on our roadmap—we'd love your input during testing. Thanks for the thoughtful proposal!
Update after the recent memory-safety work: MemoryPolicy now gives us the first layer needed for safe multi-agent/shared memory work: namespace scoping and retrieval filtering by provenance.\n\nFor a future SharedMemoryPool, the scope should stay lightweight and explicit:\n\n- optional module, not default behavior;\n- per-agent and per-swarm namespace policies;\n- provenance/trust metadata on memory records;\n- conflict handling rules that are deterministic and testable;\n- integration with guardrails for high-risk domains.\n\nI am keeping this open as a P1 design issue, but the next concrete PR should probably be an interface/design doc or a minimal in-memory prototype before adding external storage dependencies.
Great proposal! Shared memory is one of the hardest problems in multi-agent systems. Here are some patterns I've seen work well:
Letta's three-tier model (most mature implementation):
- Core Memory — always in context, agent-editable (persona, user profile)
- Recall Memory — searchable full history
- Archival Memory — infinite capacity, explicit retrieval
The key insight: not all memory needs to be shared. Core memory is per-agent; only archival memory is shared across the swarm.
AutoGen's approach (PR #6972): RedisMemory supports dual-mode retrieval — semantic (vector similarity) and sequential (temporal). For shared pools, this means agents can query either "what's relevant" or "what happened recently."
Suggested architecture for LightAgent:
# Per-agent private memory (existing CustomMemory)
agent.memory = CustomMemory()
# Shared pool with access control
shared = SharedMemoryPool(
isolation="read-write", # or "read-only" for observer agents
backend="sqlite", # lightweight for v1
retrieval="semantic", # or "sequential" or "both"
)
# Agent joins swarm with shared context
swarm = LightSwarm(agents=[agent1, agent2], shared_memory=shared)
Key design decisions to make early:
- Isolation model — Can agent A overwrite agent B's memories? (recommend: no, only append)
- Retrieval scope — When agent queries shared memory, does it see everything or filtered by relevance?
- Conflict resolution — Two agents insert contradictory facts? (recommend: keep both, let retrieval rank by recency + source confidence)
The lightweight philosophy aligns well with a SQLite backend for v1 — no external dependencies.
@wxai-space The MemoryPolicy as a foundation for SharedMemoryPool is a great architectural choice — policy-first design means you can add sharing semantics without changing the storage layer.
One pattern from AutoGen's GraphFlow (PR #6711) that might be relevant: they use a two-layer activation map to distinguish between dependencies inside a cycle vs outside. For shared memory, a similar approach could handle:
- Agent A writes → Agent B reads (simple dependency)
- Agent A writes → Agent B writes back (circular dependency / conflict)
The two-layer model would let you track which memory mutations are "in-flight" (within a workflow cycle) vs "committed" (completed), preventing read-after-write inconsistencies.
Also, for the SQLite backend: consider adding WAL mode (PRAGMA journal_mode=WAL) for better concurrent read performance. Multiple agents reading shared memory simultaneously is the common case.
Looking forward to seeing SharedMemoryPool land! 🚀
Closing this as completed for the original request. LightAgent now includes an in-memory SharedMemoryPool satisfying MemoryProtocol, append-first records, user/scoped retrieval, provenance metadata, MemoryPolicy compatibility, documentation, and regression tests. Production durability, stronger access control, and explicit conflict resolution are intentionally outside this prototype and should be tracked in focused follow-up issues rather than keeping the broad original request open.