Role-based Cooperation

Summary: Agents are assigned assorted roles and decisions are finalised in accordance with their roles.

Context: Multiple agents can be leveraged within a compound AI system. Agents need to collaborate on the same task while having their own perspectives.

Problem: How can agents cooperate on certain tasks considering their specialties?

Forces:

  • Diversity. The employed agents can have diverse opinions of how a plan is constructed or how a task should be completed.
  • Division of labor. As agents can be trained with different corpus for various purposes, their strengths and expertise should be taken into consideration for task completion.
  • Fault tolerance. Agents may be unavailable during cooperation, which will affect the eventual task result.

Solution: Fig. 1 illustrates a high-level graphical representation of role-based cooperation, where agents coordinate in a hierarchical scheme. In particular, an agent-as-a-planner can generate a multi-step plan by decomposing user’s goal into a chain of tasks. Subsequently, the agent-as-an-assigner can orchestrate task assignment, i.e., some tasks can be completed by the assigner itself, while other tasks can be delegated to specific agent-as-a-worker based on their capabilities and expertise. In addition, if there is no available agent, agent-as-a-creator can be invoked to create a new agent with a specific role, by providing necessary resources, clear objectives and initial guidance to ensure a seamless transition of tasks and responsibilities. Please note that more elaborate roles can be defined and assigned to the agents.

Figure 1. Role-based cooperation.

Benefits:

  • Division of labor. Agents can simulate the division of labor in the real world according to their roles, which enables the observation of social phenomena.
  • Fault tolerance. Since multiple agents are leveraged, the system can continue operation by replacing inactive agents with other agents of the same role.
  • Scalability. Agents of new roles can be employed or created anytime to refine the task workflow and extend the capability of the whole system.
  • Accountability. Accountability is facilitated as the responsibilities of agents are attributed clearly regarding their expected roles.

Drawbacks:

  • Overhead. Cooperation between agents will increase communication overhead, while agent services with different roles may have different prices.

Known uses:

  • XAgent. XAgent consists of three main parts: planner agent for task generation, dispatcher agent for task assignment, and tool agent for task completion.
  • MetaGPT [1]. MetaGPT utilises various agents acting as different roles (e.g., architect, project manager, engineer) in standardized operating procedures.
  • MedAgents [2]. Agents are assigned roles as various domain experts (e.g. cardiology, surgery, gastroenterology) to provide specialised analysis and collaboratively work on healthcare issues.
  • Wang et al. [3] propose Mixture-of-Agents where proposer agents provide useful reference responses to aggregator agents, and the aggregator agents are composed in layers to synthesise and refine the responses.

Related patterns:

  • Cross-reflection. An agent can query multiple agents to provide feedback, which can be determined via role-based cooperation between the reflective agents.
  • Voting-based and debate-based cooperation. Role-based cooperation can be regarded as an alternative of other cooperation patterns by clearly assigning roles to agents, which will then work and collaborate according to the given roles. Whilst, these patterns can be applied together to complement each other.
  • Tool/agent registry. Agents with different roles can be searched and employed via tool/agent registry.

References:

[1] S. Hong, X. Zheng, J. Chen, Y. Cheng, J. Wang, C. Zhang, Z. Wang, S. K. S. Yau, Z. Lin, L. Zhou et al., “Metagpt: Meta programming for multi-agent collaborative framework,” arXiv preprint arXiv:2308.00352, 2023.

[2] X. Tang, A. Zou, Z. Zhang, Y. Zhao, X. Zhang, A. Cohan, and M. Gerstein, “Medagents: Large language models as collaborators for zero-shot medical reasoning,” arXiv preprint arXiv:2311.10537, 2023.

[3] J. Wang, J. Wang, B. Athiwaratkun, C. Zhang, and J. Zou, “Mixture-of-agents enhances large language model
capabilities,” arXiv preprint arXiv:2406.04692, 2024.