Skip to content
CrewAI 文档版本 跟随上游 源快照 8108deb4 更新于 2026-10-18

智能体能力

了解扩展 CrewAI 智能体的五种方式:工具、MCP、应用、技能和知识。

概述

CrewAI 智能体可以通过 五种不同的能力类型 进行扩展,每种类型服务于不同目的。理解何时使用每种类型——以及它们如何协同工作——是构建高效智能体的关键。


关键区别

最重要的一点是:这些能力分为两类。

行动能力(工具、MCP、应用)

这些能力让智能体能够 做事——调用 API、读取文件、搜索网页、发送电子邮件。在执行时,三者都会解析为相同的内部格式(BaseTool 实例),并出现在智能体可调用的统一工具列表中。

python
from crewai import Agent
from crewai_tools import SerperDevTool, FileReadTool

agent = Agent(
    role="Researcher",
    goal="Find and compile market data",
    backstory="Expert market analyst",
    tools=[SerperDevTool(), FileReadTool()],  # Local tools
    mcps=["https://mcp.example.com/sse"],     # Remote MCP server tools
    apps=["gmail", "google_sheets"],           # Platform integrations
)

上下文能力(技能、知识)

这些能力会修改智能体的 提示词——在智能体开始推理之前注入专业知识、指令或检索到的数据。它们不会赋予智能体新的行动;它们塑造智能体的思考方式以及可访问的信息。

python
from crewai import Agent

agent = Agent(
    role="Security Auditor",
    goal="Audit cloud infrastructure for vulnerabilities",
    backstory="Expert in cloud security with 10 years of experience",
    skills=["./skills/security-audit"],        # Domain instructions
    knowledge_sources=[pdf_source, url_source], # Retrieved facts
)

何时使用何种能力

你需要……使用示例
让智能体搜索网页工具tools=[SerperDevTool()]
让智能体通过 MCP 调用远程 APIMCPmcps=["https://api.example.com/sse"]
让智能体通过 Gmail 发送电子邮件应用apps=["gmail"]
让智能体遵循特定流程技能skills=["./skills/code-review"]
让智能体引用公司文档知识knowledge_sources=[pdf_source]
让智能体搜索网页并遵循评审指南工具 + 技能同时使用两者

组合能力

在实践中,智能体经常 同时使用多种能力类型。下面是一个贴近实际的示例:

python
from crewai import Agent
from crewai_tools import SerperDevTool, FileReadTool, CodeInterpreterTool

# A fully-equipped research agent
researcher = Agent(
    role="Senior Research Analyst",
    goal="Produce comprehensive market analysis reports",
    backstory="Expert analyst with deep industry knowledge",

    # ACTION: What the agent can DO
    tools=[
        SerperDevTool(),         # Search the web
        FileReadTool(),          # Read local files
        CodeInterpreterTool(),   # Run Python code for analysis
    ],
    mcps=["https://data-api.example.com/sse"],  # Access remote data API
    apps=["google_sheets"],                      # Write to Google Sheets

    # CONTEXT: What the agent KNOWS
    skills=["./skills/research-methodology"],    # How to conduct research
    knowledge_sources=[company_docs],            # Company-specific data
)

对比表

功能工具MCP应用技能知识
赋予智能体行动✅✅✅❌❌
修改提示词❌❌❌✅✅
需要代码是仅配置仅配置仅 Markdown仅配置
本地运行是视情况而定是(使用环境变量)不适用是
需要 API 密钥每个工具每个服务器集成 token否仅嵌入器
在智能体上设置tools=[]mcps=[]apps=[]skills=[]knowledge_sources=[]
在团队上设置❌❌❌skills=[]knowledge_sources=[]

深入探讨

准备好进一步了解每种能力类型了吗?

BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。