mcpField
P
PraisonAI

PraisonAI

本地服务
github.com/MervinPraisonAI 与智能体9.3k今天更新

关于 PraisonAI

PraisonAI 是一个 AI Agent 框架,支持自我反思,并提供 MCP 支持。它面向需要构建自主 Agent、多 Agent 团队和工作流的 Python 开发者,核心 SDK 可通过 pip 安装。

主要功能

  1. 01通过 MCP() 接入 stdio、HTTP、WebSocket 和 SSE 工具
  2. 02规划模式,支持规划、执行与推理
  3. 03Agent 之间的交接(handoffs)
  4. 04护栏、审批与钩子机制
  5. 05route、parallel、loop、repeat 等工作流模式
  6. 06可在 Docker、E2B 等沙箱中运行工具

适用场景

  1. 01构建研究、编码与数据处理类的多 Agent 工作流
  2. 02将 Telegram、Discord、Slack 连接为客服 Agent
  3. 03编排 Claude Code、Gemini CLI 等外部 Agent

MCP 相关

该框架通过 MCP() 将 MCP 服务作为工具接入 Agent,支持 stdio、HTTP、WebSocket 和 SSE 等传输方式。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"mervinpraison-praisonai": {
"command": "uvx",
"args": [
"praisonai"
]
}
}
}
启动命令uvx praisonai

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
pypipraisonai2.3.42

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

PraisonAI 徽标

总下载量 最新稳定版本 许可证

PraisonAI 🦞

MervinPraison%2FPraisonAI | Trendshift

PraisonAI 🦞 — 聘请一支全天候工作的 AI 团队。 别再编写样板代码,开始部署能够研究、规划并跨应用执行任务的自主、自我改进 Agent。从单个 Agent 到整个组织,只需 5 行代码即可部署。

curl -fsSL https://praison.ai/install.sh | bash

获 Elon Musk 推荐

下载 macOS 版    下载 Windows 版    下载 Linux 版

PraisonAI 控制面板

 ██████╗ ██████╗  █████╗ ██╗███████╗ ██████╗ ███╗   ██╗     █████╗ ██╗
 ██╔══██╗██╔══██╗██╔══██╗██║██╔════╝██╔═══██╗████╗  ██║    ██╔══██╗██║
 ██████╔╝██████╔╝███████║██║███████╗██║   ██║██╔██╗ ██║    ███████║██║
 ██╔═══╝ ██╔══██╗██╔══██║██║╚════██║██║   ██║██║╚██╗██║    ██╔══██║██║
 ██║     ██║  ██║██║  ██║██║███████║╚██████╔╝██║ ╚████║    ██║  ██║██║
 ╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚══════╝ ╚═════╝ ╚═╝  ╚═══╝    ╚═╝  ╚═╝╚═╝

 pip install praisonai

🎯 使用场景

AI Agent 正在解决各行各业的实际问题:

使用场景描述
🔍 研究与分析自动开展深入研究、收集信息,并从多个来源生成见解
💻 代码生成使用了解代码库和需求的 AI Agent 编写、调试和重构代码
✍️ 内容创作通过多 Agent 团队生成博客文章、文档、营销文案和技术内容
📊 数据管道自动从 API、数据库和网络来源提取、转换和分析数据
🤖 客户支持在 Telegram、Discord、Slack 上部署全天候支持机器人,提供记忆能力和基于知识库的回复
⚙️ 工作流自动化使用能够交接任务、验证结果并自我纠正的 Agent 自动执行多步骤业务流程

🚀 认识你的第一个 Agent(不到 1 分钟)

  1. 安装轻量级核心 SDK:
pip install praisonaiagents
export OPENAI_API_KEY="your-api-key"
  1. 运行你的第一个自主 Agent:
from praisonaiagents import Agent

# Give your agent a goal, and watch it work.
agent = Agent(instructions="You are a senior data analyst.")
agent.start("Analyze the top 3 tech trends of 2026 and format as a markdown table.")

🧬 Agent 五层架构

大多数框架只提供一两层,其余的都留给你自己摸索。PraisonAI 涵盖全部五层,还包括决定 Agent 实际运行位置的外层。

每一层都封装其内层。Agent 出现异常时,对应的层会告诉你该从哪里排查。

