LangChain 发布 Managed Deep Agents v0.9,支持定时任务、按次配置与 Slack 表情回应
What's New in Managed Deep Agents: schedules, per-run configuration, and Slack reactions
LangChain 发布 Managed Deep Agents v0.9,新增 Schedules SDK、按次运行配置和 Slack 表情回应三项能力,已进入 Public Beta。
原文给出调度、按次配置和 Slack 表情三项能力及代码示例,可据此判断内部智能体如何贴近团队工作流。
今天我们发布 Managed Deep Agents v0.9,新增了一些能力,让智能体可以安排自己的后续跟进、在每次运行时重新配置自身,并对 Slack 消息做出反应。
这些更新让你更容易构建驻留在 Slack 或你自己的渠道中、工作方式更像队友的内部智能体。
让智能体安排自己的工作
新的 Schedules SDK 让智能体可以在对话中途创建提醒、后续跟进和周期性任务,从而能够处理诸如“明天提醒我这件事”这样的请求。
智能体在对话过程中自行创建计划,计划以提出请求的人的身份、使用其权限和连接来运行,结果会返回到同一个渠道。
在一次运行中创建计划:
await schedules.create(owner={"type": "user"}, cron="0 9 * * 1-5", timezone="America/Los_Angeles", prompt="Write the daily digest.")它最适合放在工具背后,这样你的智能体用户只需聊天就能创建、列出、更新和删除计划。下面是一个提醒工具:
from langchain.tools import tool
from managed_deepagents import schedules
@tool
async def remind_me(prompt: str, cron: str, timezone: str = "UTC") -> str:
"""Run a prompt for the current user on a cron schedule."""
item = await schedules.create(
owner={"type": "user"},
cron=cron,
timezone=timezone,
prompt=prompt,
)
return f"Created schedule {item['id']}."智能体传入一个提示词和一个 cron 表达式,每次 cron 触发时,LangSmith 都会用该提示词启动一次新的运行。计划会继承其创建时所在的渠道,因此结果会发布回请求来源处:在 Slack 中请求的工作日提醒会在每次运行时向该对话发布一条新消息。一次性计划(使用 at 而非 cron)会在原线程中回复,这适合“一小时后检查这次部署”之类的后续跟进。
按运行配置智能体
智能体现在可以按每次运行动态配置。将智能体设置为一个可调用函数:它在每次运行开始时接收 runtime,并返回一个 define_deep_agent 定义,为该次运行选择模型、指令、技能、MCP 服务器和沙箱。
不必为每个团队或代码仓库维护一个几乎相同的智能体副本,你只需运行一个部署。这使你的部署能够更灵活地运作,单个智能体部署可以根据上下文(例如发起请求的渠道或用户)为不同团队或用例进行定制。

假设一个内部 Slack 智能体服务于多个团队。你的智能体函数可以检查一次运行来自哪个渠道,并为财务加载计费技能,或为平台团队加载事件响应 MCP 服务器。这与用指令告诉模型何时使用某项技能不同:配置在模型运行之前就已设定,因此智能体永远不会看到其配置之外的技能或 MCP 工具。这使其上下文保持精简,同时兼作访问控制,并让你能够选择模型本身,而这是模型自己做不到的。
总的来说,在我们明确知道智能体应该可以使用哪一组工具的情况下,它可以防止模型被赋予选择工具包的任务时产生非确定性输出。
同样的思路也适用于一个编码智能体,它为每个代码仓库加载不同的技能以及更便宜或更强大的模型:
# agent.py: one coding agent, configured per repo at the start of each run
from dataclasses import dataclass
from managed_deepagents import ManagedServerRuntime, define_deep_agent
REPOS = {
"payments-service": {
"model": "openai:gpt-5",
"instructions": "Python service. Run pytest before opening a PR.",
"skills": ["./skills/python-service"],
},
"storefront": {
"model": "openai:gpt-5-mini",
"instructions": "Next.js app. Run web tests and an a11y check before opening a PR.",
"skills": ["./skills/typescript-web"],
},
}
@dataclass
class AppContext:
repository: str = ""
def agent(runtime: ManagedServerRuntime[AppContext]):
execution = runtime.execution_runtime
context = execution.context if execution is not None else None
repo = context.repository if context is not None else None
config = REPOS.get(repo, REPOS["storefront"])
return define_deep_agent(name="open-swe", context_schema=AppContext, **config)
该函数读取 runtime.execution_runtime.context,在没有时回退到默认值,例如在渠道运行时,或当 Agent Server 加载智能体以读取其 schema 时。调用方通过运行的 context 来选择配置:
# Same deployment, different repo: just change the run context
await client.runs.create(
thread_id,
"open-swe",
input={"messages": [{"role": "user", "content": "Fix the flaky refund test."}]},
context={"repository": "payments-service"},
)对 Slack 消息做出反应
Slack 表情回应能让发送者立即看到智能体已收到他们的消息,即便智能体在回复前需要花一段时间进行推理和调用工具。表情回应默认开启(👀),你的 Slack 渠道上新增的 reactions 选项让你可以将其关闭、选择其他 emoji,或为每条消息分别选择。下面这个示例在消息提到某处损坏时使用 🐛,否则使用 👀:
from managed_deepagents import channels
async def choose_emoji(context: dict) -> str:
return "bug" if "broken" in context["text"].lower() else "eyes"
channel = channels.slack(name="Support Bot", reactions=choose_emoji)响应可以很简单。不过,你可以用一个函数来配置你的响应回复,该函数会调用模型来挑选更精确的 emoji。像 Jev 这样的决策模型可以保持快速且低成本;Slack 频道文档中有一个完整的示例。
快速上手
Managed Deep Agents v0.9 现已进入公开测试阶段。你可以在Managed Deep Agents 文档中了解更多,或通过以下方式开始:
uvx --from managed-deepagents mda init my-agent
cd my-agent
uv run mda deploy如果你错过了:v0.8 新增了按用户记忆、可从任何服务触发运行的自定义 HTTP 频道、由 Parallel 提供支持的内置网页搜索等。阅读 v0.8 文章。
来源:LangChain Blog · langchain.com