CrewAI 术语速查表

Glossary · 可打印 · 依据 docs.crewai.com(2026-10-11 核对,v1.15.27) · ← 第 1 课 · 第 2 课 · 第 3 课 · 第 4 课 →

嵌套关系:Flow ⊃ 步骤(@start / @listen)⊃ Crew ⊃ Task → 由 Agent 执行;Crew 按 Process 排班。

Agent(智能体)

自主单元:执行任务,依据 role 与 goal 做决策,可用工具、可协作。新项目每个 Agent 一个文件 agents/<name>.jsonc。

concepts/agents

role / goal / backstory

Agent 的“人设”:role 职能与专长;goal 指导决策的个人目标;backstory 背景与性格。三者均可含 {placeholder}。

Agent Attributes

tools · llm

tools:Agent 可调用的能力(默认空列表)。llm:驱动 Agent 的语言模型(可选;JSON 写法如 "openai/gpt-4o")。

Agent Attributes

Task(任务)

由一个 Agent 完成的具体工作。在 crew.jsonc 的 tasks 数组中定义,数组顺序即执行顺序(sequential)。

concepts/tasks

description · expected_output

Task 的两个必填字段:做什么;做完的交付物长什么样。

Tasks · JSONC

agent(Task 字段)

把 Task 派给哪个 Agent;值须与 crew.jsonc 中 agents 列出的名字一致。hierarchical 下可不预先分配。

Task Attributes

context(Task 字段)

列出要读取其输出的前序 Task 名(可多个);JSON 中禁止向前引用。sequential 下上一个 Task 的输出本就会自动传给下一个,context 用于显式指定。

Referring to Other Tasks · Sequential

output_file · markdown

output_file:把 Task 输出存成文件;markdown:要求以 Markdown 格式返回。

Task Attributes

Crew(团队)

一组协作的 Agent 共同完成一组 Task,并定义执行策略。核心字段 agents、tasks、process。新项目用 crew.jsonc 定义。

concepts/crews

inputs · {placeholder}

crew.jsonc 顶层 inputs 给 {topic} 等占位符提供默认值;缺省时 crewai run 会提示输入。在 Flow 中通过 crew.kickoff(inputs=...) 传入。

First Crew · Step 3

Process(流程)

Crew 执行 Task 的策略,枚举值只有两种:sequential、hierarchical。默认 sequential。

concepts/processes

sequential(顺序)

按 tasks 列表顺序执行,前一个 Task 的输出作为下一个的上下文。

Sequential Process

hierarchical(层级)

由 manager Agent 负责规划、分派、审核;Task 不预先分配。必须提供 manager_llm 或 manager_agent。

Hierarchical Process

manager_llm · manager_agent

hierarchical 的经理,二选一必填:manager_llm 让 CrewAI 自动创建经理;manager_agent 指定自定义经理(JSON 中可引用不在 agents 列表里的 agents/<name>.jsonc)。(第 3 课)

Crew Attributes · Custom Manager Agent

allow_delegation(允许委派)

Agent 属性,默认 False。设为 True 时自动获得两个协作工具:Delegate work to coworker(委派工作)与 Ask question to coworker(向同事提问)。与 Process 无关,sequential 下也可用。(第 3 课)

How Agent Collaboration Works · Agent Attributes

Delegation Loops(委派循环)

症状:Agent 之间“delegate back and forth indefinitely”。官方解法:清晰层级——经理 allow_delegation=True,专家 False(No re-delegation)。(第 3 课)

Issue: Delegation Loops

max_iter · max_execution_time

max_iter:Agent 达到最大迭代次数前必须给出最佳答案,默认 20。max_execution_time:任务执行最长秒数(可选)。兜底用的硬上限。(第 3 课)

Agent Attributes · Execution Control

Flow(流程编排)

结构化、事件驱动的工作流:管理 state、控制执行(条件/循环/分支),在某些步骤里启动 Crew。官方建议生产应用从 Flow 开始。

concepts/flows · Crews vs Flows

@start() · @listen()

@start():Flow 入口步骤。@listen(x):x 产出输出后执行,可把 x 的输出作为参数接收。

Flows · Getting Started

state(Flow 状态)

self.state:Flow 各步骤共享的数据,可为 dict(非结构化)或 Pydantic 模型(结构化);每个实例自带唯一 id。@persist 可跨重启保留。

State Management · Persistence

@router() · or_ · and_

Flow 的控制流工具:@router() 按方法输出路由到不同分支;or_ / and_ 监听多个步骤的任一/全部完成。(第 1 课未展开)

Flow Control

kickoff()

启动执行:crew.kickoff(inputs=...) 运行一个 Crew;flow.kickoff() 运行 Flow,返回最后完成的方法的输出。

Kicking Off a Crew · Flow Output

JSON-first(agents/*.jsonc + crew.jsonc)

crewai create crew 新项目的默认布局;crewai run 直接加载。旧布局 crew.py + config/*.yaml 需 --classic。

First Crew · Step 1

Unified Memory(统一记忆)

一个 Memory 类取代旧的 short-term / long-term / entity / external 四种记忆。四种用法:standalone、Crew(memory=True:Task 后自动抽取事实、Task 前召回注入)、Agent(memory.scope(...))、Flow(self.remember/recall/extract_memories)。默认存储 LanceDB 中央库。(第 4 课)

Memory · Overview · Memory in Flows

scope(记忆作用域)

类似文件系统的层级路径,如 /project/alpha;是抽象命名空间,不绑定代码目录。按 scope 召回只搜该前缀子树(向下)。memory.scope(path) 得到子树视图;memory.slice(scopes=[...]) 跨多个分支读。(第 4 课)

Hierarchical Scopes · Memory Slices

suggested_scope

remember() 省略 scope 时,LLM 读现有 scope 列表后给出的放置位置(“best matching existing scope or new path”),可新建路径;LLM 失败时退回 /。(第 4 课)

How Scope Inference Works · analyze.py

recall depth(召回深度)

recall(..., depth=):"shallow" 纯向量检索 + 复合打分,无 LLM;"deep"(默认)走 RecallFlow(查询分析、选 scope、并行检索、置信度路由)。复合分 = 语义 + 时近 + 重要度加权(默认 0.5 / 0.3 / 0.2)。(第 4 课)

RecallFlow · Composite Scoring

consolidation(记忆合并整理)

保存时与相似旧记录比较,相似度超过 consolidation_threshold(默认 0.85)时由 LLM 对旧记录决定 keep / update / delete,并决定是否 insert_new,防止重复堆积。(第 4 课)

Memory Consolidation