┌─────────────────────────────────────────────────────────────────┐
│ ⬡ MANAGED AGENTS — Where does it actually run?                  │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ 5 · GRAPH — Who runs when, and who checks whom?             │ │
│ │ ┌─────────────────────────────────────────────────────────┐ │ │
│ │ │ 4 · LOOP — When do we stop?                             │ │ │
│ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ 3 · HARNESS — Can it act, and be checked?           │ │ │ │
│ │ │ │ ┌─────────────────────────────────────────────────┐ │ │ │ │
│ │ │ │ │ 2 · CONTEXT — Is the right thing in the window? │ │ │ │ │
│ │ │ │ │ ┌─────────────────────────────────────────────┐ │ │ │ │ │
│ │ │ │ │ │ 1 · PROMPT — Did I say it clearly?          │ │ │ │ │ │
│ │ │ │ │ └─────────────────────────────────────────────┘ │ │ │ │ │
│ │ │ │ └─────────────────────────────────────────────────┘ │ │ │ │
│ │ │ └─────────────────────────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
层回答的问题PraisonAI
1 · 提示词我说清楚了吗?instructions=、role/goal/backstory、output=、templates=
2 · 上下文窗口里有正确的内容吗?memory=、knowledge=、context=、交接 ContextPolicy
3 · 执行环境它能采取行动并接受检查吗?tools=、MCP()、guardrails=、approval=、hooks=、sandbox=
4 · 循环何时停止?execution=ExecutionConfig(...)、reflection=、autonomy=、死循环检测
5 · 图谁在何时运行,谁检查谁?AgentFlow、route()、parallel()、loop()、repeat()
⬡ 托管它实际运行在哪里?tools_run_on="docker" —— 工具共用一个沙盒;或者用 run_on="anthropic" 运行整个 Agent
第 1 层 · 提示词 —— 我说清楚了吗?

角色、指令、示例、输出格式。

from praisonaiagents import Agent

agent = Agent(
    role="Senior Data Analyst",
    goal="Turn raw numbers into decisions",
    output="verbose",              # markdown-formatted output
)
agent.start("Summarise Q3 revenue trends")
第 2 层 · 上下文 —— 窗口里有正确的内容吗?

写入、选择、压缩、隔离——四种上下文操作,各对应一个参数。

from praisonaiagents import Agent

agent = Agent(
    instructions="You are a support engineer.",
    memory={"user_id": "u-42"},    # write    — persists across runs (needs a user_id)
    knowledge=["docs/"],           # select   — retrieves only what's relevant
    context="summarize",           # compress — auto-compacts before the limit
)

隔离通过 handoffs=[specialist] 实现——子 Agent 会继承最近几条消息以及与你的工具集合的交集,而不是完整的对话记录。📖 交接

第 3 层 · 执行环境 —— 它能采取行动并接受检查吗?

Agent = 模型 + 执行环境。 工具调度,以及行动前引导 Agent 的指南和行动后观察的传感器。

from praisonaiagents import Agent, MCP, tool

@tool
def deploy(env: str) -> str:
    """Deploy the current build to an environment."""
    return f"Deployed to {env}"

agent = Agent(
    name="ReleaseEngineer",
    instructions="You are a release engineer.",
    tools=[deploy, MCP("npx -y @modelcontextprotocol/server-filesystem /tmp")],
    approval=True,                 # guide — human gate before risky tools run
)
agent.start("Deploy to staging, then list the files you can read")
第 4 层 · 循环 —— 何时停止?

明确设置迭代次数上限、预算上限、无进展检测和完成检查——每个制动机制都清晰可见。

from praisonaiagents import Agent, ExecutionConfig

agent = Agent(
    instructions="Fix the failing tests.",
    execution=ExecutionConfig(max_iter=30, max_budget=0.50, on_budget_exceeded="stop"),
    autonomy=True,                 # required to drive the loop with run_autonomous()
)
result = agent.run_autonomous("Refactor the auth module", max_iterations=5)

print(result.completion_reason)
# goal | no_tool_calls | max_iterations | timeout | doom_loop | needs_help | error
# (with on_budget_exceeded="stop", hitting the cap raises BudgetExceededError,
#  surfaced here as completion_reason="error")

死循环检测默认开启。 系统会捕获重复的相同工具调用以及 A→B→A→B 式振荡,但不会误判输出持续变化的轮询器。📖 死循环检测

第 5 层 · 图 —— 谁在何时运行,谁检查谁?

将拓扑作为可版本控制的工件:提示词链、路由、并行化、协调器-工作器模式。

from praisonaiagents import AgentFlow
from praisonaiagents.workflows import route, parallel, repeat

flow = AgentFlow(steps=[
    classifier,
    route({"bug": [bug_agent], "feature": [feature_agent], "default": [triage]}),
    parallel([reviewer, tester]),                      # fan out, join automatically
    repeat(editor, until=lambda ctx: "approved" in ctx.previous_result.lower(),
           max_iterations=3),                          # evaluator–optimizer
])
flow.run("Ticket #123: login fails on Safari")

同一张图也可以用 YAML 表达,完全不需要 Python。📖 AgentFlow

⬡ 跳出技术栈:托管 Agent — 它究竟在哪里运行?

执行框架正日趋商品化;Agent 在哪里运行,将成为下一个倍增器。与其消耗笔记本电脑的 CPU,不如为 Agent 提供一个短期云沙箱 — 代码库、工具和测试都在其中运行。

