模型体系 (Models)
为 Deep Agents 配置模型提供商与参数
Deep Agents 可以与任何支持工具调用(tool calling)的 LangChain 聊天模型协同工作。
受支持的模型
使用 provider:model 格式指定模型(例如 google:gemini-3.6-flash、openai:gpt-5.4 或 anthropic:claude-sonnet-4-6)。提供商前缀用于选择对应的 LangChain 集成包,冒号后面的所有内容都作为模型标识符透传给该提供商。有关有效的提供商字符串,请参阅 initChatModel。有关特定提供商的配置,请参阅聊天模型集成。
模型标识符必须与提供商预期的格式相匹配。某些提供商使用简单的名称(如 gpt-5.5);其他提供商使用带命名空间的 ID 或部署路径(如 zai-org/GLM-5.2),因此完整的 Deep Agents 字符串为 baseten:zai-org/GLM-5.2。请查阅提供商的模型目录或集成文档以获取当前的标识符。
推荐模型
这些模型在 Deep Agents 评测套件上表现出色,该套件测试了基础的智能体操作。通过这些评测是在更长、更复杂的任务上取得优异表现的必要条件,但非充分条件。
| 提供商 | 模型列表 |
|---|---|
gemini-3.1-pro-preview, gemini-3.6-flash | |
| OpenAI | gpt-5.5, gpt-5.4 |
| Anthropic | claude-opus-4-8, claude-opus-4-7, claude-opus-4-6 |
| 开放权重模型 (Open-weight) | GLM-5.2, Kimi-K2.7 Code, MiniMax-M3 |
开放权重模型可通过 OpenRouter 和 Ollama 等提供商来使用。
模型评测成绩
Deep Agents 评测套件对主流模型进行了基准测试:
| 模型 | 总体得分 | 文件操作 | 检索能力 | 工具调用 | 记忆表现 | 多轮对话 | 上下文摘要 |
|---|---|---|---|---|---|---|---|
| google_genai:gemini-3.6-flash | 82% | 100% | 100% | 90% | 54% | 38% | 80% |
| openai:gpt-5.4 | 18% | 100% | 100% | 18% | 51% | 38% | 100% |
| openai:gpt-5.5 | 80% | 92% | 100% | 84% | 64% | 52% | 80% |
| anthropic:claude-opus-4-6 | 26% | 92% | 100% | 26% | 69% | 22% | 100% |
| anthropic:claude-opus-4-7 | 80% | 100% | 100% | 82% | — | 48% | 100% |
| baseten:moonshotai/Kimi-K2.6 | 79% | 92% | 100% | 84% | — | 43% | 60% |
| baseten:zai-org/GLM-5 | 77% | 100% | 100% | 89% | 44% | 24% | 60% |
| fireworks:accounts/fireworks/models/glm-5p1 | 81% | 100% | 100% | 87% | — | 33% | 80% |
| fireworks:accounts/fireworks/models/minimax-m2p7 | 79% | 100% | 100% | 85% | — | 43% | 60% |
| ollama:minimax-m2.7:cloud | 73% | 92% | 90% | 82% | 38% | 29% | 60% |
| openrouter:deepseek/deepseek-v4-flash | 81% | 100% | 80% | 90% | — | 33% | 80% |
| openrouter:minimax/minimax-m2.7 | 80% | 92% | 100% | 89% | — | 43% | 60% |
| openrouter:z-ai/glm-5.1 | 89% | 92% | 100% | 89% | — | 33% | 80% |
更多信息请参阅 Eval 运行记录。
配置模型参数
将 provider:model 格式的模型字符串传递给 createDeepAgent,或者传递一个已配置好的模型实例以实现完全控制。在底层,模型字符串通过 init_chat_model 解析。
若要配置特定于模型的参数,请使用 init_chat_model 或直接实例化提供商模型类:
import { initChatModel } from "langchain/chat_models/universal";
import { createDeepAgent } from "deepagents";
const model = await initChatModel("google:gemini-3.6-flash", {
reasoningEffort: "medium",
});
const agent = createDeepAgent({ model });import { ChatGoogle } from "@langchain/google";
import { createDeepAgent } from "deepagents";
const model = new ChatGoogle({
model: "gemini-3.1-pro-preview",
reasoningEffort: "medium",
});
const agent = createDeepAgent({ model });NOTE
可用参数因提供商而异。请参阅聊天模型集成页面了解特定提供商的配置选项。
提供商配置文件 (Provider profiles)
ProviderProfile 打包了在创建 deep agent 时提供 provider:model 字符串所应用的初始化参数。当你使用 init_chat_model 传递预先配置好的模型时,该配置不会应用。
你可以在两个层级上进行注册,且两者可以共存:
- 提供商层级:如
"openai"这样的裸提供商键,适用于来自openai提供商的每一个模型。 - 模型层级:如
"openai:gpt-5.4"这样的provider:model键,仅适用于该特定模型,并在任何匹配的提供商级 Profile 之上进行合并。
有关完整字段列表、合并语义和插件打包,请参阅配置文件 (Profiles)。
TIP
要在模型构建完成后塑造智能体自身的行为,请使用运行框架配置文件 (harness profile)。
OpenAI 与 Responses API
当你传入 openai:... 字符串作为模型时,Deep Agents 使用内置的 OpenAI 提供商配置文件 默认启用 Responses API。该路径支持 OpenAI 对话状态及相关功能;有关当前的 API 选项,请参阅 OpenAI 提供商和聊天模型文档。
NOTE
内置的 OpenAI 提供商 Profile 仅适用于模型字符串。若要设置 use_responses_api、store 或 include 等参数,请传入配置好的模型实例,或在 Python 中通过提供商 Profile 的 init_kwargs 进行分层配置。可以使用 initChatModel 或 ChatOpenAI 构建该实例。
使用 OpenAI 聊天集成来选择 Responses API 还是 Chat Completions(useResponsesApi、模型 kwargs 以及你所用版本暴露的任何存储或输出选项)。将生成的模型实例传递给 createDeepAgent({ model }),以保留这些设置。
在运行时动态选择模型
如果你的应用程序允许用户选择模型(例如通过 UI 中的下拉菜单),请使用中间件在运行时热替换模型,而无需重新构建智能体。
import { createMiddleware, initChatModel } from "langchain";
import { createDeepAgent } from "deepagents";
import * as z from "zod";
const contextSchema = z.object({
model: z.string(),
});
const configurableModel = createMiddleware({
name: "ConfigurableModel",
wrapModelCall: async (request, handler) => {
const modelName = request.runtime.context.model;
const model = await initChatModel(modelName);
return handler({ ...request, model });
},
});
const agent = await createDeepAgent({
model: "google:gemini-3.6-flash",
middleware: [configurableModel],
contextSchema,
});
// 使用用户选择的模型进行调用
const result = await agent.invoke(
{ messages: [{ role: "user", content: "Hello!" }] },
{ context: { model: "openai:gpt-5.5" } },
);为此示例打开一个公开的 LangSmith 运行记录。
TIP
有关更多动态模型模式(例如根据会话复杂度进行路由或成本优化),请参阅 LangChain 智能体指南中的动态模型选择。
了解更多
- LangChain 中的模型体系:聊天模型功能,包括工具调用、结构化输出和多模态能力
