CrewAI Agent と Task 入門:役割分担を崩壊させない分け方

3 min read

CrewAI の初回失敗は API ではなく、役割分担の崩れが原因であることが多いです。
原則は 1 つだけ。1 Agent = 1 専門、1 Task = 1 仕事

まず Agent を分け、次に Task を書く

考え方:

  • Agent は「誰が」
  • Task は「何を」
  • Context は「前工程から何を渡すか」

1 つの Agent に調査・執筆・レビューを同時にさせると、全部中途半端になりがちです。

良い Agent 設計例

researcher:
  role: >
    AI Research Analyst
  goal: >
    Collect accurate and current information
  backstory: >
    You specialize in finding reliable sources and extracting key facts.
  allow_delegation: false
 
writer:
  role: >
    Technical Writer
  goal: >
    Turn raw findings into clear and practical documentation
  backstory: >
    You explain complex ideas in simple language for beginners.
  allow_delegation: false

⚠️ allow_delegation は最初はオフ推奨。まず安定化してから検討しましょう。

良い Task 設計例

research_task:
  description: >
    Find 8-10 important updates about {topic} in 2026.
    Include what changed and why it matters.
  expected_output: >
    A markdown bullet list.
    Each bullet includes: title, summary, and source URL.
  agent: researcher
 
write_task:
  description: >
    Convert the research bullets into a tutorial article with examples.
  expected_output: >
    A markdown article with intro, 3 sections, and conclusion.
  agent: writer
  context:
    - research_task

初心者がハマる 3 つの罠

  1. Task 記述が短すぎる:必要な形式が伝わらない
  2. expected_output がない:毎回フォーマットが揺れる
  3. context がない:後続タスクが前段結果を受け取れない

シンプルなチェックリスト

YAML を書いたら毎回この 5 つを確認:

  • Agent は 1 つの専門に絞れているか?
  • Task は 1 つのことだけしているか?
  • expected_output に形式が明記されているか?
  • 依存関係に context があるか?
  • 出力担当に output_file を設定したか?

次へ

役割分担ができたら、次は「どう流すか」です。
👉 Crew と Process