In recent years, with the rapid development of large-scale language modeling (LLM), the capability of Multi-Agent Systems (MAS) has been significantly improved. These systems are not only able to automate tasks, but also demonstrate near-human reasoning capabilities. However, the traditional MAS Architectures often come with complex code implementations, which greatly limits their reusability. To solve this problem, Nexus was developed.Nexus is a lightweight Python framework designed for building scalable, reusable LLM-based MAS. It supports a hierarchical architecture, supervised workflow design, and is easy to use, even without a deep technical background.
Overview of Multi-Agent Systems (MAS)
Multi-Agent Systems (MAS) are the foundational systems for distributed Artificial Intelligence (AI). They are able to break down complex tasks into more manageable components that are then executed by autonomous intelligences (Agents). These intelligences utilize historical knowledge, interactions with other intelligences, and environmental information to make decisions without human intervention. This autonomy distinguishes MAS from traditional distributed problem solving systems and enhances their ability to operate effectively in dynamic and uncertain environments.
In MAS, intelligences have a degree of autonomy and collaborate with each other to form a unified whole to solve problems.The key components of the MAS architecture include intelligences, environments, and interactions. Intelligentsia are the core actors, with roles, capabilities, and knowledge models. The environment is the external world in which the intelligences live, and they perceive and act on the information in the environment. Communication between intelligences is called interaction and can be in the form of coordination, negotiation, or any form based on system requirements.
MAS architectures can take various forms including traditional, ReAct and LLM based. Traditional MAS architectures consist of intelligences that interact with the environment through observation and action, while ReAct (Reasoning and Acting) type intelligences architectures introduce advanced reasoning capabilities. Whereas LLM based architectures utilize LLMs as intelligences for reasoning and decision making.
MAS Architecture
The main challenges faced by MAS architectures include coordination among multiple intelligences, task assignment, and scalability of large systems. To address these challenges, researchers have proposed various approaches, such as the Leader-Follower hierarchy, in which the leader intelligences define global goals and delegate tasks, while the middle-tier intelligences framework simplifies service discovery and coordination among the intelligences.
Recent advances in the field of Large Language Modeling (LLM) are improving the MAS architecture and its application capabilities, such as near-human reasoning. When integrated into the MAS architecture, LLMs can act as central reasoning intelligences, enhancing adaptability, collaboration, and decision-making in dynamic environments. These advances have also facilitated the application of MAS in areas such as multimodal reasoning, complex mathematical problem solving, and autonomous navigation, which were once beyond the reach of MAS approaches.
LLM-based MAS relies on two important principles: a task-specific architecture to maximize the efficiency of LLM, and a methodology to implement domain-specific knowledge and its application in intelligences. However, integrating external knowledge for LLM-based MAS may increase the overall complexity and lead to scalability issues due to knowledge constraints and limited adaptability to different domains. In addition, developing and deploying LLM-based MAS from scratch is very difficult, especially for non-technical people.
Nexus, a novel open-source Python framework, allows users to easily design MAS architectures using low-code design standards.Nexus is lightweight, extensible, and LLM- and application domain-agnostic, enabling intelligent automation across a variety of tasks and problems.
Deeper Understanding of the Nexus Framework
The Nexus framework is based on a modular design that integrates a single Root Supervisor Agent with multiple Task Supervisors and Worker Agents. These components are designed according to a hierarchical execution graph for efficient task delegation, scalability and flexibility. The Root Supervisor is responsible for coordinating the communication between users and intelligences, and its main responsibilities include task decomposition, intelligence selection, and result aggregation.
Task decomposition involves breaking down high-level cues into actionable subtasks. Intelligent body selection refers to delegating tasks to the most appropriate working intelligences based on their degree of specialization. On the other hand, result aggregation refers to collecting outputs from delegated subtasks and combining them into a final response. Work intelligences are specialized problem solvers to which supervisors assign tasks. Each Work Intelligence Body operates in an isolated environment that consists of a unique specialization defined by its system messages, associated tools and functions, and environmental data. The capabilities of the work intelligences include using specialized tools (e.g., web search) or knowledge bases to perform domain-specific tasks, iteratively refining transition results by interacting with the tools or knowledge bases, and returning outputs to the supervisor upon completion of the assigned task.
Nexus contains a global memory and a set of external tools. The memory stores partial results with instructions and ensures that all intelligences are aware of the task progress.The memory in the Nexus is a shared repository to which the supervisor has global access, the working intelligences are limited to their event history, and the task supervisor has access to all memory locations associated with its assigned intelligences. On the other hand, external tools allow intelligences to perform specific tasks in a specialized way, such as web searches or access to external resources (cloud storage buckets, etc.).
Nexus Architecture
Nexus introduces an iterative process for task decomposition and execution, divided into three main interaction loops:
- user-supervisor interaction: In this loop, the user provides a high-level prompt to the supervisor. The supervisor explains and outlines the task execution plan and continues to align the plan with the user's goals. This exchange is iterative and continues until the supervisor is ready to delegate subtasks to other intelligences or finalize a solution.
- Supervisor - Intelligent Body Coordination: In this loop, supervisors assign subtasks to work intelligences based on their level of specialization. The work intelligences then use the available tools and generate intermediate results.
- Intelligent Body Internal Operation: The last loop works in the internal environment of each working intelligence. The working intelligences improve the intermediate results based on the iterative use of external tools and resources. Once a solution is obtained, it is forwarded back to the supervisor for final synthesis.
These loops enable Nexus to support a variety of interaction patterns between intelligences and their operating environments. It is scalable, modular, and robust, where the framework can incorporate new intelligences as task complexity increases, working intelligences can operate independently, and hierarchical delegation with iterative feedback loops reduces the impact of intelligences failures because tasks can be easily reassigned or improved.
Nexus Performance Evaluation and Analysis
The performance of Nexus is evaluated based on the pass rate, which is the ratio of the number of samples that pass all checks to the total number of samples in the benchmark test. In coding tasks, the effectiveness of the Nexus framework is evaluated based on its efficiency in solving programming-related tasks. The evaluation uses the HumanEval and VerilogEval-Human benchmarks.
The HumanEval benchmark is based on a collection of 164 problems focused on Python code generation, while VerilogEval-Human contains 156 challenges involving Verilog code generation and verification. The figure below illustrates the Nexus-based MAS architecture for solving code-related tasks.
Nexus-based MAS architecture for code-related tasks
The table below shows the effectiveness of the proposed workflow based on the pass rates of the ablation studies.
Results - 1
The following table compares the performance of the proposed Nexus-based workflow with related existing solutions.
Results - 2
The effectiveness of Nexus in solving math problems was demonstrated with the MATH dataset. The following workflow was used, in which the supervisor, mathematician intelligences and reviewer intelligences were used. They are all supported by the Claude 3.5v2 LLM provides support.
Nexus-based MAS Architecture for Mathematical Problems
Results of ablation studies on the MATH dataset
Nexus Hands-on: Code Review and Refactoring
Next, we demonstrate how to build a MAS architecture with Nexus for code review and refactoring through a real-world example.
Step 1: Install the necessary libraries
!git clone https://github.com/PrimisAI/nexus.git
nexus
!pip install -e .
Step 2: Import library and set up LLM configuration
from primisai.nexus.core import Agent, Supervisor
from google.colab import userdata
import os
os.environ["OPENAI_API_KEY"] = userdata.get("OPENAI_API_KEY")
llm_config = {
"api_key": os.getenv("OPENAI_API_KEY"),
"model": "gpt-4o",
"base_url": "https://api.openai.com/v1"
}
Step 3: Create three intelligences: Supervisor, CodeReviewer and CodeRefactor.
# Creating a Supervisor Intelligence
coordinator = Supervisor("ProgrammingCoordinator", llm_config)
# Create the code reviewer intelligence and set its system messages
code_reviewer = Agent(
"CodeReviewer",
llm_config.
system_message="You are a coding expert who specializes in code analysis. Your task is to review code, identify errors and suggest improvements."
)
# Create the code refactor intelligence and set its system message
code_refactor = Agent(
"CodeRefactor",
llm_config.
system_message="You are a coding expert focused on code refactoring. Your goal is to improve the readability and efficiency of your code."
)
Step 4: Registering Intelligentsia with the Coordinator
coordinator.register_agent(code_reviewer)
coordinator.register_agent(code_refactor)
Step 5: Display the Hierarchy of Intelligentsia
coordinator.display_agent_graph()
Step 6: Start an interactive session and provide sample Python code for review and refactoring.
coordinator.start_interactive_session()
exports
As you can see from the output, Nexus was able to review and refactor our supplied Python code based on the MAS architecture and came up with a more robust, efficient, and easy-to-use version that included proper documentation.
Summary and outlook
Nexus, a lightweight Python framework, greatly simplifies the development and management of LLM-based multi-intelligence systems. It enables seamless integration, extensibility, and flexibility through modular design through a layered approach and YAML-based architecture and workflow definitions.Nexus represents a significant advancement in MAS development and promises to further enhance LLM-based problem solving capabilities.
In the future, as LLM technology continues to evolve, Nexus is expected to play an even greater role in the following areas:
- More complex task processing: With enhanced LLM reasoning capabilities, Nexus can handle more complex and challenging tasks, such as cross-domain knowledge integration, long-term planning, and so on.
- Wider range of application scenarios: The flexibility and scalability of Nexus enables it to be used in a wider range of applications, such as smart manufacturing, smart cities, fintech and more.
- Stronger community supportAs Nexus is open sourced and promoted, more developers will be involved in the development and refinement of Nexus, and together they will push the boundaries of MAS technology.
All in all, Nexus provides a powerful and flexible platform for building and managing multi-intelligence systems, and its emergence will accelerate the development of the AI field and provide new ideas and methods for solving complex problems in the real world.
Reference:https://arxiv.org/pdf/2502.19091