커스텀 매니저 에이전트
커스텀 매니저 에이전트 (Custom Manager Agent)
계층형 프로세스를 쓸 때 크루의 매니저를 CrewAI가 자동으로 만들지, 직접 지정할지 선택할 수 있습니다. 이 가이드에서는 manager_agent 속성으로 특정 에이전트를 매니저로 설정해 태스크 관리와 조율을 더 잘 제어하는 방법을 다룹니다. 프로젝트 요구에 맞게 관리 역할을 커스터마이즈할 수 있다는 점이 핵심입니다.
출처: 공식문서
manager_agent 속성 사용하기
manager_agent 속성은 크루를 관리할 커스텀 에이전트를 정의하게 해 줍니다. 이 에이전트가 전체 프로세스를 감독하며 태스크가 효율적이고 최고 수준으로 완료되도록 합니다.
예제
import os
from crewai import Agent, Task, Crew, Process
# Define your agents
researcher = Agent(
role="Researcher",
goal="Conduct thorough research and analysis on AI and AI agents",
backstory="You're an expert researcher, specialized in technology, software engineering, AI, and startups. You work as a freelancer and are currently researching for a new client.",
allow_delegation=False,
)
writer = Agent(
role="Senior Writer",
goal="Create compelling content about AI and AI agents",
backstory="You're a senior writer, specialized in technology, software engineering, AI, and startups. You work as a freelancer and are currently writing content for a new client.",
allow_delegation=False,
)
# Define your task
task = Task(
description="Generate a list of 5 interesting ideas for an article, then write one captivating paragraph for each idea that showcases the potential of a full article on this topic. Return the list of ideas with their paragraphs and your notes.",
expected_output="5 bullet points, each with a paragraph and accompanying notes.",
)
# Define the manager agent
manager = Agent(
role="Project Manager",
goal="Efficiently manage the crew and ensure high-quality task completion",
backstory="You're an experienced project manager, skilled in overseeing complex projects and guiding teams to success. Your role is to coordinate the efforts of the crew members, ensuring that each task is completed on time and to the highest standard.",
allow_delegation=True,
)
# Instantiate your crew with a custom manager
crew = Crew(
agents=[researcher, writer],
tasks=[task],
manager_agent=manager,
process=Process.hierarchical,
)
# Start the crew's work
result = crew.kickoff()
주의할 점은 매니저 에이전트는 allow_delegation=True를 가져야 크루 구성원에게 태스크를 위임할 수 있다는 것입니다. 일반 에이전트들은 allow_delegation=False로 두어 매니저만 위임 권한을 갖도록 만든 예시입니다.
커스텀 매니저 에이전트의 장점
- 향상된 제어 (Enhanced Control): 프로젝트의 특정 요구에 맞게 관리 방식을 조정합니다.
- 개선된 조율 (Improved Coordination): 경험 많은 에이전트가 태스크 조율과 관리를 효율적으로 수행합니다.
- 커스터마이즈 가능한 관리 (Customizable Management): 프로젝트 목표에 맞는 관리 역할과 책임을 정의합니다.
매니저 LLM 설정하기
from crewai import LLM
manager_llm = LLM(model="gpt-4o")
crew = Crew(
agents=[researcher, writer],
tasks=[task],
process=Process.hierarchical,
manager_llm=manager_llm
)
계층형 프로세스를 쓰면서 커스텀 매니저 에이전트를 지정하고 싶지 않다면, 매니저의 언어 모델을 지정할 수 있습니다:
참고: 계층형 프로세스를 사용할 때는
manager_agent또는manager_llm중 하나가 반드시 설정되어야 합니다.