Building a 7x24 Multi-Agent Collaborative System on Open-Source LLMs
This article explores the practical engineering challenges and architectural patterns for building a continuously running multi-agent collaboration system powered by open-source large language models. It covers core technical requirements such as long-horizon stability, ultra-long context retention, and cross-turn task state management, then presents a concrete system design with role-based agents, state storage, context optimization via summarization and retrieval, and robust deployment monitoring for round-the-clock operation.
Building a 7x24 Multi-Agent Collaborative System on Open-Source LLMs
In today’s enterprise AI landscape, a single large language model (LLM) conversation is no longer sufficient for complex business workflows. Tasks such as market research, code generation, automated testing, and final report delivery often require multiple specialized agents working together. This article discusses how to build a 7x24-hour continuously running multi-agent system using a widely adopted open-source multi-agent framework and a recent open-source LLM with strong code-generation capabilities.
Core Technical Challenges for Multi-Agent Systems
A robust multi-agent system is far more than chaining together a few prompts. It places demanding requirements on the underlying LLM, going beyond single-turn understanding to three critical capabilities:
1. Long-Horizon Stability
In a 7x24 workflow, tasks can span hours or even days. The model must maintain consistent instruction-following throughout the entire execution period. If the model “forgets” initial rules or constraints after step 20, the whole task chain collapses. Long-horizon stability demands that the model exhibit strong self-consistency in output formatting, tool-call conventions, and logical reasoning.
2. Reliable Retention of Ultra-Long Context
Multi-agent collaboration involves extensive shared intermediate state, historical conversation lookups, and external knowledge retrieval. As the number of interactions grows, the context window expands rapidly. Many models suffer from “lost in the middle” effects, missing key information located in the center of a long context. Selecting a model that supports very long context windows while maintaining high information extraction accuracy is essential.
3. Maintaining Cross-Turn Task Chains
A multi-agent system is essentially a state machine. Agent A’s output becomes Agent B’s input, and Agent C may need to make decisions based on Agent B’s results and update the global state. Maintaining the task chain across turns requires the model to accurately understand the current node, completed work, and next action, preventing logical breaks or duplicated execution during state handoffs.
System Architecture and Engineering Practice
To address these challenges, we designed a multi-agent architecture based on open-source LLMs and deployed it on a cloud infrastructure for stable 7x24 operation.
1. Core Component Selection
- Large Language Model: We chose a recently released open-source model with notable improvements in code generation and logical reasoning. Such models are typically optimized for instruction following and function calling, making them well-suited for agent orchestration.
- Multi-Agent Framework: We used a mainstream open-source multi-agent framework that supports role definition, task assignment, message passing, and tool integration.
- Infrastructure Base: The system runs on a container platform (e.g., Baidu AI Cloud Container Engine) for service deployment, uses object storage for intermediate and final artifacts, and integrates logging services for end-to-end traceability.
2. Agent Roles and Workflow Design
Using a typical “automated software development and delivery” task as an example, we define the following roles:
- Manager Agent: Receives the user’s raw requirements, decomposes tasks, distributes them to specialized execution agents, and consolidates final results.
- Researcher Agent: Conducts market research, technology selection, and external information retrieval.
- Coder Agent: Writes concrete code based on the researcher’s findings.
- Reviewer Agent: Performs static checks and logical review of the code; if it fails, the task is sent back to the coder.
3. Task Chain State Management
To ensure that cross-turn task chains do not break, the system introduces a global state store. A key-value state database records the lifecycle status of each task.
# Pseudo-code: Task state transition based on an open-source frameworkclass AgentWorkflow:def __init__(self, model_client, state_store):self.model = model_clientself.state = state_storeself.agents = self._init_agents()def _init_agents(self):# Initialize role-specific agents, injecting an open-source model with strong code abilityreturn {"manager": ManagerAgent(self.model),"researcher": ResearcherAgent(self.model),"coder": CoderAgent(self.model),"reviewer": ReviewerAgent(self.model)}async def run(self, task_id, user_prompt):# Initialize task stateself.state.set(task_id, "status", "STARTED")self.state.set(task_id, "context", user_prompt)# Manager decomposes the tasksub_tasks = await self.agents["manager"].decompose(user_prompt)for sub in sub_tasks:# Route subtasks to different agents based on typeif sub.type == "research":result = await self.agents["researcher"].execute(sub, self.state.get(task_id, "context"))elif sub.type == "coding":result = await self.agents["coder"].execute(sub, self.state.get(task_id, "context"))# Review stepreview_res = await self.agents["reviewer"].execute(result)if not review_res.passed:# Rollback the chain and re-codecontinue# Update global context to avoid memory lossself.state.append(task_id, "context", result)self.state.set(task_id, "status", "COMPLETED")return self.state.get(task_id, "context")
Context Management and Engineering Optimization
Without intervention, the context quickly exceeds model limits or degrades performance after dozens of turns. We employ a dual mechanism of “rolling summarization + vector retrieval” to manage context:
- Rolling Summarization: After each phase, the Manager Agent generates a concise summary of the preceding conversation, preserving key decisions and state information while removing redundant trial-and-error steps.
- RAG Mechanism: Detailed code files and research reports are stored in object storage, vectorized, and indexed in a vector database. Agents only place relevant code snippets or report summaries into the current context, significantly reducing token consumption and improving accuracy.
Deployment and Monitoring for 7x24 Operation
To ensure continuous operation of the agent fleet, fault tolerance and monitoring are essential:
- Retry with Exponential Backoff: Model API calls can fail due to network issues or timeouts. The system includes an exponential backoff retry mechanism.
- Dead-loop Detection: If the Coder and Reviewer bounce back on the same issue more than three times, the system triggers an alert, and the Manager interferes by attempting a different strategy or requesting human intervention.
- Logging and Monitoring: All agent inputs, outputs, and tool calls are sent to a centralized logging service. A visual dashboard lets operators monitor task throughput, average execution time, and token consumption trends in real time.
Conclusion
Building a 7x24 multi-agent collaborative system is a dual challenge for both LLM capabilities and engineering architecture. By selecting an open-source model with strong code ability and long-context handling, combined with a well-designed multi-agent framework and strict state management, we can achieve fully automated workflows from market research to code delivery. As open-source models continue to improve, multi-agent collaboration will deliver substantial production value across more vertical business scenarios.
