返回 Skill 列表
extension
分类: 内容与媒体无需 API Key

multi-agent-collaboration

一种结构模式,其中多个专门的代理相互通信和协调,以解决对单个代理来说过于复杂的问题。当用户要求“构建多代理系统”、“代理协同工作”、“代理协作”,或提到代理团队、分布式代理或群集时使用。

person作者: jakexiaohubgithub

Multi-Agent Collaboration

Multi-Agent Collaboration (MAC) involves a team of agents, each with a specific role, tools, and persona. They work together by exchanging messages, handing off tasks, or debating solutions. This mimics human organizational structures (e.g., a software team with a PM, Dev, and QA).

When to Use

  • Separation of Concerns: To keep prompts simple and focused. Complex prompts often confuse models; specialized agents are more reliable.
  • Role-Playing: When specific expertise or persona is needed (e.g., "Act as a grumpy editor").
  • Scalability: Adding new capabilities is as simple as adding a new agent to the team.
  • Simulating User Behavior: Modeling market dynamics, social networks, or game theory scenarios.

Use Cases

  • Software Dev Team: Product Manager -> Developer -> Reviewer -> QA.
  • Debate: Proposition Agent vs. Opposition Agent -> Moderator synthesizes.
  • Creative Writing Room: Idea Generator -> Plot Outliner -> Dialogue Specialist -> Editor.

Implementation Pattern

class Agent:
    def process(self, message):
        # ... logic ...
        return response

def collaboration_workflow(task):
    # Define Roles
    researcher = Agent(role="Researcher", tools=[search_tool])
    writer = Agent(role="Writer", tools=[editor_tool])
    reviewer = Agent(role="Reviewer", prompt="Critique for accuracy")

    # Flow
    # 1. Research
    facts = researcher.process(f"Gather facts on: {task}")
    
    # 2. Write Draft
    draft = writer.process(f"Write an article using these facts: {facts}")
    
    # 3. Review & Iterate
    feedback = reviewer.process(draft)
    if feedback.has_issues:
        final_draft = writer.process(f"Fix these issues: {feedback}")
    else:
        final_draft = draft
        
    return final_draft