Multi-Agent Systems with Neural Weave

    Build collaborative AI systems where multiple agents share knowledge and work together seamlessly.

    Overview

    Multi-agent systems allow you to create teams of specialized AI agents that can collaborate, share memories, and solve complex problems together. Neural Weave provides the memory infrastructure to enable seamless agent coordination.

    Key Concepts

    • Shared Memory: Agents can access and contribute to a common memory pool
    • Agent Scoping: Control which memories each agent can access
    • Memory Handoffs: Transfer context between agents efficiently
    • Team Coordination: Enable agents to build on each other's work

    Basic Example

    from memorystack import MemoryStackClient
    
    # Initialize client (only needs API key)
    client = MemoryStackClient(api_key="your-api-key")
    
    # Agent 1: Research Agent stores findings
    client.add(
        "Found key insights about market trends: AI adoption up 40% YoY",
        metadata={"agent_id": "research-agent", "type": "research"}
    )
    
    # Agent 2: Analysis Agent searches for research context
    analysis_context = client.search("market trends")
    
    # Analysis Agent stores its findings
    client.add(
        f"Based on research: Market shows strong growth potential",
        metadata={"agent_id": "analysis-agent", "type": "analysis"}
    )

    Advanced Patterns

    1. Sequential Agent Handoffs

    Pass context from one agent to the next in a pipeline:

    # Agent pipeline: Research → Analysis → Report
    agents = ["researcher", "analyst", "reporter"]
    
    for i, agent in enumerate(agents):
        context = None
        if i > 0:
            # Get context from previous agent
            context = client.search("latest findings")
        
        # Process and store results
        result = process_with_agent(agent, context)
        client.add(result, metadata={"agent_id": agent})

    2. Parallel Agent Collaboration

    Multiple agents work simultaneously and share findings:

    import asyncio
    
    async def agent_task(agent_id, task):
        # Each agent works independently
        result = await process_task(task)
        
        # Store in shared memory with agent_id in metadata
        client.add(result, metadata={"agent_id": agent_id})
    
    # Run agents in parallel
    await asyncio.gather(
        agent_task("agent-1", task1),
        agent_task("agent-2", task2),
        agent_task("agent-3", task3)
    )
    
    # Aggregate results from all agents
    all_findings = client.search("findings")

    Best Practices

    • Use descriptive user_id values to identify agents
    • Implement proper error handling for agent failures
    • Monitor memory usage across your agent team
    • Use metadata to track agent interactions and handoffs
    • Implement access controls for sensitive agent data

    Integration Examples

    Neural Weave works seamlessly with popular agent frameworks:

    Next Steps