pip install praisonai

最简单的入门方式是 tools_run_on= — 整个团队或工作流共享一个沙箱,因此步骤 1 写入的文件在步骤 2 中仍然可用。思考过程仍在你的机器上进行:

from praisonaiagents import Agent, AgentFlow

writer = Agent(name="Writer", instructions="You write files.")
reader = Agent(name="Reader", instructions="You read files.")

flow = AgentFlow(tools_run_on="docker", steps=[writer, reader])  # or e2b | modal | daytona | flyio
flow.run("Write 'hello' to /workspace/note.txt, then read it back")

不使用 Python 也可以做到同样的事:

name: remote-demo
tools_run_on: docker      # every step shares one sandbox
agents:
  writer: {role: Writer, goal: Write files}
  reader: {role: Reader, goal: Read files}
steps:
  - agent: writer
    action: "Write 'hello' to /workspace/note.txt"
  - agent: reader
    action: "Read /workspace/note.txt"

对于单个 Agent,两个词就够了 — 它们回答的是不同的问题:

from praisonaiagents import Agent

# A. Only the TOOLS move. Thinking stays on your machine.
agent = Agent(name="builder", instructions="You build things.",
              tools_run_on="docker")   # docker | e2b | modal | daytona | flyio
                                       # tenki | sandlock | ssh | novita | subprocess

# B. The WHOLE agent moves — model calls, loop and tools
agent = Agent(name="teacher", instructions="You teach.", run_on="anthropic")  # hosted
agent = Agent(name="builder", instructions="You build.", run_on="docker")     # self-hosted
agent.start("Write a Python script that prints the first 10 primes, then run it")

询问任意对象它在哪里运行,它都会告诉你:

>>> Agent(name="builder", instructions="x", tools_run_on="docker")
Agent(name='builder', thinks_on='this machine', tools_run_on='a Docker container')

>>> agent.where_does_it_run()
Thinking (the AI model calls) happens on this machine.
Tools run on a Docker container.
Your own tools (check_db) still run on this machine -- only shell, file and
code tools move. They read and write this machine's files.

指定一个无法胜任任务的位置属于拼写错误,而非个人偏好,因此它会明确指出:

>>> Agent(name="x", instructions="i", run_on="e2b")
TypeError: Agent(run_on='e2b') is not valid: run_on= places the whole agent
-- model calls, loop and tools -- on a managed runtime, and 'e2b' runs
commands but cannot host an agent loop.
  To run only the tools there:  Agent(tools_run_on='e2b')

要在其他位置运行一段代码,只需在调用时指定位置:

agent.execute_code_sync("print(6 * 7)", run_in="sandlock")   # kernel-enforced

查看正在运行的内容并回收闲置资源:

praisonai managed ps          # list running sandboxes
praisonai managed stop --all  # reclaim them

沙箱会在闲置时自动关闭(auto_shutdown、idle_timeout_s),并重复使用设置完成后的快照,因此下次运行时会跳过镜像拉取和依赖安装。提交 .praisonai/environment.yaml 后,环境便会随代码库一起保存。

📖 20 个可运行示例 · 使用 praisonai managed sessions list <agent-id> 或 praisonai managed sessions resume <session-id> "<prompt>" 管理会话

技术栈的阐述方式改编自 Agent 五层技术栈 和 Agent 执行框架与 Orbs。


🌌 PraisonAI 生态系统

从核心 SDK 轻松入门,准备好后再扩展到完整的可视化构建器和仪表板。

  • 核心 SDK(praisonaiagents):适用于纯 Python 开发。pip install praisonaiagents
  • 💻 PraisonAI CLI(praisonai):适用于基于终端的开发者。pip install praisonai
  • 🦞 Claw 仪表板:将 Agent 直接连接到 Telegram、Slack 或 Discord。pip install "praisonai[claw]"
  • 🔗 Flow 可视化构建器:通过拖放创建工作流。pip install "praisonai[flow]"
  • 🤖 PraisonAI UI:简洁的聊天界面。pip install "praisonai[ui]"
JavaScript SDK
npm install praisonai

🧠 支持的提供商与功能

由 100 多种大模型提供支持(OpenAI、Anthropic、Gemini 和本地模型)。

OpenAI Anthropic Google Gemini DeepSeek Azure Ollama Groq Mistral Cerebras Cohere OpenRouter Perplexity Fireworks AWS Bedrock xAI Grok Vertex AI HuggingFace Together AI Databricks Replicate Cloudflare

