check-crewai-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCheck CrewAI API
检查 CrewAI API
Load this before writing or reviewing crewai code: it maps what you probably remember to what crewai 1.15.x actually accepts.
Verified against crewai 1.15.22 and 1.15.23 on 2026-10-01.
Live-tested with real LLMs on 2026-10-01.
Run first; if the major/minor differs from 1.15, re-verify version-sensitive rows with the skill before trusting them.
crewai versionask-docs编写或审查 crewai 代码前先加载本文:它将你可能记得的内容映射到 crewai 1.15.x 实际接受的内容。
已针对 crewai 1.15.22 和 1.15.23 于 2026-10-01 进行验证。
已于 2026-10-01 使用真实 LLM 进行实测。
先运行 ;如果主版本或次版本与 1.15 不同,请先使用 skill 重新验证与版本相关的条目,再信任这些内容。
crewai versionask-docs1. Three rules before you write anything
1. 开始编写前必须了解的三条规则
-
Unknown keyword arguments are silently ignored.,
AgentandTaskaccept and drop parameters that do not exist.CrewandCrew(memory_config={...})construct fine and do nothing. A stale parameter name never raises, so check it exists:Task(response_format=Model)pythonfrom crewai import Agent, Crew, Task assert "response_model" in Task.model_fields # real field assert "response_format" not in Task.model_fields # silently dropped if passed assert "memory_config" not in Crew.model_fields # silently dropped if passed print(sorted(Agent.model_fields)[:5]) -
The installed source wins over any doc, tutorial, or memory. That includes thethat
AGENTS.mdwrites into new projects. When a row below matters, check the installed signature (see verify-installed-api.md).crewai create -
Assert on structured output at the boundary. Several mistakes below fail quietly withwhile the run reports success.
out.pydantic is None
-
未知的关键字参数会被静默忽略。、
Agent和Task会接受并丢弃不存在的参数。Crew和Crew(memory_config={...})可以成功构造,但不会产生任何作用。过时的参数名不会引发异常,因此应检查该参数是否存在:Task(response_format=Model)pythonfrom crewai import Agent, Crew, Task assert "response_model" in Task.model_fields # real field assert "response_format" not in Task.model_fields # silently dropped if passed assert "memory_config" not in Crew.model_fields # silently dropped if passed print(sorted(Agent.model_fields)[:5]) -
已安装的源码优先于任何文档、教程或记忆。 这也包括写入新项目的
crewai create。当下表中的某一项很重要时,请检查已安装版本的函数签名(参见 verify-installed-api.md)。AGENTS.md -
在边界处断言结构化输出。 下文中的若干错误会在运行报告成功时静默失败,并出现。
out.pydantic is None
2. Imports
2. 导入
| You probably wrote | Current 1.15.x form | What the wrong form does |
|---|---|---|
| | |
| | |
| | |
| | |
| | |
| No replacement in crewai - use a sandbox tool or service | |
The current top-level and project imports:
python
from crewai import Agent, BaseLLM, Crew, CrewOutput, Flow, LLM, Memory, Process, Task, TaskOutput
from crewai.project import CrewBase, after_kickoff, agent, before_kickoff, crew, llm, task, tool
from crewai.tools import BaseTool, tool
from crewai.flow import Flow, and_, listen, or_, persist, router, start
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
from crewai.mcp import MCPServerHTTP, MCPServerSSE, MCPServerStdio
from crewai.events import BaseEventListener, crewai_event_bus| 你可能这样写 | 当前 1.15.x 形式 | 错误形式的表现 |
|---|---|---|
| | |
| | |
| | |
| | |
| | |
| crewai 中没有替代项——请使用沙箱工具或服务 | |
当前顶层导入和项目导入方式:
python
from crewai import Agent, BaseLLM, Crew, CrewOutput, Flow, LLM, Memory, Process, Task, TaskOutput
from crewai.project import CrewBase, after_kickoff, agent, before_kickoff, crew, llm, task, tool
from crewai.tools import BaseTool, tool
from crewai.flow import Flow, and_, listen, or_, persist, router, start
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
from crewai.mcp import MCPServerHTTP, MCPServerSSE, MCPServerStdio
from crewai.events import BaseEventListener, crewai_event_bus3. Agent, Task, Crew parameters and defaults
3. Agent、Task、Crew 的参数和默认值
| Parameter | Current value | Note |
|---|---|---|
| required | |
| | Do not assume 15 or 20 |
| | From env |
| | Only permits caching; it does not turn it on |
| | Tool-result caching is opt-in: set |
| | |
| | Only |
| | |
| You probably wrote | Current form | What the wrong form does |
|---|---|---|
| | |
| add | |
| | |
| Remove; use a sandbox tool | Deprecated no-ops; |
| Remove, or set | Deprecated, |
Two | One agent per concurrent async task | |
python
from crewai import Agent, Crew, Process, Task
researcher = Agent(
role="Researcher",
goal="Find facts about {topic}",
backstory="A careful researcher.",
llm="openai/gpt-4.1-mini",
)
research = Task(
description="List three facts about {topic}.",
expected_output="Three bullet points.",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[research], process=Process.sequential, cache=True)
out = crew.kickoff(inputs={"topic": "honey bees"})
print(out.raw)| 参数 | 当前值 | 说明 |
|---|---|---|
| 必填 | 仅使用 |
| | 不要假定为 15 或 20 |
| | 依次从 |
| | 仅表示允许缓存,并不会自动启用缓存 |
| | 工具结果缓存需要主动设置 |
| | |
| | 仅存在 |
| | |
| 你可能这样写 | 当前形式 | 错误形式的表现 |
|---|---|---|
| | |
使用 | 添加 | |
| | |
| 移除这些参数,改用沙箱工具 | 已弃用且不起作用; |
| 移除该参数,或为每个 agent 设置 | 已弃用,并产生 |
两个 | 每个并发异步 task 使用一个独立的 agent | |
python
from crewai import Agent, Crew, Process, Task
researcher = Agent(
role="Researcher",
goal="Find facts about {topic}",
backstory="A careful researcher.",
llm="openai/gpt-4.1-mini",
)
research = Task(
description="List three facts about {topic}.",
expected_output="Three bullet points.",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[research], process=Process.sequential, cache=True)
out = crew.kickoff(inputs={"topic": "honey bees"})
print(out.raw)4. Running a crew and reading the result
4. 运行 Crew 并读取结果
| You probably wrote | Current form | What the wrong form does |
|---|---|---|
| | |
| | Works, but |
| | |
| Build a fresh | No error, but every run reuses the first kickoff's inputs: the per-run copies keep the already-interpolated task text |
| | No error, but the agent gets zero MCP tools: string refs resolve with |
CrewOutputrawpydanticjson_dicttasks_outputTaskOutputtoken_usageout["field"]pydanticjson_dictkickoff_for_each(inputs=[...])CrewOutputtoken_usageLLMLLM(...)anthropic/claude-haiku-4-5LLMLLMLLMLLMCallCompletedEventevent.usagepython
import asyncio
from crewai import Agent, Crew, Task
def make_crew() -> Crew:
writer = Agent(role="Writer", goal="Write", backstory="Writes short text.", llm="openai/gpt-4.1-mini")
task = Task(description="One line on {topic}.", expected_output="One line.", agent=writer)
return Crew(agents=[writer], tasks=[task])
out = make_crew().kickoff(inputs={"topic": "bees"})
print(out.raw, out.token_usage.total_tokens, [t.raw for t in out.tasks_output])
many = make_crew().kickoff_for_each(inputs=[{"topic": "bees"}, {"topic": "ants"}])
print([o.raw for o in many])
async def main():
return await make_crew().akickoff(inputs={"topic": "wasps"})
print(asyncio.run(main()).raw)| 你可能这样写 | 当前形式 | 错误形式的表现 |
|---|---|---|
| | |
使用 | | 可以运行,但 |
| | |
在同一个 | 为 | 不会报错,但每次运行都会复用第一次 kickoff 的 inputs:每次运行生成的副本仍保留已经插值过的 task 文本 |
在通过 | | 不会报错,但 agent 得不到任何 MCP 工具:字符串引用通过 |
CrewOutputrawpydanticjson_dicttasks_outputTaskOutputtoken_usageout["field"]pydanticjson_dictkickoff_for_each(inputs=[...])CrewOutputtoken_usageLLMLLM(...)anthropic/claude-haiku-4-5LLMLLMLLMLLMCallCompletedEventevent.usagepython
import asyncio
from crewai import Agent, Crew, Task
def make_crew() -> Crew:
writer = Agent(role="Writer", goal="Write", backstory="Writes short text.", llm="openai/gpt-4.1-mini")
task = Task(description="One line on {topic}.", expected_output="One line.", agent=writer)
return Crew(agents=[writer], tasks=[task])
out = make_crew().kickoff(inputs={"topic": "bees"})
print(out.raw, out.token_usage.total_tokens, [t.raw for t in out.tasks_output])
many = make_crew().kickoff_for_each(inputs=[{"topic": "bees"}, {"topic": "ants"}])
print([o.raw for o in many])
async def main():
return await make_crew().akickoff(inputs={"topic": "wasps"})
print(asyncio.run(main()).raw)5. LLMs, model strings, and provider extras
5. LLM、模型字符串和提供商附加包
LiteLLM is no longer a dependency. is a factory that returns a native provider class; only the OpenAI SDK ships with core crewai.
LLM(model=...)| You probably wrote | Current form | What the wrong form does |
|---|---|---|
| | |
| | |
| | |
No | Default is | |
| | |
Custom | Also accept | |
Native providers: openai, anthropic/claude, azure, google/gemini, bedrock/aws, openrouter, deepseek, ollama, hosted_vllm, cerebras, dashscope, snowflake. Extras: , , , , . Construction never checks the key; kickoff does (, or ; a wrong key gets the provider's ). The scaffolds never add a provider extra, even with : run yourself.
crewai[anthropic]crewai[google-genai]crewai[bedrock]crewai[azure-ai-inference]crewai[litellm]ValueError: OPENAI_API_KEY is requiredANTHROPIC_API_KEY is requiredAuthenticationError ... 401crewai create--provider anthropic/...uv add "crewai[anthropic]"python
from crewai import LLM
gpt = LLM(model="openai/gpt-4.1-mini", temperature=0.2) # core install
local = LLM(model="ollama/llama3") # core install, OpenAI-compatible route
claude = LLM(model="anthropic/claude-sonnet-4-5") # needs: uv add "crewai[anthropic]"
print(type(gpt).__name__, type(local).__name__, type(claude).__name__)A custom LLM subclasses and implements with the full signature. If forwards to a provider SDK, send only each message's and : crewai adds a key to some messages, and the Anthropic API rejects it with .
BaseLLMcallcallmessagesrolecontentcache_breakpoint: True400 ... messages.0.cache_breakpoint: Extra inputs are not permittedpython
from typing import Any
from crewai import Agent, BaseLLM, Crew, Task
class EchoLLM(BaseLLM):
def call(self, messages, tools=None, callbacks=None, available_functions=None,
from_task=None, from_agent=None, response_model=None, **kwargs: Any) -> str:
return "echo: " + str(messages[-1]["content"])[:40]
agent = Agent(role="Echo", goal="Echo", backstory="Echoes.", llm=EchoLLM(model="echo"))
task = Task(description="Say hi", expected_output="Anything", agent=agent)
print(Crew(agents=[agent], tasks=[task]).kickoff().raw)LiteLLM 不再是依赖项。 是一个工厂,会返回原生提供商类;crewai 核心版本仅内置 OpenAI SDK。
LLM(model=...)| 你可能这样写 | 当前形式 | 错误形式的表现 |
|---|---|---|
仅安装普通 | 执行 | |
仅安装普通 | 执行 | |
| 执行 | |
不设置 | 默认值为 | |
| | |
自定义 | 还需接受 | kickoff 时出现 |
原生提供商:openai、anthropic/claude、azure、google/gemini、bedrock/aws、openrouter、deepseek、ollama、hosted_vllm、cerebras、dashscope、snowflake。附加包:、、、、。构造对象时不会检查 API key;kickoff 时才会检查( 或 ;错误的 key 会触发提供商的 )。即使使用 , 生成的脚手架也不会添加提供商附加包;请自行执行 。
crewai[anthropic]crewai[google-genai]crewai[bedrock]crewai[azure-ai-inference]crewai[litellm]ValueError: OPENAI_API_KEY is requiredANTHROPIC_API_KEY is requiredAuthenticationError ... 401--provider anthropic/...crewai createuv add "crewai[anthropic]"python
from crewai import LLM
gpt = LLM(model="openai/gpt-4.1-mini", temperature=0.2) # core install
local = LLM(model="ollama/llama3") # core install, OpenAI-compatible route
claude = LLM(model="anthropic/claude-sonnet-4-5") # needs: uv add "crewai[anthropic]"
print(type(gpt).__name__, type(local).__name__, type(claude).__name__)自定义 LLM 应继承 ,并使用完整签名实现 。如果 将 转发给提供商 SDK,请只发送每条消息的 和 :crewai 会向部分消息添加 键,而 Anthropic API 会拒绝该键并返回 。
BaseLLMcallcallmessagesrolecontentcache_breakpoint: True400 ... messages.0.cache_breakpoint: Extra inputs are not permittedpython
from typing import Any
from crewai import Agent, BaseLLM, Crew, Task
class EchoLLM(BaseLLM):
def call(self, messages, tools=None, callbacks=None, available_functions=None,
from_task=None, from_agent=None, response_model=None, **kwargs: Any) -> str:
return "echo: " + str(messages[-1]["content"])[:40]
agent = Agent(role="Echo", goal="Echo", backstory="Echoes.", llm=EchoLLM(model="echo"))
task = Task(description="Say hi", expected_output="Anything", agent=agent)
print(Crew(agents=[agent], tasks=[task]).kickoff().raw)6. Structured output
6. 结构化输出
| Where | Use | Result lands in |
|---|---|---|
| Parsed model on the task and crew output | |
| Dict output | |
| Native provider structured output only | |
| Standalone agent | |
| Direct LLM call | the parsed model |
| Constructor-level default |
| You probably wrote | Current form | What the wrong form does |
|---|---|---|
| | Silently ignored |
| | |
| Pick one | |
| Drop | The file gets the model's JSON, whatever the extension |
| A relative path (or | The leading |
| Set | With no matching |
python
from pydantic import BaseModel
from crewai import Agent, Crew, Task
class Report(BaseModel):
title: str
points: list[str]
analyst = Agent(role="Analyst", goal="Summarise", backstory="Concise.", llm="openai/gpt-4.1-mini")
task = Task(description="Summarise {topic}.", expected_output="A title and points.",
agent=analyst, output_pydantic=Report)
out = Crew(agents=[analyst], tasks=[task]).kickoff(inputs={"topic": "bees"})
assert out.pydantic is not None, "structured output was dropped"
print(out.pydantic.title, out["points"])
standalone = analyst.kickoff("Summarise bees.", response_format=Report)
print(standalone.pydantic)In a project keep the model in Python even when the rest of the task is YAML:
@CrewBasepython
@task
def research_task(self) -> Task:
return Task(config=self.tasks_config["research_task"], output_pydantic=Report)| 使用位置 | 用途 | 结果存放位置 |
|---|---|---|
| 解析后的模型,存在于 task 和 Crew 输出中 | |
| 字典输出 | |
| 仅原生提供商的结构化输出 | |
| 独立 agent | |
| 直接调用 LLM | 解析后的模型 |
| 构造函数级别的默认值 |
| 你可能这样写 | 当前形式 | 错误形式的表现 |
|---|---|---|
| | 被静默忽略 |
| | |
| 二选一 | |
使用 | 移除 | 无论文件扩展名是什么,文件中都会写入模型的 JSON |
| 使用相对路径(或通过 inputs 使用 | 前导 |
在 | 在 Python 的 | 没有匹配的 |
python
from pydantic import BaseModel
from crewai import Agent, Crew, Task
class Report(BaseModel):
title: str
points: list[str]
analyst = Agent(role="Analyst", goal="Summarise", backstory="Concise.", llm="openai/gpt-4.1-mini")
task = Task(description="Summarise {topic}.", expected_output="A title and points.",
agent=analyst, output_pydantic=Report)
out = Crew(agents=[analyst], tasks=[task]).kickoff(inputs={"topic": "bees"})
assert out.pydantic is not None, "structured output was dropped"
print(out.pydantic.title, out["points"])
standalone = analyst.kickoff("Summarise bees.", response_format=Report)
print(standalone.pydantic)在 项目中,即使 task 的其余内容使用 YAML,也应将模型保留在 Python 中:
@CrewBasepython
@task
def research_task(self) -> Task:
return Task(config=self.tasks_config["research_task"], output_pydantic=Report)7. Guardrails
7. Guardrails
A function guardrail takes one argument () and returns a tuple . On the value is fed back to the agent as the error and the task retries, up to (default 3); then the task raises . A string guardrail is checked by an extra LLM call.
TaskOutput(bool, value)Falseguardrail_max_retriesTask failed guardrail validation after N retries| You probably wrote | Current form | What the wrong form does |
|---|---|---|
| | Annotated: |
| | Same |
| | |
Relying on | Write a function guardrail | In open-source crewai it is a no-op that always passes |
python
from typing import Any
from crewai import Agent, Crew, Task, TaskOutput
def under_50_words(output: TaskOutput) -> tuple[bool, Any]:
if len(output.raw.split()) > 50:
return (False, "Keep it under 50 words.")
return (True, output.raw)
writer = Agent(role="Writer", goal="Write", backstory="Brief.", llm="openai/gpt-4.1-mini")
task = Task(description="Describe {topic}.", expected_output="A short paragraph.", agent=writer,
guardrails=[under_50_words, "Must not mention prices"], guardrail_max_retries=2)
print(Crew(agents=[writer], tasks=[task]).kickoff(inputs={"topic": "bees"}).raw)guardrails=[...]out.raw函数 guardrail 接收一个参数(),并返回元组 。当结果为 时,value 会作为错误反馈给 agent,task 最多重试 次(默认 3 次);之后 task 会抛出 。字符串 guardrail 需要额外调用一次 LLM 进行检查。
TaskOutput(bool, value)Falseguardrail_max_retriesTask failed guardrail validation after N retries| 你可能这样写 | 当前形式 | 错误形式的表现 |
|---|---|---|
| | 添加类型注解时:在 |
| | 在 |
| | |
依赖 | 编写函数 guardrail | 在开源版 crewai 中,它是一个始终通过的空操作 |
python
from typing import Any
from crewai import Agent, Crew, Task, TaskOutput
def under_50_words(output: TaskOutput) -> tuple[bool, Any]:
if len(output.raw.split()) > 50:
return (False, "Keep it under 50 words.")
return (True, output.raw)
writer = Agent(role="Writer", goal="Write", backstory="Brief.", llm="openai/gpt-4.1-mini")
task = Task(description="Describe {topic}.", expected_output="A short paragraph.", agent=writer,
guardrails=[under_50_words, "Must not mention prices"], guardrail_max_retries=2)
print(Crew(agents=[writer], tasks=[task]).kickoff(inputs={"topic": "bees"}).raw)guardrails=[...]out.raw8. Memory and knowledge
8. Memory 和 Knowledge
Memory is one class (LanceDB storage). Its defaults call OpenAI: for embeddings and for analysis. analyses with the first agent's instead, and knowledge with no embeds with . Live with an OpenAI key: a crew stored a codename in one process and a new crew recalled it in the next; crew and agent knowledge both answered from the source.
Memorytext-embedding-3-largegpt-5.4-miniCrew(memory=True)llmembeddertext-embedding-3-smallmemory=True| You probably wrote | Current form | What the wrong form does |
|---|---|---|
| | |
| Set the key, or pass | Crew completes; every save fails silently (only a |
| Same | |
| Pass | |
| Run the agent as a task in a | No error with or without a key: |
| Same | Logs |
Changing the knowledge | | |
Adding | Same reset | |
The embedder config shape is ; the OpenAI model key is . raises in , and for knowledge it is silently ignored (the crew embeds with ). The provider below also needs and a running Ollama server with the model pulled; without the package, crew knowledge is silently . is a local, key-free embedder that core crewai can already run (chromadb's ; about 80 MB of model downloaded on first use) - the design-agent skill's memory-and-knowledge reference has working examples. For a deterministic embedder in tests, use a callable () or a custom class (knowledge) - see verify-installed-api.md.
{"provider": <name>, "config": {...}}model_name"model"TypeError: ... unexpected keyword argument 'model'Memorytext-embedding-3-largeollamauv add ollamaNone{"provider": "onnx"}onnxruntimeMemorypython
from crewai import Agent, Crew, Memory, Task
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
embedder = {"provider": "ollama", "config": {"model_name": "nomic-embed-text"}} # needs: uv add ollama
memory = Memory(llm="openai/gpt-4.1-mini", embedder=embedder)
facts = StringKnowledgeSource(content="acme was founded in 2020.")
agent = Agent(role="Analyst", goal="Answer", backstory="Uses knowledge.", llm="openai/gpt-4.1-mini")
task = Task(description="When was acme founded?", expected_output="A year.", agent=agent)
crew = Crew(agents=[agent], tasks=[task], memory=memory, knowledge_sources=[facts], embedder=embedder)
if crew.knowledge is None:
print("knowledge failed to initialise - is the ollama package installed and the server running?")Reset stored data from the project directory with (memory; errors with if the crew has no memory), (knowledge), (agent knowledge), (latest kickoff outputs), (all). The old , , flags are hidden deprecated aliases that print a warning and reset the unified memory. Storage path and offline embedders: verify-installed-api.md.
crewai reset-memories -mMemory memory system is not initialized-kn-akn-k-a-s-l-eMemory 已统一为单个 类(使用 LanceDB 存储)。其默认配置会调用 OpenAI:embeddings 使用 ,分析使用 。 会改用第一个 agent 的 进行分析;knowledge 未指定 时,会使用 生成 embeddings。使用有效的 OpenAI key 实测:一个 Crew 在一个进程中存储了代号,新建的 Crew 在下一个进程中成功回忆了该代号;Crew 和 agent 的 knowledge 均能根据来源回答问题。
Memorytext-embedding-3-largegpt-5.4-miniCrew(memory=True)llmembeddertext-embedding-3-smallmemory=True| 你可能这样写 | 当前形式 | 错误形式的表现 |
|---|---|---|
| | |
使用 | 设置 key,或传入 | Crew 会完成;每次保存都会静默失败(仅发出 |
调用 | 同上 | |
agent 位于 Crew 中,且 | 在 Agent 或 Crew 上传入 | Crew kickoff 时出现 |
对包含 | 将该 agent 作为 task 放入 | 无论是否设置 key 都不会报错: |
| 同上 | 日志显示 |
运行并存储 knowledge 后更改 knowledge 的 | 执行 | |
使用无 | 执行相同的重置操作 | |
Embedder 配置结构为 ;OpenAI 的模型键为 。在 中使用 会引发 ,而在 knowledge 中使用则会被静默忽略(Crew 会使用 生成 embeddings)。下面的 提供商还需要执行 ,并确保 Ollama 服务正在运行且已拉取所需模型;如果未安装该包,Crew 的 knowledge 会静默变成 。 是一种本地、无需 key 的 embedder,crewai 核心版本已经可以运行(使用 chromadb 的 ;首次使用时会下载约 80 MB 的模型)——design-agent skill 的 memory-and-knowledge 参考文档中提供了可用示例。如需在测试中使用确定性 embedder,请为 Memory 传入 callable,或为 knowledge 传入自定义类——参见 verify-installed-api.md。
{"provider": <name>, "config": {...}}model_nameMemory"model"TypeError: ... unexpected keyword argument 'model'text-embedding-3-largeollamauv add ollamaNone{"provider": "onnx"}onnxruntimepython
from crewai import Agent, Crew, Memory, Task
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
embedder = {"provider": "ollama", "config": {"model_name": "nomic-embed-text"}} # needs: uv add ollama
memory = Memory(llm="openai/gpt-4.1-mini", embedder=embedder)
facts = StringKnowledgeSource(content="acme was founded in 2020.")
agent = Agent(role="Analyst", goal="Answer", backstory="Uses knowledge.", llm="openai/gpt-4.1-mini")
task = Task(description="When was acme founded?", expected_output="A year.", agent=agent)
crew = Crew(agents=[agent], tasks=[task], memory=memory, knowledge_sources=[facts], embedder=embedder)
if crew.knowledge is None:
print("knowledge failed to initialise - is the ollama package installed and the server running?")在项目目录中重置已存储的数据:(memory;如果 Crew 没有 memory,会报错 )、(knowledge)、(agent knowledge)、(最近一次 kickoff 的输出)、(全部)。旧的 、、 标志是隐藏的弃用别名;使用时会显示警告,并重置统一的 memory。存储路径和离线 embedder 参见 verify-installed-api.md。
crewai reset-memories -mMemory memory system is not initialized-kn-akn-k-a-s-l-e9. Project scaffold and CLI
9. 项目脚手架和 CLI
| You probably wrote | Current form | What the wrong form does |
|---|---|---|
| | Starts an interactive wizard that writes a JSON project ( |
| For CI, create the crew with | Opens a full-screen run view that waits for the user to quit, even with no TTY, so the command never exits. An environment variable, |
Leaving | Set the key, set | The crew completes; memory recall and saves fail silently |
| Put inputs in | |
| | Deprecated aliases, warning printed |
| Do not return the output | The |
Trusting | Run | There |
bash
crewai version
crewai create crew research_crew --classic --skip-provider
cd research_crew && uv add "crewai[anthropic]" # only if an agent uses an anthropic/ model
crewai install && crewai run
crewai reset-memories --helpThe classic layout: ( class), and (keys match the / method names), , and with and dependency . In YAML, resolves to an method of that name, otherwise it is used as a model string. also writes a with a placeholder - replace it, never commit it.
src/<name>/crew.py@CrewBasesrc/<name>/config/agents.yamltasks.yaml@agent@taskmain.pypyproject.toml[tool.crewai] type = "crew"crewai[tools]llm: <name>@llmcrewai create flow.envOPENAI_API_KEY| 你可能这样写 | 当前形式 | 错误形式的表现 |
|---|---|---|
执行 | | 现在会启动交互式向导并生成 JSON 项目( |
在 CI 或脚本中对 JSON Crew 执行 | 对于 CI,使用 | 会打开全屏运行视图并等待用户退出,即使没有 TTY 也不会退出,导致命令一直挂起。环境变量 |
保留 JSON 脚手架中的 | 设置 key、将 | Crew 会完成;memory 的回忆和保存都会静默失败 |
对经典 Crew 执行 | 将 inputs 放入 | |
| | 弃用别名,会显示警告 |
在 | 不要返回输出 | |
在 CI 中信任经典 Crew( | 运行 | 即使 Crew 或 flow 进程失败, |
bash
crewai version
crewai create crew research_crew --classic --skip-provider
cd research_crew && uv add "crewai[anthropic]" # only if an agent uses an anthropic/ model
crewai install && crewai run
crewai reset-memories --help经典项目布局:( 类)、 和 (键名与 / 方法名一致)、,以及包含 和 依赖项的 。在 YAML 中, 会解析为同名 方法,否则会被用作模型字符串。 还会写入一个包含占位符 的 ——请替换该值,切勿提交到版本库。
src/<name>/crew.py@CrewBasesrc/<name>/config/agents.yamltasks.yaml@agent@taskmain.py[tool.crewai] type = "crew"crewai[tools]pyproject.tomlllm: <name>@llmcrewai create flowOPENAI_API_KEY.env10. Removed and deprecated
10. 已移除和已弃用的功能
| Feature | Status in 1.15.22-1.15.23 | Do instead |
|---|---|---|
| Removed from | Sandbox tool or service |
| Deprecated no-ops | Same |
| Removed / ignored | |
| Removed | |
| Deprecated | Per-agent |
| Deprecated | |
| Deprecation shim | |
| LiteLLM as a core dependency | Optional extra | |
| 功能 | 1.15.22-1.15.23 中的状态 | 替代做法 |
|---|---|---|
| 已从 | 使用沙箱工具或服务 |
| 已弃用且不起作用 | 同上 |
| 已移除或被忽略 | 使用 |
| 已移除 | 使用 |
| 已弃用 | 为每个 agent 设置 |
| 已弃用 | 使用 |
| 弃用兼容层 | 使用 |
| 将 LiteLLM 作为核心依赖 | 改为可选附加包 | 仅非原生提供商需要 |
11. Common mistakes
11. 常见错误
| Symptom | Cause | Fix |
|---|---|---|
| A parameter has no effect and no error | Unknown kwargs are dropped by Agent/Task/Crew | Check |
| | Set |
| Provider SDK extra missing | |
| No | Set |
| Crew finishes but nothing was remembered | | Pass |
| Knowledge never appears in prompts | Crew-level knowledge failed to embed | Set |
| Custom | Accept |
| Guardrail annotated | Annotate |
| It is an interactive JSON wizard now | Add |
| The run view waits for a keypress | For CI, use |
| The | Build a fresh |
| An | One |
Agent never uses its MCP tools under | | |
| Knowledge was stored with another embedder | |
| Knowledge was stored with another OpenAI embedding model | |
| | Do not return it |
| 症状 | 原因 | 修复方法 |
|---|---|---|
| 参数没有任何作用,也没有报错 | Agent/Task/Crew 会丢弃未知 kwargs | 检查 |
| 在 YAML 中设置了 | 在 Python 中设置 |
| 缺少提供商 SDK 附加包 | 执行 |
kickoff 时出现 | 未设置 | 设置 |
| Crew 完成运行,但没有记住任何内容 | | 传入 |
| Knowledge 从未出现在 prompt 中 | Crew 级 knowledge 的 embedding 失败 | 设置 |
| 自定义 | 接受 |
在 | Guardrail 注解为 | 注解为 |
| 现在默认使用交互式 JSON 向导 | 添加 |
对 JSON Crew 执行 | 运行视图会等待按键 | 对于 CI,使用 |
| 该 | 每批任务构建一个新的 |
| 多个 agent 共享同一个 | 每个 Crew 中的每个 agent 使用独立的 |
Agent 在 | 在运行中的事件循环内为 | 使用 |
| Knowledge 使用了另一个 embedder 存储 | 执行 |
| Knowledge 使用了另一个 OpenAI embedding 模型存储 | 执行 |
Crew 成功后, | | 不要返回它 |
12. Checklist
12. 检查清单
- checked; rows re-verified if not 1.15.x
crewai version - Every /
Agent/Taskkwarg exists inCrewmodel_fields - Tools import from , flow decorators and
crewai.toolsfrompersistcrewai.flow - Every task has
expected_output - Every non-OpenAI model string has its extra in
pyproject.toml - Structured output set in Python with , and
output_pydanticasserted non-Noneout.pydantic - Guardrails return and are annotated
(bool, value)or not at alltuple[bool, Any] - Memory and knowledge have an explicit embedder or a provider key in the environment
- No ,
CodeInterpreterTool,allow_code_execution,ShortTermMemorymemory_config - Classic projects created with ; provider extra added with
crewai create crew <name> --classicuv add - CI and scripts use classic crews () run with
crewai create crew <name> --classicuv run run_crew
- 已检查 ;如果不是 1.15.x,已重新验证相关条目
crewai version - 每个 /
Agent/Taskkwargs 都存在于Crew中model_fields - Tool 从 导入,flow 装饰器和
crewai.tools从persist导入crewai.flow - 每个 task 都有
expected_output - 每个非 OpenAI 模型字符串都在 中配置了对应的附加包
pyproject.toml - 在 Python 中使用 设置结构化输出,并断言
output_pydantic不为out.pydanticNone - Guardrail 返回 ,并使用
(bool, value)注解或完全不使用注解tuple[bool, Any] - Memory 和 knowledge 都有显式 embedder,或环境中提供了提供商 key
- 不使用 、
CodeInterpreterTool、allow_code_execution或ShortTermMemorymemory_config - 经典项目通过 创建;提供商附加包通过
crewai create crew <name> --classic添加uv add - CI 和脚本使用经典 Crew(),并通过
crewai create crew <name> --classic运行uv run run_crew
References
参考资料
- Verify the installed API - one-liners to check fields, defaults and signatures in the installed crewai; storage paths; an offline embedder for memory and knowledge
- Source receipts - the crewai source file and line behind each row, so you can re-check after an upgrade
- Public docs: https://docs.crewai.com
For related skills:
- ask-docs - query the live CrewAI docs when a row may have changed
- getting-started - project scaffolding and choosing crews vs flows
- design-agent / design-task - tuning agents and tasks once the API is right
- build-flow - Flow state, routers, , human feedback
@persist - connect-tools-and-mcp - ,
BaseTool,@toolmcps=[...] - test-crewai-project - offline stub LLM and deterministic tests
- deploy-to-amp / call-deployed-crew - shipping and calling a crew
- 验证已安装的 API——用于快速检查已安装 crewai 中的字段、默认值和函数签名;还包含存储路径以及用于 memory 和 knowledge 的离线 embedder
- 来源凭据——提供每个条目背后的 crewai 源文件和对应行,便于升级后重新核对
- 公共文档:https://docs.crewai.com
相关 skills:
- ask-docs——当某个条目可能已经发生变化时,查询最新的 CrewAI 文档
- getting-started——项目脚手架以及在 Crew 与 flow 之间进行选择
- design-agent / design-task——API 配置正确后,对 agent 和 task 进行调优
- build-flow——Flow 状态、router、和人工反馈
@persist - connect-tools-and-mcp——、
BaseTool、@toolmcps=[...] - test-crewai-project——离线 stub LLM 和确定性测试
- deploy-to-amp / ——部署和调用 Crew
call-deployed-crew