Model Division of Labor and Long-Horizon Task Practices in Multi-Agent Collaboration
This article explores the transition from single-session LLM interactions to multi-agent collaboration for complex tasks. It covers the division of responsibilities between orchestrator and worker agents, strategies for tiering models based on task requirements and costs, and techniques for managing context growth and compression in long-horizon tasks.
1. From Single Q&A to Multi-Agent Collaboration
Early typical usage of Large Language Models (LLMs) involves single-turn or multi-turn Q&A: users ask a question, and the model provides an answer. As task complexity increases, a single session struggles to simultaneously handle requirement understanding, solution design, code writing, test verification, and result aggregation. Multi-agent collaboration splits these phases into different roles. An orchestrator agent decomposes the goal, several worker agents execute subtasks in parallel, and finally, the orchestrator integrates the results.
The value of this pattern is primarily reflected in three aspects. First, parallel processing reduces total turnaround time. Second, the contexts of subtasks are isolated from each other, so a single agent does not need to carry the entire historical information. Third, with clear roles, each phase can be individually evaluated and replaced.
However, collaboration does not automatically yield benefits. Improper task decomposition, missing dependencies between subtasks, and unresolved result conflicts can make a multi-agent system slower, more expensive, and harder to reproduce than a monolithic approach. Therefore, role boundaries must be clearly defined during the design phase.
2. Division of Responsibilities Between Orchestrator and Worker Agents
It is recommended to divide responsibilities according to the following principles:
- Orchestrator: Responsible for goal understanding, task decomposition, dependency sorting, task assignment, result acceptance, and final aggregation. It does not directly perform a large amount of detailed work to prevent its own context from rapidly expanding.
- Worker Agents: Only receive specific inputs, constraints, and output formats, complete a single subtask, and return structured results.
- External Tools: Operations such as reading/writing files, running tests, and querying data should be performed by deterministic programs, rather than relying on the model’s “memory.”
The following pseudo-code demonstrates how the orchestrator assigns tasks and aggregates results. Functions like call_model and build_prompt are placeholders and need to be replaced with actual calling logic in your environment.
from concurrent.futures import ThreadPoolExecutorfrom dataclasses import dataclass@dataclassclass SubTask:task_id: strgoal: strconstraints: list[str]depends_on: list[str]def run_worker(task: SubTask, context: dict) -> dict:prompt = build_prompt(task, context) # Only inject information needed for this subtaskraw = call_model(role="worker", prompt=prompt)return parse_structured_output(raw) # Require a fixed structure for easy validationdef orchestrate(plan: list[SubTask]) -> dict:results: dict[str, dict] = {}pending = {t.task_id: t for t in plan}with ThreadPoolExecutor(max_workers=8) as pool:while pending:ready = [t for t in pending.values()if all(d in results for d in t.depends_on)]if not ready:raise RuntimeError("Circular dependency or missing dependency task exists")futures = {pool.submit(run_worker, t, results): t for t in ready}for fut, task in futures.items():results[task.task_id] = fut.result()del pending[task.task_id]return merge_results(results) # Orchestrator completes integration and conflict checking
This code has three design points. First, dependencies are explicitly declared, and the scheduler only dispatches tasks whose prerequisites are met. Second, worker agents only receive the context they need, not the entire history. Third, the return values are forcibly structured for programmatic validation, preventing unchecked free text from being directly concatenated into the next step.
The concurrency level should be set based on the server’s rate limits and cost budget. The max_workers=8 in the example is just a placeholder value.
3. Model Tiering: Matching Capabilities and Costs by Phase
In a multi-agent system, the requirements for model capabilities vary significantly across different phases. Planning, architectural decisions, complex reasoning, and cross-file consistency checks require deep reasoning capabilities. Tasks with high determinism, such as format conversion, simple code generation, and log extraction, prioritize speed and cost.
A common practice is tiered configuration:
| Role | Typical Tasks | Selection Focus |
|---|---|---|
| Orchestrator | Decomposition, planning, arbitration, acceptance | Reasoning ability, instruction following |
| Core Worker Agent | Key module implementation, troubleshooting | Code quality, long-context stability |
| Standard Worker Agent | Boilerplate code, documentation, batch processing | Unit cost, response speed |
The benefit of tiering is concentrating expensive capabilities on a few key nodes. However, tiering should not only look at the unit price. The total cost of a single call depends on the number of input and output tokens, the number of retries, and the rework caused by misjudgments. A cheaper model that frequently requires rework may not result in a lower overall cost.
Different service tiers from the same provider (e.g., standard vs. high-speed versions) may also differ in speed, pricing, and quota calculation. This information should be subject to the provider’s current official announcements. Before formal adoption, the team should conduct small-scale testing on their actual tasks.
4. Context Growth and Compression Strategies
In long-horizon tasks, the growth rate of the context window often exceeds expectations. Tool call results, file contents, conversation history, and intermediate reasoning all consume space. The longer the context, the easier it is for the model’s attention to key information to scatter, and retrieval accuracy may also decline. At the same time, the cost and latency of each call increase.
Common coping strategies include the following:
- On-demand injection: Worker agents only read file fragments relevant to the current subtask, rather than the entire code repository.
- Periodic summarization: When the context exceeds a threshold, compress completed steps into a structured summary, retaining decision conclusions, unresolved issues, and key constraints, while discarding process details.
- State externalization: Write task progress, change logs, and to-do items to external storage. The model only needs to read the current state without relying on the full conversation history.
- Segmented handoff: After a subtask is completed, only pass the result summary to the downstream agent, not the full execution trace.
Below is a simplified pseudo-code for the compression logic:
def maybe_compress(messages: list[dict], token_limit: int) -> list[dict]:if count_tokens(messages) < token_limit:return messageskeep_recent = messages[-6:] # Keep the last few rounds of original textolder = messages[:-6]summary = call_model(role="summarizer",prompt=("Please compress the following history into a structured summary, ""including: completed items, key decisions, unresolved issues, hard constraints.\n"+ render(older)),)return [{"role": "system", "content": summary}] + keep_recent