View all 24 providers with examples
提供商示例
OpenAI示例
Anthropic示例
Google Gemini示例
Ollama示例
Groq示例
DeepSeek示例
xAI Grok示例
Mistral示例
Cohere示例
Perplexity示例
Fireworks示例
Together AI示例
OpenRouter示例
HuggingFace示例
Azure OpenAI示例
AWS Bedrock示例
Google Vertex示例
Databricks示例
Cloudflare示例
AI21示例
Replicate示例
SageMaker示例
Moonshot示例
vLLM示例
埃隆·马斯克推荐

“Grok 3 客户支持”——埃隆·马斯克引用 PraisonAI 的教程



🌟 为什么选择 PraisonAI?

功能使用方式
🔌MCP 协议 — stdio、HTTP、WebSocket、SSEtools=MCP("npx ...")
🧠规划模式 — 规划 → 执行 → 推理planning=True
🔍深度研究 — 多步骤自主研究文档
🤖外部 Agent — 编排 Claude Code、Gemini CLI、Codex文档
🔄Agent 交接 — 无缝传递对话handoffs=[other_agent]
🛡️防护措施 — 输入/输出验证文档
网页搜索 + 抓取 — 原生浏览web=True
🪞自我反思 — Agent 审查自身输出文档
🔀工作流模式 — 路由、并行、循环、重复文档
🧠记忆(零依赖) — 开箱即用memory=True
查看全部 25 项功能
功能使用方式
💡提示词缓存 — 降低延迟和成本caching=True
💾会话 + 自动保存 — 重启后状态依然持久auto_save="my-project"
💭思考预算 — 控制推理深度agent.thinking_budget = 1024
📚RAG + 基于质量的 RAG — 自动进行质量评分检索文档
📊模型路由器 — 自动路由至能力满足要求且成本最低的模型文档
🧊Shadow Git 检查点 — 失败时自动回滚文档
📡A2A 协议 — Agent 间互操作文档
📏上下文压缩 — 永不触及令牌上限文档
📡遥测 — OpenTelemetry 跟踪、跨度和指标文档
📜策略引擎 — 以声明式方式控制 Agent 行为文档
🔄后台任务 — 即发即弃的 Agent文档
🔁死循环检测 — 自动恢复卡住的 Agent文档
🕸️图记忆 — 类似 Neo4j 的关系跟踪文档
🏖️沙箱执行 — 隔离执行代码文档
🖥️Bot 网关 — 跨渠道的多 Agent 路由文档

📘 使用 Python 代码

不确定结果是错误还是模型随机性导致的?请查看 SDK 行为矩阵,了解 stream、记忆预取、结构化输出、团队和 AG-UI。

1. 单个 Agent
from praisonaiagents import Agent
agent = Agent(instructions="You are a helpful AI assistant")
agent.start("Write a movie script about a robot in Mars")
2. 多个 Agent
from praisonaiagents import Agent, Agents

research_agent = Agent(instructions="Research about AI")
summarise_agent = Agent(instructions="Summarise research agent's findings")
agents = Agents(agents=[research_agent, summarise_agent])
agents.start()
3. MCP(Model Context Protocol)
from praisonaiagents import Agent, MCP

# stdio - Local NPX/Python servers
agent = Agent(tools=MCP("npx @modelcontextprotocol/server-memory"))

# Streamable HTTP - Production servers
agent = Agent(tools=MCP("https://api.example.com/mcp"))

# WebSocket - Real-time bidirectional
agent = Agent(tools=MCP("wss://api.example.com/mcp", auth_token="token"))

# With environment variables
agent = Agent(
    tools=MCP(
        command="npx",
        args=["-y", "@modelcontextprotocol/server-brave-search"],
        env={"BRAVE_API_KEY": "your-key"}
    )
)

📖 完整 MCP 文档 — stdio、HTTP、WebSocket、SSE 传输方式

4. 自定义工具
from praisonaiagents import Agent, tool

@tool
def search(query: str) -> str:
    """Search the web for information."""
    return f"Results for: {query}"

@tool
def calculate(expression: str) -> float:
    """Safely evaluate a numeric arithmetic expression."""
    import ast
    import operator
    
    # Define allowed operations
    _OPS = {
        ast.Add: operator.add,
        ast.Sub: operator.sub,
        ast.Mult: operator.mul,
        ast.Div: operator.truediv,
        ast.Pow: operator.pow,
        ast.USub: operator.neg,
        ast.UAdd: operator.pos,
    }
    
    def _safe_eval(node):
        if isinstance(node, ast.Constant) and isinstance(node.value, (int, float)):
            return node.value
        elif isinstance(node, ast.BinOp) and type(node.op) in _OPS:
            return _OPS[type(node.op)](_safe_eval(node.left), _safe_eval(node.right))
        elif isinstance(node, ast.UnaryOp) and type(node.op) in _OPS:
            return _OPS[type(node.op)](_safe_eval(node.operand))
        else:
            raise ValueError("Unsupported expression")
    
    try:
        return _safe_eval(ast.parse(expression, mode="eval").body)
    except (ValueError, SyntaxError, TypeError, ZeroDivisionError, OverflowError):
        raise ValueError("Invalid arithmetic expression")

