Building a 24/7 Multi-Agent System with Open-Source LLMs
Learn how to design a continuously running multi-agent system for software engineering using open-source large language models. This article covers role specialization, structured messaging, context isolation, operational infrastructure, model evaluation, and practical lessons, illustrated by an e-commerce competitor price-monitoring workflow.
1. Why Use a Multi-Agent System?
LLM-powered agents are increasingly being used to handle real software engineering tasks. A single agent works well on a focused task within a limited context. However, when the workflow expands from requirements research and product documentation to architecture, implementation, testing, and delivery, a single-agent approach faces several challenges:
- Context growth: Putting every intermediate artifact into one context window quickly consumes its capacity. As the context grows, the model may also become less reliable at recalling earlier information.
- Mixed responsibilities: Asking the same agent to write both a product requirements document and application code can create conflicting instructions and inconsistent output quality.
- Limited parallelism: A single agent performs work sequentially, reducing throughput and making it harder to sustain continuous work across multiple tasks.
Multi-agent collaboration translates software engineering team responsibilities into a system architecture. Each agent has a specific role, maintains its own context, and coordinates with others through messages. The approach follows familiar microservices principles: high cohesion, loose coupling, and independent scaling.
2. Overall Architecture
A typical multi-agent system can be organized into four layers.
2.1 Role Layer: Define Each Agent’s Responsibilities
For a software development team, the roles might include:
- Coordinator agent: Receives requests through an external entry point, such as a messaging application. It breaks down tasks, assigns work, and consolidates progress updates.
- Research agent: Conducts market research and gathers competitor information, producing structured research reports.
- Product agent: Converts research findings into a product requirements document (PRD), defining feature boundaries and acceptance criteria.
- Architecture agent: Produces a technical design from the PRD, including module boundaries, data models, and interface contracts.
- Development agent: Implements the software. In practice, it can integrate with locally deployed coding CLI tools to make implementation decisions and continue coding.
- Testing agent: Writes and runs tests, checks deliverable quality, and sends defect information back to the development agent when validation fails.
Each role’s prompt should follow the single-responsibility principle. Define its inputs, expected outputs, and completion criteria explicitly. Clear role boundaries make inter-agent messaging protocols more stable.
2.2 Communication Layer: Use a Message Bus
Rather than having agents call one another’s functions directly, use a shared message bus to exchange structured messages. This could be a database message table, a message queue service, or routing built into an agent framework.
A recommended message structure is:
{"from": "architect","to": "developer","task_id": "T-20250101-001","type": "handoff","payload": { "design_doc_ref": "docs/design.md" },"status": "pending"}
Three principles matter:
- Keep messages structured. Include a task ID and status fields to support end-to-end tracing and recovery from interruptions.
- Pass artifact references rather than entire documents. File references prevent large blocks of text from overwhelming the receiving agent’s context.
- Drive workflows with a state machine. Tasks move through
pending → in_progress → review → done / failed. Failed tasks can be retried or escalated to the coordinator for resolution.
2.3 Context Isolation Layer
Each agent should have its own session containing only its system prompt, its own history, and artifacts relevant to the current task. This helps preserve continuity over many interactions without mixing unrelated information.
- Lengthy source material collected by the research agent does not clutter the development agent’s working context.
- Agents exchange distilled summaries and document references, not complete conversation histories.
- When needed, a memory service can store important decisions as searchable knowledge entries that agents retrieve on demand.
2.4 Execution Layer: Support 24/7 Operation
Continuous operation requires infrastructure beyond the agents themselves. Common engineering practices include:
- Scheduled execution: Use a scheduler such as crontab or scheduled jobs on a container platform to trigger recurring workflows—for example, hourly data collection.
- Process supervision: Deploy agent runtimes on a container platform with health checks and automatic restarts.
- Notifications: Use messaging webhooks to send alerts and delivery updates, allowing humans to intervene when a decision is required.
- Artifact storage: Store reports, code, and exported files in object storage or a file service, with version numbers for traceability.
3. Practical Example: E-Commerce Competitor Price Monitoring
An overnight run of this agent team can work toward delivering a useful competitor price-monitoring system. The end-to-end workflow is:
- Requirements: A person sends a short request to the coordinator through a messaging application. The coordinator breaks it down and assigns work to the research and product agents.
- Design: The architecture agent defines a system that periodically collects target products’ current prices, original prices, promotions, and stock status. The design includes database storage, trend charts, and markers for unusual changes.
- Development: The development agent uses local coding tools to implement the collector, analysis service, and notification module, continuing work around the clock.
- Testing and delivery: The testing agent validates the implementation. Once delivered, the system sends webhook alerts when it detects price reductions, sharp fluctuations, or out-of-stock products. It also exports data in a common spreadsheet format for offline analysis.
This example combines scheduled tasks, data collection, anomaly detection, notifications, and file export. With adjustments, the same workflow can support public sentiment monitoring, routine log inspection, or inventory checks.
4. Model Selection: What Multi-Agent Workflows Demand
Multi-agent systems place greater demands on their underlying models than ordinary single-turn questions. Evaluate four dimensions in particular:
- Stability over long tasks: Across dozens of calls, does the model consistently follow role constraints and output formats without drifting from its assigned responsibilities?
- Consistency in very long contexts: Does later implementation still follow architectural decisions established earlier, without introducing contradictions?
- Continuity across interactions: Can the agent correctly resume work after waiting for messages, handling interruptions, or recovering a task?
- Coding and tool-use capability: Can the development agent reliably produce runnable code and invoke tools correctly? These capabilities directly affect delivery quality.
Several open-source models have made substantial progress in coding and agent capabilities. Rather than relying primarily on leaderboard scores, benchmark models against your actual workflow. Run the same multi-agent pipeline with different models and compare task completion rates, workflow interruptions, and the frequency of human intervention.
5. Lessons Learned and Best Practices
- Prefer narrowly scoped roles. Combining research and PRD writing in one agent may seem convenient, but conflicting prompt requirements can make it less reliable. Separating the roles often produces more stable results.
- Define human approval points in advance. Human confirmation at requirements approval and architecture review can substantially reduce rework.
- Implement logging and tracing early. Record every message and model call. These records are essential for diagnosing broken workflow chains.
- Control cost and call rates. Long-running tasks consume considerable inference resources. Use lighter models for less critical agents and configure call-rate limits.
- Make external actions idempotent. Design database writes and notifications so that retries do not create duplicate effects, such as repeated alerts.
6. Conclusion
Multi-agent collaboration is a practical way to organize LLM capabilities into an engineered workflow. Its central principle is simple: design agents with architectural discipline, coordinate them through messaging protocols, and sustain them with operational infrastructure.
With clear responsibilities, stable communication protocols, isolated contexts, and an open-source model that performs reliably on long tasks and coding, individuals and small teams can build continuously running agent systems that deliver useful software outcomes.
