mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +00:00
* docs(cli): document device-code login and config reset guidance; renumber sections * docs(cli): fix duplicate numbering (renumber Login/API Keys/Configuration sections) * docs: Fix webhook documentation to include meta dict in all webhook payloads - Add note explaining that meta objects from kickoff requests are included in all webhook payloads - Update webhook examples to show proper payload structure including meta field - Fix webhook examples to match actual API implementation - Apply changes to English, Korean, and Portuguese documentation Resolves the documentation gap where meta dict passing to webhooks was not documented despite being implemented in the API. * WIP: CrewAI docs theme, changelog, GEO, localization * docs(cli): fix merge markers; ensure mode: "wide"; convert ASCII tables to Markdown (en/pt-BR/ko) * docs: add group icons across locales; split Automation/Integrations; update tools overviews and links
363 lines
11 KiB
Plaintext
363 lines
11 KiB
Plaintext
---
|
|
title: 협업
|
|
description: CrewAI 팀 내에서 에이전트가 함께 작업하고, 작업을 위임하며, 효과적으로 소통하는 방법에 대해 설명합니다.
|
|
icon: screen-users
|
|
mode: "wide"
|
|
---
|
|
|
|
## 개요
|
|
|
|
CrewAI에서의 협업은 에이전트들이 팀으로서 함께 작업하며, 각자의 전문성을 활용하기 위해 작업을 위임하고 질문을 주고받을 수 있도록 합니다. `allow_delegation=True`로 설정하면, 에이전트들은 자동으로 강력한 협업 도구에 접근할 수 있습니다.
|
|
|
|
## 빠른 시작: 협업 활성화
|
|
|
|
```python
|
|
from crewai import Agent, Crew, Task
|
|
|
|
# Enable collaboration for agents
|
|
researcher = Agent(
|
|
role="Research Specialist",
|
|
goal="Conduct thorough research on any topic",
|
|
backstory="Expert researcher with access to various sources",
|
|
allow_delegation=True, # 🔑 Key setting for collaboration
|
|
verbose=True
|
|
)
|
|
|
|
writer = Agent(
|
|
role="Content Writer",
|
|
goal="Create engaging content based on research",
|
|
backstory="Skilled writer who transforms research into compelling content",
|
|
allow_delegation=True, # 🔑 Enables asking questions to other agents
|
|
verbose=True
|
|
)
|
|
|
|
# Agents can now collaborate automatically
|
|
crew = Crew(
|
|
agents=[researcher, writer],
|
|
tasks=[...],
|
|
verbose=True
|
|
)
|
|
```
|
|
|
|
## 에이전트 협업 방식
|
|
|
|
`allow_delegation=True`로 설정하면, CrewAI는 에이전트에게 두 가지 강력한 도구를 자동으로 제공합니다.
|
|
|
|
### 1. **업무 위임 도구**
|
|
에이전트가 특정 전문성을 가진 팀원에게 작업을 할당할 수 있습니다.
|
|
|
|
```python
|
|
# Agent automatically gets this tool:
|
|
# Delegate work to coworker(task: str, context: str, coworker: str)
|
|
```
|
|
|
|
### 2. **질문하기 도구**
|
|
에이전트가 동료로부터 정보를 수집하기 위해 특정 질문을 할 수 있게 해줍니다.
|
|
|
|
```python
|
|
# Agent automatically gets this tool:
|
|
# Ask question to coworker(question: str, context: str, coworker: str)
|
|
```
|
|
|
|
## 협업의 실제
|
|
|
|
아래는 에이전트들이 콘텐츠 제작 작업에 협력하는 완성된 예시입니다:
|
|
|
|
```python
|
|
from crewai import Agent, Crew, Task, Process
|
|
|
|
# Create collaborative agents
|
|
researcher = Agent(
|
|
role="Research Specialist",
|
|
goal="Find accurate, up-to-date information on any topic",
|
|
backstory="""You're a meticulous researcher with expertise in finding
|
|
reliable sources and fact-checking information across various domains.""",
|
|
allow_delegation=True,
|
|
verbose=True
|
|
)
|
|
|
|
writer = Agent(
|
|
role="Content Writer",
|
|
goal="Create engaging, well-structured content",
|
|
backstory="""You're a skilled content writer who excels at transforming
|
|
research into compelling, readable content for different audiences.""",
|
|
allow_delegation=True,
|
|
verbose=True
|
|
)
|
|
|
|
editor = Agent(
|
|
role="Content Editor",
|
|
goal="Ensure content quality and consistency",
|
|
backstory="""You're an experienced editor with an eye for detail,
|
|
ensuring content meets high standards for clarity and accuracy.""",
|
|
allow_delegation=True,
|
|
verbose=True
|
|
)
|
|
|
|
# Create a task that encourages collaboration
|
|
article_task = Task(
|
|
description="""Write a comprehensive 1000-word article about 'The Future of AI in Healthcare'.
|
|
|
|
The article should include:
|
|
- Current AI applications in healthcare
|
|
- Emerging trends and technologies
|
|
- Potential challenges and ethical considerations
|
|
- Expert predictions for the next 5 years
|
|
|
|
Collaborate with your teammates to ensure accuracy and quality.""",
|
|
expected_output="A well-researched, engaging 1000-word article with proper structure and citations",
|
|
agent=writer # Writer leads, but can delegate research to researcher
|
|
)
|
|
|
|
# Create collaborative crew
|
|
crew = Crew(
|
|
agents=[researcher, writer, editor],
|
|
tasks=[article_task],
|
|
process=Process.sequential,
|
|
verbose=True
|
|
)
|
|
|
|
result = crew.kickoff()
|
|
```
|
|
|
|
## 협업 패턴
|
|
|
|
### 패턴 1: 조사 → 작성 → 편집
|
|
```python
|
|
research_task = Task(
|
|
description="Research the latest developments in quantum computing",
|
|
expected_output="Comprehensive research summary with key findings and sources",
|
|
agent=researcher
|
|
)
|
|
|
|
writing_task = Task(
|
|
description="Write an article based on the research findings",
|
|
expected_output="Engaging 800-word article about quantum computing",
|
|
agent=writer,
|
|
context=[research_task] # Gets research output as context
|
|
)
|
|
|
|
editing_task = Task(
|
|
description="Edit and polish the article for publication",
|
|
expected_output="Publication-ready article with improved clarity and flow",
|
|
agent=editor,
|
|
context=[writing_task] # Gets article draft as context
|
|
)
|
|
```
|
|
|
|
### 패턴 2: 협업 단일 작업
|
|
```python
|
|
collaborative_task = Task(
|
|
description="""Create a marketing strategy for a new AI product.
|
|
|
|
Writer: Focus on messaging and content strategy
|
|
Researcher: Provide market analysis and competitor insights
|
|
|
|
Work together to create a comprehensive strategy.""",
|
|
expected_output="Complete marketing strategy with research backing",
|
|
agent=writer # Lead agent, but can delegate to researcher
|
|
)
|
|
```
|
|
|
|
## 계층적 협업
|
|
|
|
복잡한 프로젝트의 경우, 매니저 에이전트를 활용하여 계층적 프로세스를 사용하세요:
|
|
|
|
```python
|
|
from crewai import Agent, Crew, Task, Process
|
|
|
|
# Manager agent coordinates the team
|
|
manager = Agent(
|
|
role="Project Manager",
|
|
goal="Coordinate team efforts and ensure project success",
|
|
backstory="Experienced project manager skilled at delegation and quality control",
|
|
allow_delegation=True,
|
|
verbose=True
|
|
)
|
|
|
|
# Specialist agents
|
|
researcher = Agent(
|
|
role="Researcher",
|
|
goal="Provide accurate research and analysis",
|
|
backstory="Expert researcher with deep analytical skills",
|
|
allow_delegation=False, # Specialists focus on their expertise
|
|
verbose=True
|
|
)
|
|
|
|
writer = Agent(
|
|
role="Writer",
|
|
goal="Create compelling content",
|
|
backstory="Skilled writer who creates engaging content",
|
|
allow_delegation=False,
|
|
verbose=True
|
|
)
|
|
|
|
# Manager-led task
|
|
project_task = Task(
|
|
description="Create a comprehensive market analysis report with recommendations",
|
|
expected_output="Executive summary, detailed analysis, and strategic recommendations",
|
|
agent=manager # Manager will delegate to specialists
|
|
)
|
|
|
|
# Hierarchical crew
|
|
crew = Crew(
|
|
agents=[manager, researcher, writer],
|
|
tasks=[project_task],
|
|
process=Process.hierarchical, # Manager coordinates everything
|
|
manager_llm="gpt-4o", # Specify LLM for manager
|
|
verbose=True
|
|
)
|
|
```
|
|
|
|
## 협업을 위한 모범 사례
|
|
|
|
### 1. **명확한 역할 정의**
|
|
```python
|
|
# ✅ Good: Specific, complementary roles
|
|
researcher = Agent(role="Market Research Analyst", ...)
|
|
writer = Agent(role="Technical Content Writer", ...)
|
|
|
|
# ❌ Avoid: Overlapping or vague roles
|
|
agent1 = Agent(role="General Assistant", ...)
|
|
agent2 = Agent(role="Helper", ...)
|
|
```
|
|
|
|
### 2. **전략적 위임 활성화**
|
|
```python
|
|
# ✅ Enable delegation for coordinators and generalists
|
|
lead_agent = Agent(
|
|
role="Content Lead",
|
|
allow_delegation=True, # Can delegate to specialists
|
|
...
|
|
)
|
|
|
|
# ✅ Disable for focused specialists (optional)
|
|
specialist_agent = Agent(
|
|
role="Data Analyst",
|
|
allow_delegation=False, # Focuses on core expertise
|
|
...
|
|
)
|
|
```
|
|
|
|
### 3. **컨텍스트 공유**
|
|
```python
|
|
# ✅ Use context parameter for task dependencies
|
|
writing_task = Task(
|
|
description="Write article based on research",
|
|
agent=writer,
|
|
context=[research_task], # Shares research results
|
|
...
|
|
)
|
|
```
|
|
|
|
### 4. **명확한 작업 설명**
|
|
```python
|
|
# ✅ 구체적이고 실행 가능한 설명
|
|
Task(
|
|
description="""Research competitors in the AI chatbot space.
|
|
Focus on: pricing models, key features, target markets.
|
|
Provide data in a structured format.""",
|
|
...
|
|
)
|
|
|
|
# ❌ 협업에 도움이 되지 않는 모호한 설명
|
|
Task(description="Do some research about chatbots", ...)
|
|
```
|
|
|
|
## 협업 문제 해결
|
|
|
|
### 문제: 에이전트들이 협업하지 않음
|
|
**증상:** 에이전트들이 각자 작업하며, 위임이 이루어지지 않음
|
|
```python
|
|
# ✅ Solution: Ensure delegation is enabled
|
|
agent = Agent(
|
|
role="...",
|
|
allow_delegation=True, # This is required!
|
|
...
|
|
)
|
|
```
|
|
|
|
### 문제: 지나친 이중 확인
|
|
**증상:** 에이전트가 과도하게 질문을 하여 진행이 느려짐
|
|
```python
|
|
# ✅ Solution: Provide better context and specific roles
|
|
Task(
|
|
description="""Write a technical blog post about machine learning.
|
|
|
|
Context: Target audience is software developers with basic ML knowledge.
|
|
Length: 1200 words
|
|
Include: code examples, practical applications, best practices
|
|
|
|
If you need specific technical details, delegate research to the researcher.""",
|
|
...
|
|
)
|
|
```
|
|
|
|
### 문제: 위임 루프
|
|
**증상:** 에이전트들이 무한히 서로에게 위임함
|
|
```python
|
|
# ✅ Solution: Clear hierarchy and responsibilities
|
|
manager = Agent(role="Manager", allow_delegation=True)
|
|
specialist1 = Agent(role="Specialist A", allow_delegation=False) # No re-delegation
|
|
specialist2 = Agent(role="Specialist B", allow_delegation=False)
|
|
```
|
|
|
|
## 고급 협업 기능
|
|
|
|
### 맞춤 협업 규칙
|
|
```python
|
|
# Set specific collaboration guidelines in agent backstory
|
|
agent = Agent(
|
|
role="Senior Developer",
|
|
backstory="""You lead development projects and coordinate with team members.
|
|
|
|
Collaboration guidelines:
|
|
- Delegate research tasks to the Research Analyst
|
|
- Ask the Designer for UI/UX guidance
|
|
- Consult the QA Engineer for testing strategies
|
|
- Only escalate blocking issues to the Project Manager""",
|
|
allow_delegation=True
|
|
)
|
|
```
|
|
|
|
### 협업 모니터링
|
|
```python
|
|
def track_collaboration(output):
|
|
"""Track collaboration patterns"""
|
|
if "Delegate work to coworker" in output.raw:
|
|
print("🤝 Delegation occurred")
|
|
if "Ask question to coworker" in output.raw:
|
|
print("❓ Question asked")
|
|
|
|
crew = Crew(
|
|
agents=[...],
|
|
tasks=[...],
|
|
step_callback=track_collaboration, # Monitor collaboration
|
|
verbose=True
|
|
)
|
|
```
|
|
|
|
## 메모리와 학습
|
|
|
|
에이전트가 과거 협업을 기억할 수 있도록 합니다:
|
|
|
|
```python
|
|
agent = Agent(
|
|
role="Content Lead",
|
|
memory=True, # Remembers past interactions
|
|
allow_delegation=True,
|
|
verbose=True
|
|
)
|
|
```
|
|
|
|
메모리가 활성화되면, 에이전트는 이전 협업에서 학습하여 시간이 지남에 따라 더 나은 위임 결정을 내릴 수 있습니다.
|
|
|
|
## 다음 단계
|
|
|
|
- **예제 시도하기**: 기본 협업 예제부터 시작하세요
|
|
- **역할 실험하기**: 다양한 에이전트 역할 조합을 테스트해 보세요
|
|
- **상호작용 모니터링**: 협업 과정을 직접 보려면 `verbose=True`를 사용하세요
|
|
- **작업 설명 최적화**: 명확한 작업이 더 나은 협업으로 이어집니다
|
|
- **확장하기**: 복잡한 프로젝트에는 계층적 프로세스를 시도해 보세요
|
|
|
|
협업은 개별 AI 에이전트를 복잡하고 다면적인 문제를 함께 해결할 수 있는 강력한 팀으로 변화시킵니다. |