agent = Agent(
    instructions="You are a helpful assistant",
    tools=[search, calculate]
)
agent.start("Search for AI news and calculate 15*4")

⚠️ **安全提示:**切勿在处理大模型生成或用户提供输入的工具函数中使用 eval()、exec() 或 subprocess。务必验证并清理输入,以防止代码注入攻击。 📖 完整工具文档 — BaseTool、工具包、100 多种内置工具

5. 持久化(数据库)
from praisonaiagents import Agent, db

agent = Agent(
    name="Assistant",
    memory={
        "db": db(database_url="postgresql://localhost/mydb"),
        "session_id": "my-session",
    },
)
agent.chat("Hello!")  # Auto-persists messages, runs, traces

📖 完整持久化文档 — PostgreSQL、MySQL、SQLite、MongoDB、Redis 等 20 多种数据库

6. PraisonAI Claw 🦞(仪表板 UI)

通过一条命令,将你的 AI Agent 连接到 Telegram、Discord、Slack、WhatsApp 等平台。

pip install "praisonai[claw]"
praisonai claw
必需的环境变量

将 .env.example 复制为 .env,并配置以下变量:

变量必需描述
OPENAI_API_KEY是用于所有大模型调用的 OpenAI API 密钥
TAVILY_API_KEY是(Claw)内置网页搜索工具所需的 Tavily 密钥。可在 https://app.tavily.com 免费获取

打开 http://localhost:8082 — 仪表板内置 13 个页面:聊天、Agent、记忆、知识库、频道、护栏、Cron 等。可直接在 UI 中添加消息频道。

📖 Claw 完整文档 — 平台令牌、CLI 选项、Docker 和 YAML Agent 模式

7. Langflow 集成 🔗(可视化流程构建器)

在 Langflow 中使用拖放式组件,以可视化方式构建多 Agent 工作流。

pip install "praisonai[flow]"
praisonai flow

打开 http://localhost:7861 — 使用 Agent 和 Agent Team 组件创建顺序或并行工作流。连接 Chat Input → Agent Team → Chat Output,即可快速搭建多 Agent 流水线。

📖 完整流程文档 — 可视化 Agent 构建、组件参考和部署

8. PraisonAI UI 🤖(简洁聊天)

为你的 AI Agent 提供轻量级聊天界面。

pip install "praisonai[ui]"
praisonai ui

📄 使用 YAML(无需代码)

示例 1:两个 Agent 协同工作

创建 agents.yaml:

framework: praisonai
topic: "Write a blog post about AI"

agents:
  researcher:
    role: Research Analyst
    goal: Research AI trends and gather information
    instructions: "Find accurate information about AI trends"
    
  writer:
    role: Content Writer
    goal: Write engaging blog posts
    instructions: "Write clear, engaging content based on research"

运行命令:

praisonai agents.yaml

Agent 会自动按顺序协同工作

示例 2:带自定义工具的 Agent

在同一文件夹中创建两个文件:

agents.yaml:

framework: praisonai
topic: "Calculate the sum of 25 and 15"

agents:
  calculator_agent:
    role: Calculator
    goal: Perform calculations
    instructions: "Use the add_numbers tool to help with calculations"
    tools:
      - add_numbers

tools.py:

def add_numbers(a: float, b: float) -> float:
    """
    Add two numbers together.
    
    Args:
        a: First number
        b: Second number
    
    Returns:
        The sum of a and b
    """
    return a + b

运行命令:

praisonai agents.yaml

💡 提示:

  • 在工具列表中使用函数名(例如 add_numbers),不要使用文件名
  • 系统会自动发现 tools.py 中的工具
  • 函数的文档字符串有助于 AI 理解如何使用该工具

🎯 CLI 快速参考

类别命令
执行praisonai、--auto、--interactive、--chat
研究research、--query-rewrite、--deep-research
规划--planning、--planning-tools、--planning-reasoning
工作流workflow run、workflow list、workflow auto
记忆memory show、memory add、memory search、memory clear
知识库knowledge add、knowledge query、knowledge list
会话session list、session resume、session delete
工具tools list、tools info、tools search
MCPmcp list、mcp create、mcp enable
开发commit、docs、checkpoint、hooks
调度schedule start、schedule list、schedule stop

📖 CLI 完整参考


✨ 主要功能

