Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      CodeSOD: A Unique Way to Primary Key

      July 22, 2025

      BrowserStack launches Figma plugin for detecting accessibility issues in design phase

      July 22, 2025

      Parasoft brings agentic AI to service virtualization in latest release

      July 22, 2025

      Node.js vs. Python for Backend: 7 Reasons C-Level Leaders Choose Node.js Talent

      July 21, 2025

      The best CRM software with email marketing in 2025: Expert tested and reviewed

      July 22, 2025

      This multi-port car charger can power 4 gadgets at once – and it’s surprisingly cheap

      July 22, 2025

      I’m a wearables editor and here are the 7 Pixel Watch 4 rumors I’m most curious about

      July 22, 2025

      8 ways I quickly leveled up my Linux skills – and you can too

      July 22, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025
      Recent

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025

      Zero Trust & Cybersecurity Mesh: Your Org’s Survival Guide

      July 22, 2025

      Execute Ping Commands and Get Back Structured Data in PHP

      July 22, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025
      Recent

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025

      “I don’t think I changed his mind” — NVIDIA CEO comments on H20 AI GPU sales resuming in China following a meeting with President Trump

      July 22, 2025

      Galaxy Z Fold 7 review: Six years later — Samsung finally cracks the foldable code

      July 22, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Machine Learning»Meet LangGraph Multi-Agent Swarm: A Python Library for Creating Swarm-Style Multi-Agent Systems Using LangGraph

    Meet LangGraph Multi-Agent Swarm: A Python Library for Creating Swarm-Style Multi-Agent Systems Using LangGraph

    May 16, 2025

    LangGraph Multi-Agent Swarm is a Python library designed to orchestrate multiple AI agents as a cohesive “swarm.” It builds on LangGraph, a framework for constructing robust, stateful agent workflows, to enable a specialized form of multi-agent architecture. In a swarm, agents with different specializations dynamically hand off control to one another as tasks demand, rather than a single monolithic agent attempting everything. The system tracks which agent was last active so that when a user provides the next input, the conversation seamlessly resumes with that same agent. This approach addresses the problem of building cooperative AI workflows where the most qualified agent can handle each sub-task without losing context or continuity.

    LangGraph Swarm aims to make such multi-agent coordination easier and more reliable for developers. It provides abstractions to link individual language model agents (each potentially with their tools and prompts) into one integrated application. The library comes with out-of-the-box support for streaming responses, short-term and long-term memory integration, and even human-in-the-loop intervention, thanks to its foundation on LangGraph. By leveraging LangGraph (a lower-level orchestration framework) and fitting naturally into the broader LangChain ecosystem, LangGraph Swarm allows machine learning engineers and researchers to build complex AI agent systems while maintaining explicit control over the flow of information and decisions.

    LangGraph Swarm Architecture and Key Features

    At its core, LangGraph Swarm represents multiple agents as nodes in a directed state graph, edges define handoff pathways, and a shared state tracks the ‘active_agent’. When an agent invokes a handoff, the library updates that field and transfers the necessary context so the next agent seamlessly continues the conversation. This setup supports collaborative specialization, letting each agent focus on a narrow domain while offering customizable handoff tools for flexible workflows. Built on LangGraph’s streaming and memory modules, Swarm preserves short-term conversational context and long-term knowledge, ensuring coherent, multi-turn interactions even as control shifts between agents.

    Agent Coordination via Handoff Tools

    LangGraph Swarm’s handoff tools let one agent transfer control to another by issuing a ‘Command’ that updates the shared state, switching the ‘active_agent’ and passing along context, such as relevant messages or a custom summary. While the default tool hands off the full conversation and inserts a notification, developers can implement custom tools to filter context, add instructions, or rename the action to influence the LLM’s behavior. Unlike autonomous AI-routing patterns, Swarm’s routing is explicitly defined: each handoff tool specifies which agent may take over, ensuring predictable flows. This mechanism supports collaboration patterns, such as a “Travel Planner” delegating medical questions to a “Medical Advisor” or a coordinator distributing technical and billing queries to specialized experts. It relies on an internal router to direct user messages to the current agent until another handoff occurs.

    State Management and Memory

    Managing state and memory is essential for preserving context as agents hand off tasks. By default, LangGraph Swarm maintains a shared state, containing the conversation history and an ‘active_agent’ marker, and uses a checkpointer (such as an in-memory saver or database store) to persist this state across turns. Also, it supports a memory store for long-term knowledge, allowing the system to log facts or past interactions for future sessions while keeping a window of recent messages for immediate context. Together, these mechanisms ensure the swarm never “forgets” which agent is active or what has been discussed, enabling seamless multi-turn dialogues and accumulating user preferences or critical data over time.

    When more granular control is needed, developers can define custom state schemas so each agent has its private message history. By wrapping agent calls to map the global state into agent-specific fields before invocation and merging updates afterward, teams can tailor the degree of context sharing. This approach supports workflows ranging from fully collaborative agents to isolated reasoning modules, all while leveraging LangGraph Swarm’s robust orchestration, memory, and state-management infrastructure.

    Customization and Extensibility

    LangGraph Swarm offers extensive flexibility for custom workflows. Developers can override the default handoff tool, which passes all messages and switches the active agent, to implement specialized logic, such as summarizing context or attaching additional metadata. Custom tools simply return a LangGraph Command to update state, and agents must be configured to handle those commands via the appropriate node types and state-schema keys. Beyond handoffs, one can redefine how agents share or isolate memory using LangGraph’s typed state schemas: mapping the global swarm state into per-agent fields before invocation and merging results afterward. This enables scenarios where an agent maintains a private conversation history or uses a different communication format without exposing its internal reasoning. For full control, it’s possible to bypass the high-level API and manually assemble a ‘StateGraph’: add each compiled agent as a node, define transition edges, and attach the active-agent router. While most use cases benefit from the simplicity of ‘create_swarm’ and ‘create_react_agent’, the ability to drop down to LangGraph primitives ensures that practitioners can inspect, adjust, or extend every aspect of multi-agent coordination.

    Ecosystem Integration and Dependencies

    LangGraph Swarm integrates tightly with LangChain, leveraging components like LangSmith for evaluation, langchain_openai for model access, and LangGraph for orchestration features such as persistence and caching. Its model-agnostic design lets it coordinate agents across any LLM backend (OpenAI, Hugging Face, or others), and it’s available in both Python (‘pip install langgraph-swarm’) and JavaScript/TypeScript (‘@langchain/langgraph-swarm’), making it suitable for web or serverless environments. Distributed under the MIT license and with active development, it continues to benefit from community contributions and enhancements in the LangChain ecosystem.

    Sample Implementation

    Below is a minimal setup of a two-agent swarm:

    Copy CodeCopiedUse a different Browser
    from langchain_openai import ChatOpenAI
    from langgraph.checkpoint.memory import InMemorySaver
    from langgraph.prebuilt import create_react_agent
    from langgraph_swarm import create_handoff_tool, create_swarm
    
    model = ChatOpenAI(model="gpt-4o")
    
    # Agent "Alice": math expert
    alice = create_react_agent(
        model,
        [lambda a,b: a+b, create_handoff_tool(agent_name="Bob")],
        prompt="You are Alice, an addition specialist.",
        name="Alice",
    )
    
    # Agent "Bob": pirate persona who defers math to Alice
    bob = create_react_agent(
        model,
        [create_handoff_tool(agent_name="Alice", description="Delegate math to Alice")],
        prompt="You are Bob, a playful pirate.",
        name="Bob",
    )
    
    workflow = create_swarm([alice, bob], default_active_agent="Alice")
    app = workflow.compile(checkpointer=InMemorySaver())

    Here, Alice handles additions and can hand off to Bob, while Bob responds playfully but routes math questions back to Alice. The InMemorySaver ensures conversational state persists across turns.

    Use Cases and Applications

    LangGraph Swarm unlocks advanced multi-agent collaboration by enabling a central coordinator to dynamically delegate sub-tasks to specialized agents, whether that’s triaging emergencies by handing off to medical, security, or disaster-response experts, routing travel bookings between flight, hotel, and car-rental agents, orchestrating a pair-programming workflow between a coding agent and a reviewer, or splitting research and report generation tasks among researcher, reporter, and fact-checker agents. Beyond these examples, the framework can power customer-support bots that route queries to departmental specialists, interactive storytelling with distinct character agents, scientific pipelines with stage-specific processors, or any scenario where dividing work among expert “swarm” members boosts reliability and clarity. At the same time, LangGraph Swarm handles the underlying message routing, state management, and smooth transitions.

    In conclusion, LangGraph Swarm marks a leap toward truly modular, cooperative AI systems. Structured multiple specialized agents into a directed graph solves tasks that a single model struggles with, each agent handles its expertise, and then hands off control seamlessly. This design keeps individual agents simple and interpretable while the swarm collectively manages complex workflows involving reasoning, tool use, and decision-making. Built on LangChain and LangGraph, the library taps into a mature ecosystem of LLMs, tools, memory stores, and debugging utilities. Developers retain explicit control over agent interactions and state sharing, ensuring reliability, yet still leverage LLM flexibility to decide when to invoke tools or delegate to another agent.


    Check out the GitHub Page. All credit for this research goes to the researchers of this project. Also, feel free to follow us on Twitter and don’t forget to join our 90k+ ML SubReddit.

    The post Meet LangGraph Multi-Agent Swarm: A Python Library for Creating Swarm-Style Multi-Agent Systems Using LangGraph appeared first on MarkTechPost.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleGraphQL API Testing: Strategies and Tools for Testers
    Next Article DanceGRPO: A Unified Framework for Reinforcement Learning in Visual Generation Across Multiple Paradigms and Tasks

    Related Posts

    Machine Learning

    How to Evaluate Jailbreak Methods: A Case Study with the StrongREJECT Benchmark

    July 22, 2025
    Machine Learning

    Boolformer: Symbolic Regression of Logic Functions with Transformers

    July 22, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2023-49904 – Apache HTTP Server Remote Code Execution

    Common Vulnerabilities and Exposures (CVEs)

    ILuvUI: Instruction-Tuned Language-Vision Modeling of UIs from Machine Conversations

    Machine Learning

    BSD Release: DragonFlyBSD 6.4.1

    News & Updates

    Best practices to handle AWS DMS tasks during PostgreSQL upgrades

    Databases

    Highlights

    CVE-2025-32889 – goTenna Hardcoded Verification Token Vulnerability

    May 1, 2025

    CVE ID : CVE-2025-32889

    Published : May 1, 2025, 6:15 p.m. | 1 hour, 11 minutes ago

    Description : An issue was discovered on goTenna v1 devices with app 5.5.3 and firmware 0.25.5. The verification token used for sending SMS through a goTenna server is hardcoded in the app.

    Severity: 7.3 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-32922 – Tobias WP2LEADS CSRF Stored XSS

    May 15, 2025

    CVE-2025-46550 – YesWiki Reflected Cross-Site Scripting Vulnerability

    April 29, 2025

    A Windows 11 bug makes you say goodbye to Windows Hello, but only temporarily

    April 15, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.