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

      Turning User Research Into Real Organizational Change

      July 1, 2025

      June 2025: All AI updates from the past month

      June 30, 2025

      Building a culture that will drive platform engineering success

      June 30, 2025

      Gartner: More than 40% of agentic AI projects will be canceled in the next few years

      June 30, 2025

      I FINALLY got my hands on my most anticipated gaming laptop of 2025 — and it’s a 14-inch monster

      July 1, 2025

      This gimbal-tracking webcam has TWO cameras and a great price — but it may not be “private” enough

      July 1, 2025

      I spent two months using the massive Area-51 gaming rig — both a powerful beast PC and an RGB beauty queen

      July 1, 2025

      “Using AI is no longer optional” — Did Microsoft just make Copilot mandatory for its staff as a critical performance metric?

      July 1, 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

      June report 2025

      July 1, 2025
      Recent

      June report 2025

      July 1, 2025

      Make your JS functions smarter and cleaner with default parameters

      July 1, 2025

      Best Home Interiors in Hyderabad – Top Designers & Affordable Packages

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

      I FINALLY got my hands on my most anticipated gaming laptop of 2025 — and it’s a 14-inch monster

      July 1, 2025
      Recent

      I FINALLY got my hands on my most anticipated gaming laptop of 2025 — and it’s a 14-inch monster

      July 1, 2025

      This gimbal-tracking webcam has TWO cameras and a great price — but it may not be “private” enough

      July 1, 2025

      I spent two months using the massive Area-51 gaming rig — both a powerful beast PC and an RGB beauty queen

      July 1, 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 1, 2025
    Machine Learning

    Instruction-Following Pruning for Large Language Models

    June 30, 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-2025-6651 – PDF-XChange Editor JP2 File Parsing Remote Code Execution Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Critical Open VSX Registry Flaw Exposes Millions of Developers to Supply Chain Attacks

    Development

    Why WordPress Scalability Starts with Smart Site Structure from Day One

    Development

    Turn Siloed Metrics into Business-Driven Insights with Tx-Insights

    Development

    Highlights

    Apache Tomcat Under Attack: Massive Brute-Force Campaign Targets Manager Interfaces

    June 13, 2025

    Apache Tomcat Under Attack: Massive Brute-Force Campaign Targets Manager Interfaces

    A significant surge in brute-force attacks is targeting Apache Tomcat Manager interfaces, according to a new report from GreyNoise. On June 5, 2025, analysts observed a large-scale campaign where atta …
    Read more

    Published Date:
    Jun 13, 2025 (4 hours, 2 minutes ago)

    Vulnerabilities has been mentioned in this article.

    CVE-2025-6031

    CVE-2025-24813

    CVE-2024-38286

    New TCESB Malware Found in Active Attacks Exploiting ESET Security Scanner

    New TCESB Malware Found in Active Attacks Exploiting ESET Security Scanner

    April 9, 2025

    SuperLight Photonics partners with Precision Technologies to expand into Southeast Asia

    April 29, 2025

    Introducing Gemma 3

    May 27, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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