🤖 核心 Agent
功能代码文档
单个 Agent示例📖
多 Agent示例📖
自动 Agent示例📖
自我反思 AI Agent示例📖
推理 AI Agent示例📖
多模态 AI Agent示例📖
🔄 工作流 | 功能 | 代码 | 文档 | |---------|:----:|:----:| | 简单工作流 | [示例](examples/python/workflows/simple_workflow.py) | [📖](https://docs.praison.ai/docs/concepts/agentflow) | | 带 Agent 的工作流 | [示例](examples/python/workflows/workflow_with_agents.py) | [📖](https://docs.praison.ai/docs/concepts/agentflow) | | Agent 路由(`route()`) | [示例](examples/python/workflows/workflow_routing.py) | [📖](https://docs.praison.ai/docs/features/routing) | | 并行执行(`parallel()`) | [示例](examples/python/workflows/workflow_parallel.py) | [📖](https://docs.praison.ai/docs/features/parallelisation) | | 遍历列表/CSV(`loop()`) | [示例](examples/python/workflows/workflow_loop_csv.py) | [📖](https://docs.praison.ai/docs/features/repetitive) | | 评估器-优化器(`repeat()`) | [示例](examples/python/workflows/workflow_repeat.py) | [📖](https://docs.praison.ai/docs/concepts/evaluation) | | 条件步骤 | [示例](examples/python/workflows/workflow_conditional.py) | [📖](https://docs.praison.ai/docs/concepts/agentflow) | | 工作流分支 | [示例](examples/python/workflows/workflow_branching.py) | [📖](https://docs.praison.ai/docs/concepts/agentflow) | | 工作流提前停止 | [示例](examples/python/workflows/workflow_early_stop.py) | [📖](https://docs.praison.ai/docs/concepts/agentflow) | | 工作流检查点 | [示例](examples/python/workflows/workflow_checkpoints.py) | [📖](https://docs.praison.ai/docs/concepts/agentflow) |
💻 代码与开发
功能代码文档
代码解释器 Agent示例📖
AI 代码编辑工具示例📖
外部 Agent(全部)示例📖
Claude Code CLI示例📖
Gemini CLI示例📖
Codex CLI示例📖
Cursor CLI示例📖
🧠 记忆与知识 | 功能 | 代码 | 文档 | |---------|:----:|:----:| | 记忆(短期和长期) | [示例](examples/python/general/memory_example.py) | [📖](https://docs.praison.ai/docs/concepts/memory) | | 基于文件的记忆 | [示例](examples/python/general/memory_example.py) | [📖](https://docs.praison.ai/docs/concepts/memory) | | Claude 记忆工具 | [示例](examples/python/memory/claude_memory_example.py) | [📖](https://docs.praison.ai/docs/features/claude-memory-tool) | | 添加自定义知识 | [示例](examples/python/concepts/knowledge-agents.py) | [📖](https://docs.praison.ai/docs/concepts/knowledge) | | RAG Agent | [示例](examples/python/concepts/rag-agents.py) | [📖](https://docs.praison.ai/docs/concepts/rag) | | 与 PDF 对话的 Agent | [示例](examples/python/concepts/chat-with-pdf.py) | [📖](https://docs.praison.ai/docs/features/chat-with-pdf) | | 数据读取器(PDF、DOCX 等) | [CLI](https://docs.praison.ai/docs/cli/knowledge) | [📖](https://docs.praison.ai/docs/features/chunking-strategies) | | 向量存储选择 | [CLI](https://docs.praison.ai/docs/cli/knowledge) | [📖](https://docs.praison.ai/docs/features/knowledge-backends) | | 检索策略 | [CLI](https://docs.praison.ai/docs/cli/knowledge) | [📖](https://docs.praison.ai/docs/features/retrieval-strategies) | | 重排器 | [CLI](https://docs.praison.ai/docs/cli/knowledge) | [📖](https://docs.praison.ai/docs/features/smart-retrieval) | | 索引类型(向量/关键词/混合) | [CLI](https://docs.praison.ai/docs/cli/knowledge) | [📖](https://docs.praison.ai/docs/features/incremental-indexing) | | 查询引擎(子问题等) | [CLI](https://docs.praison.ai/docs/cli/knowledge) | [📖](https://docs.praison.ai/docs/features/retrieval) |
🔬 研究与情报
功能代码文档
深度研究 Agent示例📖
查询改写 Agent示例📖
原生网页搜索示例📖
内置搜索工具示例📖
统一网页搜索示例📖
网页抓取(Anthropic)示例📖
📋 规划与执行
功能代码文档
规划模式示例📖
规划工具示例📖
规划推理示例📖
提示词链示例📖
评估器优化器示例📖
编排器工作者示例📖
👥 专业 Agent | 功能 | 代码 | 文档 | |---------|:----:|:----:| | 数据分析 Agent | [示例](examples/python/agents/data-analyst-agent.py) | [📖](https://docs.praison.ai/docs/agents/data-analyst) | | 金融 Agent | [示例](examples/python/agents/finance-agent.py) | [📖](https://docs.praison.ai/docs/agents/finance) | | 购物 Agent | [示例](examples/python/agents/shopping-agent.py) | [📖](https://docs.praison.ai/docs/agents/shopping) | | 推荐 Agent | [示例](examples/python/agents/recommendation-agent.py) | [📖](https://docs.praison.ai/docs/agents/recommendation) | | Wikipedia Agent | [示例](examples/python/agents/wikipedia-agent.py) | [📖](https://docs.praison.ai/docs/agents/wikipedia) | | 编程 Agent | [示例](examples/python/agents/programming-agent.py) | [📖](https://docs.praison.ai/docs/agents/programming) | | 数学 Agent | [示例](examples/python/agents/math-agent.py) | [📖](https://docs.praison.ai/docs/features/mathagent) | | Markdown Agent | [示例](examples/python/agents/markdown-agent.py) | [📖](https://docs.praison.ai/docs/agents/markdown) | | 提示词扩展 Agent | [示例](examples/python/agents/prompt-expander-agent.py) | [📖](https://docs.praison.ai/docs/agents/prompt-expander) |
🎨 媒体与多模态
功能代码文档
图像生成 Agent示例📖
图像转文本 Agent示例📖
视频 Agent示例📖
摄像头集成示例📖
🔌 协议与集成
功能代码文档
MCP 传输方式示例📖
WebSocket MCP示例📖
MCP 安全性示例📖
MCP 可恢复性示例📖
MCP 配置管理文档📖
集成 LangChain 的 Agent示例📖
🛡️ 安全与控制
功能代码文档
护栏示例📖
人工审批示例📖
规则与指令文档📖
⚙️ 高级功能 | Feature | Code | Docs | |---------|:----:|:----:| | Async & Parallel Processing | [Example](examples/python/general/async_example.py) | [📖](https://docs.praison.ai/docs/features/async) | | Parallelisation | [Example](examples/python/general/parallelisation.py) | [📖](https://docs.praison.ai/docs/features/parallelisation) | | Repetitive Agents | [Example](examples/python/concepts/repetitive-agents.py) | [📖](https://docs.praison.ai/docs/features/repetitive) | | Agent Handoffs | [Example](examples/python/handoff/handoff_basic.py) | [📖](https://docs.praison.ai/docs/concepts/handoffs) | | Stateful Agents | [Example](examples/python/stateful/workflow-state-example.py) | [📖](https://docs.praison.ai/docs/features/stateful-agents) | | Autonomous Workflow | [Example](examples/python/general/autonomous-agent.py) | [📖](https://docs.praison.ai/docs/concepts/autonomy) | | Structured Output Agents | [Example](examples/python/general/structured_agents_example.py) | [📖](https://docs.praison.ai/docs/features/structured) | | Model Router | [Example](examples/python/agents/router-agent-cost-optimization.py) | [📖](https://docs.praison.ai/docs/features/model-router) | | Prompt Caching | [Example](examples/python/agents/prompt-caching-agent.py) | [📖](https://docs.praison.ai/docs/features/model-capabilities) | | Fast Context | [Example](examples/context/00_agent_fast_context_basic.py) | [📖](https://docs.praison.ai/docs/features/fast-context) |
🛠️ Tools & Configuration
FeatureCodeDocs
100+ Custom ToolsExample📖
YAML ConfigurationExample📖
100+ LLM SupportExample📖
Callback AgentsExample📖
HooksExample📖
Middleware SystemExample📖
Configurable ModelExample📖
Rate LimiterExample📖
Injected Tool StateExample📖
Shadow Git CheckpointsExample📖
Background TasksExample📖
Policy EngineExample📖
Thinking BudgetsExample📖
Output StylesExample📖
Context CompactionExample📖
📊 Monitoring & Management
FeatureCodeDocs
Sessions ManagementExample📖
Auto-Save SessionsDocs📖
History in ContextDocs📖
TelemetryExample📖
Langfuse TracingDocs📖
Project Docs (.praison/docs/)Docs📖
AI Commit MessagesDocs📖
@Mentions in PromptsDocs📖
🖥️ CLI Features
FeatureCodeDocs
Slash CommandsExample📖
Autonomy ModesExample📖
Cost TrackingExample📖
Repository MapExample📖
Interactive TUIExample📖
Git IntegrationExample📖
Sandbox ExecutionExample📖
CLI CompareExample📖
Profile/BenchmarkDocs📖
Auto ModeDocs📖
InitDocs📖
File InputDocs📖
Final AgentDocs📖
Max TokensDocs📖
🧪 Evaluation
FeatureCodeDocs
Accuracy EvaluationExample📖
Performance EvaluationExample📖
Reliability EvaluationExample📖
Criteria EvaluationExample📖
🎯 Agent Skills
FeatureCodeDocs
Skills ManagementExample📖
Custom SkillsExample📖
⏰ 24/7 调度
功能代码文档
Agent 调度器示例📖

💻 使用 JavaScript 代码

npm install praisonai
export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxx
const { Agent } = require('praisonai');
const agent = new Agent({ instructions: 'You are a helpful AI assistant' });
agent.start('Write a movie script about a robot in Mars');

⚡ 性能

PraisonAI 将框架开销控制在微秒级:在我们 2026-10-15 的测试中,创建一个 Agent(一个工具,不调用大模型)的平均耗时为 46 μs,因此在多 Agent 工作负载中,与模型延迟相比,每个 Agent 的初始化开销可以忽略不计。

性能指标PraisonAI测量结果
平均 Agent 实例化耗时(1 个工具,1000 次迭代)46 μs2026-10-15 · praisonaiagents 1.7.12

方法、比较结果和复现方式:benchmarks/BENCHMARK_RESULTS.md · 文档



⭐ Star 历史

Star 历史图表


PraisonAI AgentFlow

PraisonAI 命令执行

* export TAVILY_API_KEY=xxxxx

🔍 Langfuse 追踪

pip install "praisonai[langfuse]"
praisonai langfuse

PraisonAI Langfuse 追踪


🎓 视频教程

通过我们全面的视频系列了解 PraisonAI:

查看全部 22 个视频教程
主题视频
具备自我反思能力的 AI Agent自我反思
推理数据生成 Agent推理数据
具备推理能力的 AI Agent推理
多模态 AI Agent多模态
AI Agent 工作流工作流
异步 AI Agent异步
迷你 AI Agent迷你
具备记忆功能的 AI Agent记忆
重复执行型 Agent重复执行
简介简介
工具概览工具概览
自定义工具自定义工具
Firecrawl 集成Firecrawl
用户界面UI
Crawl4AI 集成Crawl4AI
聊天界面聊天
代码界面代码
Mem0 集成Mem0
训练训练
实时语音界面实时
通话界面通话
推理提取 Agent推理提取

👥 参与贡献

欢迎贡献!Fork 此仓库,创建分支并提交 PR → 贡献指南。


❓ 常见问题与故障排查

ModuleNotFoundError: No module named 'praisonaiagents'

安装软件包:

pip install praisonaiagents
未找到 API 密钥 / 身份验证错误

请确保已设置 API 密钥:

export OPENAI_API_KEY=your_key_here

其他提供商请参阅 Models 文档。

如何使用本地模型(Ollama)?
# Start Ollama and pull a model
ollama serve
ollama pull llama3.2
from praisonaiagents import Agent

agent = Agent(instructions="You are a helpful assistant", llm="ollama/llama3.2")
agent.start("Why is the sky blue?")

ollama/ 前缀用于选择 Ollama 的处理方式,包括工具调用修复、工具结果格式化,以及小型本地模型所需的流式传输规则。也可以通过环境变量设置:

export OPENAI_MODEL_NAME=ollama/llama3.2

仅设置 OPENAI_BASE_URL 并不足够:如果没有指定模型名称,OpenAI 默认模型(gpt-4o-mini)会被发送给 Ollama,后者会返回 404 model 'gpt-4o-mini' not found。请务必指定模型名称。

使用 base_url= 或 OLLAMA_HOST 指向非默认主机:

agent = Agent(instructions="...", llm="ollama/llama3.2", base_url="http://192.168.1.10:11434")

其他本地运行时也可以使用相同的格式,例如 lm_studio/、vllm/ 和 hosted_vllm/,并搭配其服务端的 base_url。

更多详情请参阅 Models 文档。

如何将对话持久化到数据库?

使用 db 参数:

from praisonaiagents import Agent, db

agent = Agent(
    name="Assistant",
    memory={
        "db": db(database_url="postgresql://localhost/mydb"),
        "session_id": "my-session",
    },
)

支持的数据库请参阅 Persistence 文档。

如何启用 Agent 记忆?
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    # Enables file-based memory (no extra deps!)
    memory={"user_id": "user123"},
)

更多选项请参阅 Memory 文档。

如何让多个 Agent 协同运行?
from praisonaiagents import Agent, Agents

agent1 = Agent(instructions="Research topics")
agent2 = Agent(instructions="Summarize findings")
agents = Agents(agents=[agent1, agent2])
agents.start()

更多示例请参阅 Agents 文档。

如何使用 MCP 工具?
from praisonaiagents import Agent, MCP

agent = Agent(
    tools=MCP("npx @modelcontextprotocol/server-memory")
)

所有传输选项请参阅 MCP 文档。

获取帮助

由 PraisonAI 团队倾情打造 ❤️

📚 文档 • GitHub • ▶️ YouTube • 𝕏 X • 💼 LinkedIn

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。