跳到主要内容

Agent Framework

已经用 agent framework 写好的 Agent 不需要重写就能运行在 Dex 上。Framework adapter 把 Agent 包装成 session Flow,每个 session 对应一个 Flow,并保留 framework 自己的 Agent 定义、tool 和 prompt。

Session 如何运行​

Framework 每个 Step 只调用一次模型。模型请求的每个 tool call 作为独立的 Step 执行,同一轮的 tool call 并行运行。它们完成后,session 带着结果回到模型。

崩溃时只会重跑当时正在执行的那一次调用。整个循环不会重放,所以 framework 代码不需要遵守确定性规则,代码改动会在下一个 Step 生效。

Claude Agent SDK 是例外:它在 CLI 子进程中运行自己的循环,因此它的 adapter 把每一整轮作为一个 Step 执行。

Tool policy 和审批​

每个 tool 都有一个 ToolPolicy,标明它是读操作、幂等写操作,还是只能执行一次的写操作。读操作和幂等写操作会重试,其他写操作只尝试一次,因此重试不会悄悄重复它们。需要审批的 tool call 会在独立的 Step 中等待,直到有人回复,等多久都可以。

安装​

Python adapter 发布在 PyPI:

pip install dex-agents-pydantic-ai "pydantic-ai-slim[openai]"
pip install dex-agents-langgraph
pip install dex-agents-openai-agents
pip install dex-agents-google-adk
pip install dex-agents-claude-agent-sdk

TypeScript adapter 发布在 npm,core 和 Dex SDK 作为 peer package 一起安装:

npm i @superdurable/dex-agents-vercel-ai @superdurable/dex-agents @superdurable/dex ai zod
npm i @superdurable/dex-agents-mastra @superdurable/dex-agents @superdurable/dex @mastra/core zod
npm i @superdurable/dex-agents-openai-agents @superdurable/dex-agents @superdurable/dex @openai/agents zod
npm i @superdurable/dex-agents-claude-agent-sdk @superdurable/dex-agents @superdurable/dex zod

Adapter​

每个 adapter 的 README 都有可运行的示例和选项说明。

Framework语言Adapter
Pydantic AIPythonpydantic-ai
LangChain 和 LangGraphPythonlanggraph
OpenAI Agents SDKPython、TypeScriptPython、TypeScript
Google ADKPythongoogle-adk
Vercel AI SDKTypeScriptvercel-ai
MastraTypeScriptmastra
Claude Agent SDKPython、TypeScriptPython、TypeScript

相关内容​