Harrison Chase 谈智能体的下一步:如何构建长期运行的智能体
原题The Future of Agents with Harrison Chase
推荐理由LangChain 创始人用持续目标和事件触发解释长期智能体,适合对照自家系统的故障恢复、追踪和权限设计。
看前速览
Harrison Chase 讲解如何围绕长期目标与反馈设计智能体,并用可恢复执行、追踪评估和工具权限支撑它。
围绕用户能给的反馈设计目标
Actively AI 把智能体从按账户划分,改成围绕外联等跨账户的目标组织,使一处积累的反馈能用到其他账户。
把运行环境与智能体框架分开
框架让模型能调用工具和管理上下文;外部运行环境负责事件监听、调度、检查点、任务队列和跨客户端恢复。
该不该行动,也要纳入评估
既查看误打扰,也查看错过的机会。线上失败可转成离线回归用例,线上评估则用于发现实际行为退化。
把授权和审批落实到工具调用上
Slack 私聊和公开频道可以允许不同操作;涉及实际后果的工具调用要能按权限拦截、请求批准和记录审计。
把临时观察与长期记忆分开
智能体运行时先记笔记,后台再从笔记、运行追踪和其他来源整理共享知识。
完整摘要
演讲先区分一次性任务与持续追求的目标。Actively AI 的销售案例说明,同一种反馈可以帮助智能体改进多个账户的工作;LangChain 内部的 Slack 应用则展示了私聊与群聊如何使用不同的权限。Chase 进一步拆解模型、运行框架和业务上下文,解释外部运行环境如何安排调度、处理新消息及恢复任务。他也讲到如何把线上失败变成回归用例、遮蔽敏感追踪数据,并在工具和模型网关设置权限与审批。问答部分讨论了支付的审计日志,以及记忆是即时更新还是交给后台整理。
章节
文字稿
简要描述Brief Description
Harrison Chase 解释了持久化智能体如何从一次性任务转向持续性目标。LangChain 网络研讨会涵盖反馈、运行框架、持久化运行时、基于追踪的评估、策略控制和记忆维护,并结合 LangSmith 示例及观众提问展开讨论。Harrison Chase explains how persistent agents move from one-off tasks to ongoing goals. The LangChain webinar covers feedback, harnesses, durable runtime, trace-based evaluation, policy controls and memory maintenance, with examples from LangSmith and audience questions.
目录Table of Contents
- LangSmith 简介The LangSmith introduction
- 是什么让智能体能够持续运行What makes an agent persistent
- 模型、测试框架和应用上下文Models, harnesses and application context
- 设计目标、日程安排和记忆Designing goals, schedules and memory
- 测试框架周边的运行时The runtime around the harness
- 观察与管理行为Observing and governing behavior
- 用于运行和改进智能体的 LangSmith 工具LangSmith’s tools for running and improving agents
- 追踪隐私、编码指标与工具权限Trace privacy, coding metrics and tool permissions
- 观众提问:使用场景、权限与记忆Audience questions: use cases, permissions and memory
LangSmith 简介The LangSmith introduction
开场视频:过去 3 年,数百万开发者使用 LangChain 框架构建智能体。今天,我们将所学的一切整合到一个平台中——全新的 LangSmith。如今,人人都在构建智能体,但只有少数智能体正在改变企业。真正做到这一点的智能体,主动性强、专注于特定领域,而且会不断进步。构建这类智能体的唯一方法,就是持续迭代:看看它们做了什么,衡量效果,修正问题,然后再次发布。如今,这些步骤分散在多个并非为智能体而打造的工具中。这正是 LangSmith 发挥作用的地方。LangSmith 专为智能体打造,并由智能体驱动,支持智能体开发的整个生命周期。因此,你可以构建、运行、改进并治理每一个智能体。下面来看看它是如何运作的。Opening video: Over the past 3 years, millions of developers have used LangChain frameworks to build agents. And today, we're putting everything we've learned into one platform, the new LangSmith. Right now, everyone is building agents, but only a handful of them are transforming businesses. Those that do are proactive, specialized, and they get better over time. The only way to build these agents is to keep iterating on them. See what they did, measure it, fix it, and ship it again. Today, these steps are spread across multiple tools that weren't built for agents. And that's where LangSmith comes in. LangSmith is built for and powered by agents supporting the entire agent development life cycle. So you can build, run, improve, and govern every agent. Here's how it works.
LangSmith 让团队中的任何人都能用自然语言或代码构建智能体。你可以使用 LangChain 的开源智能体框架,也可以使用任何其他框架。一键部署智能体。LangSmith 会处理基础设施,让智能体能够可靠地运行和扩展。Workday 采用 LangSmith 后,部署新智能体的时间从 5 个月缩短到不到一天。公司中的所有智能体都能在一个地方查看,让你随时掌握正在运行的内容。你可以追踪智能体执行的每一步,并准确看到它在哪一步出了问题。每次进行更改时,eval 都会测试新版本,让你在发布前确认它确实更好。LangSmith Engine 全天候监控智能体,发现故障。它会自动为你编写修复方案和评测。你只需审核并合并即可。使用 LangSmith Engine 的团队改进智能体的速度快了五倍。LangSmith lets anyone on your team build an agent in natural language or in code. You can use LangChain's open-source harnesses or any harness. Deploy your agent in one click. LangSmith handles the infrastructure so it can run and scale reliably. Workday adopted LangSmith and deploying a new agent went from 5 months to under a day. Every agent across your company is visible from one place, so you always know what's running. You can trace every step an agent takes and see exactly where it went wrong. Every time you make a change, eval tests the new version so you know it's better before it ships. LangSmith Engine monitors your agents 24/7 to find failures. It writes the fixes and evals for you. All you have to do is review and merge. Teams using LangSmith Engine improve their agents five times faster.
每次运行都由 LangSmith 管理,并配备模型回退、成本控制和敏感数据保护功能。如今,LangSmith 每月处理数十亿条追踪记录,每天有 7,000 多家客户依赖它。我们的目标是帮助每家公司掌控自己的智能,从其构建的智能体,到用于改进和管理这些智能体的系统。首先,我们要帮助团队构建值得在生产环境中信赖的智能体。因此,我们将向所有新 Plus 订阅用户免费提供 LangSmith Engine,直至年底。现在就访问 LangChain 网站,开始构建吧。 大家好。感谢各位参加。很高兴能举办这场网络研讨会。我们马上进入正题。不过右侧有一个很棒的问答区,大家可以在那里提交问题,我们会在最后回答,并尽量留出充足的时间。Every run is governed by LangSmith with model fallbacks, cost controls, and protection for sensitive data. Today, LangSmith processes billions of traces a month with more than 7,000 customers relying on it every day. Our goal is to help every company own its intelligence from the agents it builds to the systems that improve and govern them. That starts with helping teams build agents they can trust in production. So, we're providing LangSmith Engine for free to all new plus subscribers through the end of the year. Start building today at the LangChain website. Hello. Thank you everyone for joining. Excited to be doing this webinar. we are going to jump right into it. But there is a nice Q&A section on the right and if people add their questions there we will get to them at the end and we'll try to leave lots of time for that.
是什么让智能体能够持续运行What makes an agent persistent
Harrison Chase:我想谈谈我们认为智能体未来的发展方向,以及我们正在打造的一些助力于此的东西。我觉得现在做这个演讲时机非常好,因为我认为一种新型智能体——智能体发展的一个新飞跃——即将到来。回顾过去四年,以及人工智能和智能体的发展历程、我们构建智能体的方式,我觉得其中出现了几种不同的趋势。最初,我们只有简单的大语言模型,输入文本,输出文本。那时,LangChain 刚刚启动,大约比 ChatGPT 早一个月。之后,我认为下一个阶段是基于消息和工具调用的大语言模型,或者是服务提供商开放出来的 API。Harrison Chase: I want to talk a little bit about where we see agents going and some of the things that we're building to help with that. So I think it's actually a really great timing to be doing this presentation because I think there is a new type of agent a new step change in agent that's coming around. And so when I think of the past four years really and I think of the progression of AI and of agents and how we've built them, I think there's a few different kind of like you know trends that we've seen. First, we started with just simple LLMs, text in, text out. This was when LangChain was started about a month before ChatGPT. And then after those came out, I'd say like the next era was these messages and tool calling based LLM or APIs that providers exposed.
而这正是你可以开始打造对话式体验、进行大量顺序工具调用的地方。后来,推理模型问世,让模型和智能体都变得好得多。此后,编程智能体开始兴起。现在你知道,完成大量工作的已不再只是单次模型调用,而是这些与环境交互的智能体。正如我所说,我们现在正处于新一轮重大变革的起点。我认为,人们正在构建的这些新事物可以称为持久型智能体。那么,持久型智能体究竟是什么?过去几个月里,人们用过几种不同的术语来描述类似的事物。我最喜欢“持久型智能体”这个说法,不过你可能也听说过它们被称为环境智能体。And this is really where you could start creating conversational experiences and doing a bunch of sequential tool calling. And then reasoning models came out and it just made the models and the agents way better and after that we saw the rise of coding agents and now you know it wasn't just single model calls doing a lot of the work. It was these agents interacting with the environment and as I said right now we're we're at the start of a new step change and I think of these the these new things that people are building as persistent agents. and so what exactly is persistence agents? And there's a few different kind of terms that have been used over the past few months to describe similar things. I like persistent agents the best, but you might also have heard them called ambient agents.
所以这件事我们其实差不多一年前就用过了——现在想想,应该是两年前了。我们还听说过有人把它们叫作“常驻代理”。Anthropic 写过一篇关于构建常驻代理的博客。“主动式代理”也是一种说法。然后“持久型代理”这个说法来自 Dylan Patel,至少我是第一个听到他这么说的人。我最喜欢这个说法,因为我觉得这类代理有几个不同的维度,而这些名称其实都在描述这些维度。我认为“持久型”算是最好的名称。所以我想到持久型代理时,会想到它们的四个特征:它们以目标为导向、始终在线、会随着时间积累上下文,而且支持多人协作。So that's something we used actually about almost a year ago at this point, two years ago at this point actually. always on agents is another thing that we've heard them called. so Anthropic wrote a blog on building always on agents. Proactive agents is another term. And then persistent agents comes from Dylan Patel, or at least he's the first person I heard say it. and I like that the best because I think there's a few different dimensions of these agents that really all of these names are talking about. And I think persistent is kind of like the best name. And so when I think of persistent agents, I think of kind of like four different characteristics. They're goal oriented. They're always on. They accumulate context over time. And then they're multiplayer.
而且是跨多个界面的。因此,我想先聊聊这些特征是什么样的,然后再谈谈我们认为构建这类智能体需要具备的一些条件。随着模型和智能体越来越强大,关注点也逐渐从任务转向了目标。说到任务,我想到的是“写一封邮件”这样的事情:你作为用户把这个任务交给智能体,智能体就会去查找所需的信息,调用类似“写邮件”的工具。这是智能体执行的一项操作,通常范围相当明确。而我说到目标时,想到的可能是“维护一个博客”或“让收件箱始终保持清零”这样的事情,这需要智能体在较长一段时间内持续运行,并尝试不同的方法。And multi-surface. And so I want to talk a little bit about what these characteristics look like and then I want to talk about some of the things that we think are needed to build these. So we've as models and as agents have gotten better there 's been this kind of like shift from tasks to goals. and so when I say a task, I think of something like write this email and you know the agent you send that as a user to the agent. The agent will go off. It'll, you know, find whatever information it needs, call the kind of like write email tool. it's an action that the agent is doing. It's generally like pretty bounded. When I think of a goal, it might be something like maintain a blog or, you know, maintain inbox zero and that involves the agent running over an extended period of time trying out different things.
它是在针对某个结果进行优化。比如说,你知道,提升博客表现,或者实现收件箱清零。这是一个持续进行的过程,需要完成各种不同类型的任务。它必须在过程中把这些任务拆解开来。所以我认为,从任务转向目标,是这类持久运行的智能体非常重要的一部分。我觉得,由此产生的一件有趣的事就是目标设计。我想,在接下来的这段时间里,我们会更多地讨论目标工程或目标设计。我们的一位用户——一家很棒的公司 Actively AI,他们开发销售智能体——有一个重要的见解。我们和他们一起写了一篇博客,探讨目标设计,以及他们如何将目标与用户反馈基本上对齐。It's optimizing for an outcome. So like you know performance on the blog or inbox zero. it's constantly ongoing and it has to do a bunch of different kind of like tasks. It has to break down these tasks as it goes along. And so this shift from tasks to goals I think is a really important part of these persistent agents. And one of the interesting things that I think emerges because of this is goal design. And I think we'll talk a lot more about goal engineering or goal design over the next however long. and one of the key insights that one of our users had, Actively AI, great company, they build sales agents. we wrote a blog with them. We wrote a blog on kind of like goal design and how they basically aligned goals with user feedback.
关键的洞见是,对于这些持久运行的智能体来说,最难获得、但又必不可少的东西就是用户反馈。因此,如果你让目标与用户反馈保持一致,智能体就会表现得更好。举例来说,他们之前的做法有点像是每个账户配一个智能体,这是一种很自然的思路。你知道,每个智能体的目标就是推动对应账户向前发展。但实际上,所有账户都存在许多相似的阶段,比如外呼销售、早期交易推进。当他们重新围绕这些目标来设计智能体,并让它们能够适用于各种账户时,效果反而更好。基本上,这是因为他们的客户需要教智能体如何开展外呼销售,以及如何推进早期交易。The key insight being that the hardest thing to get that is needed for these persistent agents is user feedback. And so if you align the goals with user feedback then your agent will be better off. And so for example they had previously they had kind of like one agent per account which is a very natural way to think about it. and you know, the goal for each of those agents would be to like progress the account, but there's actually a bunch of different stages that are similar across all accounts, outbound sales, early stage deal progression and when they reoriented their agents around those goals and then made it work across all kinds, that was actually better. And it was basically better because their customers needed to basically teach the agent how to outbound, teach it how to kind of like progress early stage deals.
将目标围绕客户觉得更自然、也更愿意提供反馈的方式来设定,比如,客户更容易针对多个不同账户的外呼销售提供反馈,并让这些经验在不同账户之间迁移。这证明非常有价值。因此,这里的关键在于围绕反馈闭环来设计目标;总的来说,设计目标会变得非常重要。持续运行的智能体还有一个特点,那就是它们始终在线,因此会对各种不同的事情做出响应。不仅是用户消息,还包括现实世界中的事件,或智能体开发者可能设置的日程安排、智能体用户可能设置的日程安排,乃至智能体自己可能设置的日程安排。所有这些都会促使智能体被唤醒。And by orienting the goals around what the customers found more natural to give feedback, like it's easier to give feedback on outbound sales across a bunch of different accounts and have those learnings transfer. that proved to be really valuable. And so the key thing here is basically designing goals around feedback loops or just designing goals in general will become really important. Another part of these persistent agents is the fact that they're always on. So they react to a bunch of different things. Not just user messages, but real world events or schedules that the developer of the agent might set up or schedules that the user of the agent might set up or schedules that the agent itself might set up. And so all of these contribute to waking up the agent.
我所说的唤醒,实际上只是向智能体发送另一条消息,但这条消息并非来自盯着聊天框输入内容的用户,而是来自某些事件系统。因此,这是持久化智能体的一个关键部分。持久化智能体也会随着时间不断学习。也就是说,它们需要在更长的时间跨度内,围绕更模糊的目标开展行动。因此,它们在应对各种情况时也需要学习,并且需要把这些记忆保存在某处,以保持一致性并朝着目标不断推进。因此,记忆是这类持久化智能体的关键组成部分。而且,这些持久化智能体通常还支持多人协作,可以同时与许多人并肩工作。And when I say waking up, really what that means is just sending another message to the agent, but it's not coming from a user looking at a chat box and typing something in. It's coming from some of these event systems. And so this is a key part of persistent agents. Persistent agents also learn over time. so you've now got them, you know, acting over longer time horizons on more ambiguous goals. And so as they react to things they need to learn as well and they need to keep that memory someplace so that it maintains consistency and makes progress towards its goal. And so memory is a key part of these persistent agents. And then these persistent agents are often times multiplayer. So they work alongside humans many at the same time.
因此,你可以在这里看到 Robin 的一个示例。Robin 是我们内部使用的一个智能体,它能同时在 Slack 中与许多不同的用户互动。它也支持多种界面:我们还为 Robin 提供了桌面应用和 Web 应用,你可以通过这三种界面与自己的对话线程互动。这是这类持久智能体的另一个关键特征:它们并非只能在一个地方使用,而是可以通过多种不同的界面使用。这些就是我们认为构成持久智能体的特征。那么,究竟该如何构建它们呢?我们花了很多时间思考这个问题,也和开发者们进行了交流。智能体的行为来自整个系统。因此,我们通常会把智能体看作由三个层次构成。And so here you can see an example of Robin which is an agent that we have internally and it's interacting in Slack with a bunch of different users at the same time. and it's also multi-surface and so we also have a desktop app and a web app for Robin and you can interact with your threads through all three of those. and so that's another key part of these persistent agents. They're not just available in one place. They're available across a bunch of different surfaces. So, so, so, so those are the characteristics that we think make up persistent agents. So, so how do you actually build them? And we've spent a lot of time thinking and talking with builders about this. So, so behavior comes from the whole system. And so, when we think of an agent, we generally think of kind of like three layers.
模型、测试框架与应用上下文Models, harnesses and application context
所以,你需要模型、运行框架和上下文。模型提供推理和工具调用等能力。运行框架决定模型如何与环境,也就是外部世界交互。它包含各种工具,知道如何在循环中运行,也知道如何与沙箱或文件系统交互。上下文则是特定于应用的内容,包括指令、事实、反馈和记忆,也包括特定于应用的工具。一般来说,我们看到大家构建这些智能体时,多数人会直接使用现成的模型,无论是前沿模型还是开放权重模型。他们通常不会一开始就微调自己的模型。So the you've got the model, you've got the harness, and you've got the context. The model brings capabilities such as reasoning and tool calling. The harness is really how that model interacts with the environment with the outside world. So it's got tools and it knows how to run in a loop and it knows how to interact with its sandbox or its file system. And then context is the application specific stuff. And so these are instructions and facts and feedback and memory but also like application specific tools. And so generally when we see people building these agents, most people will use a model off the shelf, whether it's a Frontier model or an open-weight model. They're usually not tuning their own to start.
他们通常会从一个基础执行框架开始,或者使用现成的执行框架。这是因为这些框架包含很多组成部分,因此相当复杂,我稍后会谈到这一点。不过,接下来你会把自己的上下文都带进来:自己的工具、自己的技能、自己的记忆。这才是关键,它能让智能体真正适用于特定领域和垂直行业。所以我说过要谈谈执行框架。我们有自己的框架,叫作 LangChain Deep Agents。它是开源的,而且与模型无关,因此适用于市面上的任何模型。到目前为止,过去一年半里我们在其中加入了不少内容,我们认为这些改进让它变得非常出色。They'll usually start from a base harness or use an off-the-shelf harness. And that's because there's actually a lot of things that go into these harnesses that make them quite complex, and I'll talk about that in a second. But then you bring all of your own context. So you bring your own tools, you bring your own skills, you bring your own memory. and that's that's the key part that makes the agent really domain specific, vertical specific really work. So I said I'd talk about harnesses. So we have a harness of our own. It's called LangChain Deep Agents. It's open source. It's model agnostic, so it works with any of the models out there. and there's a bunch of stuff that we've added into it over the past year and a half at this point that we think makes it really good.
我们认为,这让它成为一个非常好的基础运行框架。稍后我会对此详细说明。我们提供了一些工具,用于与文件系统、沙箱以及现在也包括浏览器进行交互。我们还为你处理了大量通用的上下文管理工作。我们支持技能及其加载;当对话线程变得很长时,我们会进行摘要;工具调用内容很大时,我们会进行大量上下文卸载。提示缓存也非常重要,必须做好,所以我们也提供了相关功能。我们支持人在环路中参与。这也是这类长时间运行的智能体的关键,因为你需要就一些事情征求用户反馈。此外,我们还支持子规划、子智能体和异步子智能体,将它们作为委派能力。And we think makes it really good as a base harness. And I'll say more about that in a second, but we have kind of like tools for interacting with file system and sandboxes and actually browsers now as well. We do a bunch of base undifferentiated context management for you. So, so we support kind of like skills and loading skills. we have summarization for when threads get really long. When tool calls are big, we do a lot of context offloading. Prompt caching is really important to get right. And so we have stuff there. we support human in the loop. That's a key part of these long-running agents as well because you're going to need to ask for kind of like user feedback on things. And then we also support subplanning and subagents and async subagents as delegation capabilities.
因此,所有这些都是你希望自己的运行框架具备的通用能力,你大概不想从头开始构建它们,但也可能希望修改自己的运行框架。这正是 Deep Agents 再次发挥优势的地方。Deep Agents 的设计初衷就是作为一个基础运行框架。这意味着我们希望你对它进行修改。你可以通过中间件来修改它——这是一种让我们能够更好地控制智能体循环的方式;或者,如果你确实想这么做,也可以 fork Deep Agents,因为它是开源的,然后直接在其中进行修改。因此,Deep Agents 并不是专门面向终端用户的编程运行框架,尽管它很擅长编程;它的定位是一个可供构建和扩展的基础运行框架。所以,我想再回过头来谈谈这些持久化智能体的四种特性,然后聊聊要让这些特性成为现实,需要哪些组成部分。And so all of these are general capabilities that you want your harness to have and you probably don't want to build from scratch, but you might also want to modify your harness. And that's where deep agents is again really great. Deep agents is built to be a base harness. So what that means is that we want you to modify it. we want you to modify it through middleware which is a way that we have to kind of like control the agent loop more or if you really want to you can fork Deep Agents because it's open source and modify there so deep agents is not kind of like explicitly an end-user facing coding harness although it's good at coding but it's intended to be a base harness to build upon so I want to touch back on those kind of like four different properties of these persisting agents and then talk about what you need in your what like what parts are needed to make those a reality.
设计目标、日程安排与记忆Designing goals, schedules and memory
所以,所以,所以,当我说智能体是目标导向的,真正让它们具有目标导向性的,主要是那些促使它们朝目标努力的提示。而且,这些提示也应该鼓励它们发挥创造力。朝着目标努力,不只是蛮力尝试。你要考虑各种不同的路径,而不是只做这一件事。如果你按固定时间醒来,每隔30分钟就做同样的事,那你不会取得太大进展。你要记住之前做过什么,发挥创造力,观察各种情况。所以,这种提示方式和单纯完成一项任务的提示有所不同,后者往往很像是在蛮干。而这也正是对齐开始发挥作用的地方。So, so, so when I say agents are goal oriented, the main thing that makes them goal oriented will be some of the prompting that gets them to work towards that goal. And that prompting should also you know encourage them to be creative. When you're working towards a goal, it's not just like brute forcing something. You want to consider a bunch of different paths and not just do this. If you're waking up on a schedule and doing the same thing every 30 minutes, you're not going to make a bunch of progress. You want to know what you did before and get creative and look at things. And so, it's a different type of prompting than just accomplishing a task, which is often, kind of like very brute force. and then this is also where alignment comes into play.
这既体现在提示层面,也体现在模型层面。我的意思是,如果你给一个智能体设定一个目标,比如清除代码库中的所有 bug,它可能会通过直接删除整个代码库来实现这个目标。这样就没有 bug 了,目标也算是完成了。但当然,这不是我们希望智能体做的事,也不是我们希望任何工程师或任何被赋予这个目标的系统实际去做的事。这正是模型对齐在构建智能体这种常驻能力时发挥重要作用的地方。你可能会需要几样东西。你会需要 cron 定时任务。它们基本上是在后台运行任务的方式。你可以为它们设置某种运行计划,也可以让它们只运行一次。And both at the prompting level, but also at the model level. and so what I mean by this is if you give a agent a goal of kind of like removing all bugs from the codebase, it might accomplish that goal by just deleting the whole codebase. There 's no there's no bugs left. It's accomplished the goal. But of course, that's not what we want the agent to do. That's not what we want any engineer or any system that we give that goal to actually do. And this is where alignment of the models really comes into play for the for building this like always on aspect of the agents. You're probably going to want a few things. You're going to want crons. These are basically ways of running runs in the background. And so you can set either kind of like a schedule for them or as one-off.
你可能会想提供一种方式,让智能体为自己安排提醒,因为它们会执行任务或与用户互动,并且会希望在某个时间点醒来做些事情。因此,为智能体提供工具来管理自己的 cron 计划非常重要。你还会需要一大批事件监听器。智能体应该能在监听事件时被唤醒,无论是收到新邮件,还是有人向它发送新的 Slack 消息。这些都是你需要支持的不同事件监听器。你还需要支持某种队列和引导机制。这些智能体始终在线、始终在工作;当它从后台收到另一类事件时,你可能会向它发送一条消息。You'll probably want a way for agents to schedule their own reminders because they will be doing work or interacting with the user and there and they'll want to wake up at some point in time and do something. And so the and so having tools for the agent to interact with its own cron schedules is really important. You'll want a bunch of event listeners as well. So these agents should wake up as they're listening to events, whether that's a new email coming in or a new Slack message being sent to it. and so these are different event listeners you'll want to have. And then you'll also need to support kind of like queuing and steering. And so these agents are always on, they're always working. and a and you might send a message to it as it receives another kind of like event from the background.
那么,这个主代理如何处理所有传入的消息——是将它们排队,还是利用新消息来引导自身——这些都需要由代理的逻辑来处理。你会希望这个代理能够随着时间不断学习。实际来说,这意味着什么?具体而言,你需要考虑用户、代理,或以上所有对象的记忆。你需要决定代理运行时能否直接写入记忆,还是应该写入笔记;它是否会写入一个缓冲区,再在做梦过程中将其整合进去。所谓做梦,是指代理在后台运行,查看之前的运行记录、笔记或缓冲区等其他信息来源,然后据此更新记忆的过程。And so how this main agent deals with all these messages coming in and whether it queues them up or whether it uses new messages to steer, you're you're going to want kind of like the logic of your agent to handle that. You're going to want this agent to learn over time. What practically does that mean? And practically that means you'll want some concept of user or agent or all of the above. memory you'll want to determine whether the agent can write to memory directly as it's running or does it write to notes. Does it write to a buffer that is then incorporated during dreaming. So dreaming is a process where the agent runs in the background and looks at previous runs, previous like notes or buffer other kind of like sources of info and then updates its memory accordingly.
因此,这些都是你需要考虑的一些因素,而具体情况可能会因你如何组织记忆以及它的复杂程度而有所不同。接着,考虑到要支持多人协作和多平台,你需要处理身份验证和权限问题。比如我和同事在同一个 Slack 频道里,如果我发起一个线程,而我的同事接着发送下一条消息,那么即使是我发起的线程,也不应该因此就能访问我的 Notion 或电子邮件。因此,你需要确保授权机制与支持多人协作的频道相匹配。你还需要让多个服务都能连接到它。这意味着,无论你存储了什么状态,都需要能够通过其中任何一个服务访问。And so those are some of the considerations you'll want to take into account and that can be different based on how you structure memory and how complex it is. And then when you think about building for multiplayer and multi-surface you're you're going to want you're going to need to handle authentication and permissions. if me and my coworker are in a Slack channel together, you know, if I start a thread and my co coworker, you know, adds on the next message, it shouldn't be able to access my Notion or my email even though I started it. And so you'll want to make sure that authorization is lined up with channels where you have multiplayer capabilities. And then you're going to need to connect to it from multiple services as well. And so that means that any state you store will need to be accessible through any of those.
测试框架周边的运行时环境The runtime around the harness
无论是流式输出,还是展示你取得的任何进展,你都需要有不同的 UI 来支持这些功能。我之前谈过 harness,但它实际上只涵盖了我们讨论的需求中的大约一半。harness 会影响智能体的行为:提示词放在那里,工具放在那里,一些东西(比如子智能体)也放在那里。但我们讨论的很多内容其实都是围绕 harness 的基础设施,并不属于智能体核心循环本身。它位于核心循环之外,并与之交互。这就是我们所说的智能体运行时。可以这样理解:你有一个供用户与智能体交互的应用,也有这里的 harness,但实际上你还需要围绕它构建大量其他东西。And any streaming or any progress that you make, you'll also want kind of like different UIs to kind of like support that. And so I've talked about the harness before, but that really only gets you about like half of the stuff that we talked about in terms of the requirements. And so the harness affects how the agent behaves. And so it has the that's where the prompts go. That's where the tools go. That's where some of the things like subagents go. But a lot of what we talked about is also infrastructure around the harness. It's not actually in kind of like that core agent loop. It sits outside and in and interacts with that. And so this is kind of what we call an agent runtime. and the way to think about it is you've got your app where users are interacting with the agent and you've got your harness here, but there's actually a ton of stuff that you need to build around it.
所以,你需要某种执行机制来运行你的智能体,而且你会希望它以持久化的方式运行。我的意思是,这里有一个“持久化执行”的概念。也就是说,如果智能体在一次运行到一半时失败了,它不会就这么从头开始,而是会记住自己是在哪里失败的,然后从那里接着运行。你还需要一些 API 来接收消息,然后决定如何处理这些消息:是拒绝新消息、将它们排队,还是调整智能体的执行方向?你还需要一个带有 cron 定时任务并能发送提醒的调度器。你也会希望这个智能体能够使用工具。你还需要保存智能体的所有状态。如果它运行在你的笔记本电脑上,那很好。So you're going to want some concept of kind of like execution that runs your agent and you'll you're going to want to do this in a durable manner. And what I mean by that is there's a concept of durable execution. This is where if the agent fails halfway through a run, it doesn't just like start back from the beginning. actually remembers where it failed from and picks right back up from there. you're going to want APIs to take messages and then decide what to do with them. Does it reject new messages? Does it queue them? Does it steer them? you're going to want a scheduler that has crons and sends reminders. And you're going to want this agent to have tools to go there. You're going to need to keep all the state of your agent. and so if it's running on your laptop, great.
你不需要太担心这个。你可以直接把它作为文件存在那里。但如果它运行在云端呢?你会想要创建类似对话、进度和历史记录这样的东西,让你的应用和智能体都能访问。你还会希望以可靠的方式传输事件,并且能够跨设备使用。比如,我先在 Slack 里开始,然后切换到桌面应用,就可以接着接收这个事件流。然后,你还需要一个智能体可以与之交互的环境。所以,我们把这些东西都看作一种智能体运行时,它能解决许多不同的问题。这就是 LangSmith Deployments 所包含的内容。LangSmith Deployments 是 LangSmith 的一部分。You don't need to worry about that as much. You can just store it as files there. But what about when it's running in the cloud? you're going to want to create kind of like the conversation and progress and history and have that accessible to your app, but also to your agent. You're going to want to stream events in a reliable way. and across kind of like devices as well. So, if I start in Slack and then I move to my desktop app, I can resume that stream. And then you're going to need your kind of like environment that the agent interacts with. And so, we think of all this stuff as kind of like an agent runtime that solves a bunch of different things. and that's what's in LangSmith deployments. so LangSmith deployments is part of LangSmith.
我们真正把它称作智能体服务器。它会接入 harness 并将其打包起来,还加入了沙箱,以及一个上下文中心,用于以持久化的方式管理技能。它支持定时任务,也引入了用于对话的线程概念。它支持流式传输,而且足够可靠,因此你可以重新加入会话。它还负责处理身份验证,并提供任务队列来处理传入消息;实际上,它支持四种不同的多任务处理方式,其中包括引导和排队。它还设有检查点来维持运行状态。再强调一次,这一切都是为了支持长时间运行的智能体。你可以在智能体中定义各种内容,然后 LangSmith 会在这个智能体服务器中运行它,让你轻松构建始终在线、能够完成工作的智能体。It's the what we really call it is like an agent server. So it takes the harness and it bundles it up. It adds in we've got sandboxes there. It adds in a context hub for managing kind of like skills in a persistent manner. It's got cron jobs. It has a concept of threads for conversation. It does streaming and it does it in a reliable way so you can rejoin to it. it handles authentication. It has a task queue for kind of like incoming messages and actually handles four different ways of multitasking, which is that steering and queuing. it's got checkpoints to kind of like maintain things. And so again, this supports kind of like long-running agents. You define kind of like a bunch of different stuff in your agent. and then LangSmith will run it in this agent server and it makes building these always on agents that complete work easy.
所以,我想强调的关键部分是:在考虑构建智能体时,你需要考虑它的上下文、业务逻辑,也就是只有你才能提供的领域专属内容;还需要考虑智能体的运行框架,其中定义了对技能、子智能体、摘要和任务卸载等功能的支持。我们看到,越来越多的人会使用像 Deep Agents 这样的基础运行框架来实现这些功能。然后是智能体服务器,也就是智能体运行的基础设施,它位于 LangSmith 中。LangSmith 中还有一项功能叫 Managed Deep Agents。之前我提到过,这里有三个层次:上下文、运行框架,以及基础设施。So, so the key part that I want to emphasize is that you've got when you think about building your agent, you've got your the like context, the business logic of your agent, and that's the domain specific stuff that only you can provide. You've got the harness of the agent and this is where like support for skills and support for subagents and summarization and offloading is defined and more we see people using a base harness like deep agents for that and then you've got this agent server that is the infrastructure where the agent lives and that's in LangSmith. Another thing that's in LangSmith is Managed Deep Agents. So I mentioned before that there's these three layers. There's this context, there's the harness and then there's the infrastructure.
所以,Managed Deep Agents 的作用基本上就是把运行框架和基础设施打包在一起。现在你只需要定义智能体的逻辑,比如指令、技能、记忆、你想设置的各种计划,以及希望用户从哪里与它交互,还有要用到的工具。然后,我们会通过 Managed Deep Agents 来运行它,而它与 Agent Server 是分开的。它是位于 Agent Server 之上的一个抽象层。再说一次,如果你想运行任意运行框架,就使用 Agent Server;如果你想要最简单的方式,将运行框架与基础设施结合起来,就使用 Managed Deep Agents。它们处于不同的层级。Managed Deep Agents 也已在 LangSmith 中提供,你可以直接从那里轻松部署。And so what Managed Deep Agentss does is it basically bundles the harness with the infrastructure. so now you just define the logic of your agents. You define kind of like the instructions and the skills and the memory and any kind of like schedules you want to have and where you want people to interact with it from and any tools and then basically we run it on Managed Deep Agents which is separate from the agent server. It’s a abstraction layer above the agent server. So again, if you want to run any harness you want, use the agent server. if you want to run if you want the easiest way that combines a harness with infrastructure, use Managed Deep Agents. They're at different levels. and so this is also this is available in LangSmith and can be easily deployed to from there.
观察与治理行为Observing and governing behavior
到目前为止,我们一直在讨论运行时,我想强调的是,我们谈到运行时时,指的是智能体的预期行为。也就是说,你希望智能体做什么。但任何构建过智能体的人都会告诉你,即使你告诉智能体该做什么,也完全无法保证它真的会照做。因此,要想可靠地大规模运行和运维这些智能体,还有另外两个缺失的环节。其中一个可以说是改进循环,以及对智能体实际行为的观察。也就是说,你在运行时设定了智能体的预期行为,但实际发生了什么?你需要观察这一点,并利用这些观察结果,随着时间推移不断改进智能体的实际行为。说到这种观察与测试循环,其中有几个关键组成部分。We've talked all about the runtime so far and I want to emphasize that when we talk about the runtime, this is the intended behavior of the agent. this is what you want the agent to do, but as anyone who's built agents will tell you, you know, even if you tell an agent what to do, there's zero guarantee that it's actually going to do that. And so there's two other missing pieces when you think about what it means to actually run and operate these agents reliably at scale. One is kind of like the improvement loop and the observed behavior of the agent. So again, you have this intended behavior in the runtime, but what actually happens? you need to observe that and you need to use those observations to improve the agent's actual behavior over time. And so when we think about this kind of like observation and testing loop, there's a few key parts of it.
一是测试智能体。也就是说,你想测试智能体的各个方面。你想测试它,确保它不会针对事件做得太多。我的意思是,如果一个智能体每 30 分钟醒来一次,并且每 30 分钟都联系用户一次,那就太扰人了。你想测试它是否进行了正确的工具调用,是否返回了正确的消息,是否正确地编辑了状态。总之,你想从许多不同维度测试智能体。你想根据评分标准评估智能体的执行轨迹,不仅是执行轨迹,还要评估整个智能体的最终状态。你想评估传入的信号是否相关,以及它所做的研究是否到位。One is testing the agent. so you want to test all aspects of the agent. You want to test that you know it that it doesn't kind of like do too much for events. So, what I mean by this is if you have an agent waking up every 30 minutes and it reaches out to the user every 30 minutes, that's too spammy. You want to kind of like test you want to test that it does the right tool calls. You want to test that it returns the right message. You want to test that it edits the state correctly. So, so you want to test the agent on a bunch of different dimensions. You want to grade like the traces of the agent and not just the traces but actually the end state of the whole agent against a rubric. so you want to grade kind of like was the signal that came in relevant was the research that it did.
这些是一些示例,基本上都是展示如何对执行轨迹进行评分的示例,也就是从多个不同维度评估智能体的完整执行过程。因此,你需要为其中一些评估设置评分标准或评估器,既包括在线的,也包括离线的。在线评估是指在智能体运行时对其进行评分;此时你没有标准答案,但知道它应该完成某些事情。而离线评估则有标准答案。我之前提到过,评估持久型智能体的一个关键方面,或者说一个新的方面,是评估它如何处理不断传入的各种信号或事件。因此,你需要测试它是否会在值得采取行动时采取行动,以及在不值得采取行动时保持沉默。These are examples but these are basically examples that show how you can grade a trace. So the full execution of an agent against a bunch of different dimensions. And so you'll you're going to want to set up kind of like rubrics or evaluators both online and offline for some of these. And online I mean a as agents are running you grade them so you don't have the ground truth but you know it should do certain things. And then offline you do have the ground truth. I mentioned this before but a key part or a new part of evaluating persistent agents is evaluating how it basically deals with all the signal the signals that are coming in or the events that are coming in. And so you're going to want to test that it acts when it's worth acting on and it's also silent when it's not worth acting on.
如果出现任何噪声或错失任何机会,那都是不好的。所以,这只是你需要针对这些持久运行的智能体进行测试的一个新维度。接下来你主要要做的,就是建立这样一个循环:把轨迹转化为测试用例,以便用来运行回归测试。具体来说,你可能会在生产环境中运行智能体,并在它运行时发现它以某些方式失败;或者你有一个系统能够捕捉这些失败,然后将其转化为评估项,之后基本上就可以把它们用作修改代码时的单元测试。因此,运行时就是智能体的预期行为。And if there's any noise or any missed opportunities, those are bad things. So this is just a new dimension of things that you're going to want to test with these persistent agents. And then the main thing that you're going to want to do is have this loop that basically takes traces and turns them into kind of like test cases that you can run regression tests against. So specifically what I mean is you might be running your agent in production and as it's running you notice that it fails in some manners or you have a system that catches those failures and then you turn those failures into evaluations that you can then basically use as unit tests for when you're making changes. And so the runtime is the intended behavior of the agent.
你会根据观察到的智能体行为,持续迭代改进。但有些事情是你绝不希望智能体获准去做的。这正是治理发挥作用的地方。治理定义了智能体能做什么、不能做什么。不要把这些写在提示词里,因为提示词只是建议,智能体可以忽略,也可能受到提示词注入攻击。如果你希望明确规定智能体能做或不能做哪些事情,就应该在治理层强制执行。你需要在关键关口强制落实策略、身份验证和审批。也就是说,在智能体调用工具、发起网络请求(包括向模型发送请求)时,都要在这些环节强制执行相关要求。You've got this improvement loop that you're spinning due to the observed behavior of the agent. But then there's certain things that you just don't ever want your agent to be allowed to do. And this is where governance comes into play. And so governance defines what the agent can and cannot do. You should not define this in a prompt. A prompt offers suggestions. The agent can ignore it. It can get prompt injected. if there are specific things that you want the agent to be able to do or not be able to do, you want to enforce this at the governance layer. And so you want to enforce things like policy and identity and approval at basically like the choke points. And so that means when it calls tools, when it does network requests including to the models, those are the places where you want to basically enforce these things.
这里的一个关键点是,这些权限可能取决于上下文:是谁在执行、执行的是什么操作,以及操作发生在哪个界面中。举个例子,这是一个关于 Slack 机器人的真实案例。当你在 Slack 中与我们公司的某个智能体交互时,如果你在私信(DM)中,就可以在个人范围内访问电子邮件、发送邮件;但如果你在共享频道中,就不允许这样做。这是因为频道里还有其他人,而且其中可能包含敏感信息。因此,这是一个真实案例,说明权限完全取决于智能体运行时所处的上下文。这就是智能体行为的三个方面:我们认为,智能体有其预期行为、观察到的行为,以及受治理的行为。And a key part here is that those permissions might depend on the context. so who is acting, what action it is, what surface it's in. And so for example, this is a real example of Slack bots. We have when you interact with one of our company agents in Slack, if you're in DMs, you're allowed to kind of like access email send emails from within the personal scope. When you're in a shared channel, you're not allowed to. And that's because there's other people kind of like in the channel and there might be sensitive information that's in there. And so this is a real example where permissions depend entirely on the context of where the agent is running. And so these are like the three aspects of agent behavior. We think there's kind of like the intended behavior of the agent, the observed behavior of the agent, and then the governed behavior of the agent.
随着智能体变得越来越强大,你需要掌控它们的行为。这就是我们所说的“掌控你的智能”真正的含义。因此,当我们谈到掌控你的智能时,我们指的是从以下三个维度掌控这些智能体的行为:你需要能够明确指定希望它们做什么;能够观察它们,确保它们做得正确;还需要能够设定治理规则,约束它们的行为。我提到了 LangSmith,接下来想谈谈 LangSmith 在哪些方面是为智能体而构建、又是由智能体驱动的。就智能体运行时而言,开源部分是你定义智能体行为的地方,而 LangSmith 则让你能够大规模运行它。And as agents become more powerful, you need to own how they behave. And that's what we really mean when we say own your intelligence. And so when we talk about kind of like owning the int your intelligence, we talk about owning the behavior of these agents across these three dimensions. You need to be able to specify what you want them to do. You need to be able to observe them to make sure that they're doing the right thing. And then you need to be able to also set governance to enforce what they do. I mentioned LangSmith. I want to touch on a few places of how LangSmith is built for and powered by agents actually. So in terms of the agent runtime, the open source is where this is where you define the behavior of your agent and then LangSmith is how you run it at scale.
LangSmith 用于运行和改进智能体的工具LangSmith’s tools for running and improving agents
我提到了 agent server、managed agents,接着提到了 deep agents,也就是我们的开源 harness。这些内容都与 agent 改进闭环中的 agent 运行时有关。这里有 SmithDB,它是我们用于可靠存储追踪记录的数据库;此外还有可观测性和评估,它们也是关键组成部分。我还想重点介绍一下 Engine。我提到过,你希望推动这样一个改进闭环,而 Engine 是我们在 LangSmith 中实际构建的一个 agent,可以帮你推动这个闭环。它基于追踪记录运行,监控其中的问题,然后根据这些问题创建评估,并在你的代码库中生成修复方案。So I mentioned the agent server I mentioned managed agents and then you I mentioned deep agents which are which is our open-source harness. and so these are really everything related to the agent runtime on the agent improvement loop. You've got things like SmithDB which is our database for storing traces reliably and then you've got observability and eval which are a key part. The other thing I want to highlight is engine. So I mentioned there's this improvement loop that you want to spin. engine is an agent that we actually built in LangSmith to help spin it for you. So it sits on top of traces and it monitors them for issues and then based on those issues creates eval creates fixes in your codebase.
实际上,如果你还没试过,我觉得我们看到的情况之一是,你可以向 LangSmith 发送成千上万甚至数百万条追踪记录,但你已经无法再逐条手动查看它们了。因此,在上面运行一个智能体就非常有价值。如果你还没试过 LangSmith,我会强烈推荐你试试。接下来是智能体治理,也就是定义智能体能做什么、不能做什么。我前面提到过,你要把这些规则设在智能体的关键控制点上,也就是事情通过网络传输的地方。主要有两个这样的地方:调用模型时。我们有一个 LLM 网关,可以在这里控制成本、控制对不同模型的访问权限、设置回退方案,等等。Actually if you haven't tried it out I think that like one of the things that we see is that you can send thousands or millions of traces to LangSmith and the value you get from them you can't look at them by hand anymore and so then having an agent that runs on top is really valuable and so if you haven't tried out LangSmith already I would highly suggest it and then agent governance this is where you define what the agent can and cannot do and so there's again I mentioned that you want to set these at kind of like the choke points of the agent where things go across the wire so to speak and so The two main places that happens are when you call Ms. And so we have an LLM gateway. This is where you can control costs, control access to different models, set fallbacks, things like that.
然后还有一个工具网关,我稍后会谈到这一点。我想聊聊我们上周在 LangSmith 发布的三项新功能,它们都围绕着同一个目标:努力让 LangSmith 成为最适合这类主动式、始终在线智能体的平台。之后我会回答一些用户提问。如果有问题已经出现,而你还没有把它们放进问答框,请放进去。我稍后会回答,也请给你感兴趣的问题点个赞。基本上,我会按照受欢迎程度从高到低依次回答。所以,如果你希望某些问题得到解答,请给它们点赞。本周我们在 LangSmith 推出了三项新功能。第一项基本上是对追踪数据的控制。And then a tool gateway as well. And I'll talk about that in a second. And so I want to talk about three new releases that we made in LangSmith this past week that all speak towards this goal of you know trying to make LangSmith the best platform that for these proactive always on agents. I after that I'll I'll go into kind of like user questions. So, if there are any that have popped up and you haven't already put them in the Q&A box, please put them there. I'll get to them after that and please upvote the ones that you like. basically what I'm going to do is I'm going to go down the order of ones that are most popular and answer them. So, if you want ones answered, please upvote them. So, there's three new things that we launched in LangSmith this week. First is basically trace data control.
追踪隐私、编码指标与工具权限Trace privacy, coding metrics and tool permissions
所以,追踪记录非常重要。它们能观察你的智能体在做什么,也可以用来推动改进循环,但其中也包含大量敏感信息。因此,你要确保不该访问这些信息的用户无法查看它们。本周我们添加了三项功能,我认为它们对安全地使用、治理和管理追踪记录的访问权限都非常有帮助。首先,我们新增了对查看追踪记录输入和输出的权限控制。也就是说,在这里你可以看到追踪记录的概要:调用了哪些模型、输入 token 数量、费用以及使用的工具,但看不到任何输入和输出。实际上,这是一个非常实用的视图。So, so traces are super important. they observe what your agent does and they can be used to power the improvement loop, but they also contain a ton of sensitive information. And so you want to make sure that they're not available to users who they shouldn't be available to. And so there's three things we added this week that are that I think are really impactful for safe kind of like usage and governance and access of traces. First, we added new controls over the ability to see trace inputs and outputs. So, what I mean by that is here you can see the skeleton of a trace. You can see what models was called, what the input tokens were, the cost was, the tools, but you can't see any of the inputs and outputs. And this is actually a really useful view to have.
你可能希望将其设为开发人员的默认视图,因为输入和输出中包含大量敏感信息。不过,客户可能有相关政策或合同,不允许你或开发人员查看输入和输出。因此,默认情况下,你可以对它们进行屏蔽,但仍然能够了解代理正在进行的操作。接下来,你可以通过用户组管理这些权限,例如谁可以查看输入和输出,以及谁可以访问特定的跟踪记录。以前,我们只能在用户级别设置权限。如果你有不同的团队,这显然会非常麻烦。因此,我们新增的功能之一就是可以通过用户组按团队设置权限。And you might want this to be the default view for your developers because the inputs and outputs contain a ton of sensitive information. But there's a and so and your customers may have basically policies or contracts that don't allow you or your developers to see kind of like the inputs and outputs. And so by default you can mask them but you can still get this sense of what's going on in the agent. the next thing you can do is you can basically manage these permissions like who can see inputs and outputs, who can even access certain traces with user groups. And so previously the way that we had it defined is that you could only set this at a user level. if you have different teams that's obviously very cumbersome. And so one of the things we added was basically team by team permissions with user groups.
最后,我们添加的最后一项功能是,你可以使用元数据设置 trace 级别的访问策略。我这是什么意思呢?基本上,以前,如果你想让某些人看到某些内容——比如,假设默认情况下输入和输出都是屏蔽的,而你想让某个人看到特定 trace 的输入和输出——你就必须为项目中的所有 trace 开启这项权限。但项目里可能会有许多来自不同客户的 trace;或者客户可能始终只希望你看到某一部分 trace。现在,你可以使用元数据设置这些策略。也就是说,你可以根据 trace 中的元数据指定:任何元数据键等于某个特定值的 trace,都允许用户组 ABC 查看其输入和输出。这是一种非常实用的控制方式组合,因为我们看到,默认情况下,人们希望组织中的每个人都能访问这种……骨架式的 trace。And then lastly, the last thing we added was you can set trace level access policies using metadata. So what do I mean by this? So basically, previously you could you would if you wanted people to see like the if like let's say by default you had inputs and outputs masked and then you're like okay I want someone to see the inputs and outputs for particular traces you would have to turn that on for all traces in the project and you might have a bunch of different traces from different customers there or maybe the customer always want only wants you to see a certain subset of traces and so now you can set those policies using metadata. So based on the metadata that's available in the traces, you can say any trace with you know a metadata key equals a specified value then you know user group ABC can see the inputs and outputs of and this is a really useful kind of like combination of controls because by default what we see is that people want to give everyone in their org access to this kind of like you know skeleton trace.
但当用户投诉或遇到问题时,他们希望开启——他们希望开启一项功能,让部分用户能够查看该特定用户的跟踪记录,而这些记录通常会保存在元数据中。现在,你可以通过这个功能实现这一点,我们认为它非常强大。 接下来是面向编码代理的 LangSmith。LangSmith 是一个平台,可帮助你改进和管理代理的使用,无论是你构建的代理,还是你使用的代理。当然,我们现在都在使用的一种非常受欢迎的代理类型就是编码代理。因此,我们在 LangSmith 中为编码代理添加了一个专属视图。你可以看到,我们做了几项改进。首先,我们支持连接 GitHub,这样你就可以将编码代理的支出与成果关联起来。But then when a user complains or when a user has an issue, they want to turn on they want to turn on the ability for a subset of users to see the traces for that particular user which is often recorded in metadata. And so now you can do that with this and we think that's really powerful. Next LangSmith for coding agents. so LangSmith is the platform for you know improving and governing your agent usage whether it's agents that you build or agents that you use. And so of course a really popular type of agent that we're all using is coding agents. And so we added a dedicated view for coding agents in LangSmith. So you can see here that there's a few things that we've done. First we made it so that you can connect GitHub so you can associate coding agent spend with outcomes.
创建了哪些 PR?哪些追踪记录导致了这些结果?我们还添加了许多专为编码代理设计的统计数据。比如,你可以查看每次合并的成本、PR 成本随时间的变化以及不同模型的相关数据。你可以按许多不同维度分组,比如按用户、模型或 PR 类型分组。我们还会尝试对不同类型的对话线程进行分类,例如区分它们是修复 bug 还是单纯探索。现在,所有这些功能都作为一种新的代理类型在 LangSmith 中提供。你会看到这里有一个 coding 标签。如果你进入 LangSmith,点击“创建新代理”,然后选择 coding 类型,就会看到这个视图,可以在这里开始追踪相关数据。我们还集成了所有主流且广受欢迎的编码框架。Which PRs are being created, and which traces lead to those outcomes? you we add a bunch of different statistics that are coding agent specific. so you can see kind of like cost per merge PR cost over time by model. You can group it by a bunch of different things. So you can group it by users. you can group it by model. You can group it by PR type. we do things like try to classify the different types of threads. So whether it's a bug fix or just exploration. and so all of this is now available as a new agent type in LangSmith. You'll see here that there's this coding tag. And so if you go into LangSmith and you click kind of like create new agent and you select type coding. This is the view that you will get when you start tracing things here. We also have integrations with all the major kind of like in popular coding harnesses.
所以像 Claude Code、pi、OpenCode、Codex 这类工具,都有可以追溯到 LangSmith 的集成。最后再说说 LangSmith 工具网关。我之前提过会讲到它。它基本上是一种用于保护和管理智能体工具使用的方式。 它的工作原理是这样的:你有各种不同的智能体,不仅是 LangGraph 智能体,还可以将工具网关用于编程智能体,或你可能会使用的其他任何框架。工具网关有什么作用?它会跟踪是谁在调用哪个工具。它会获取令牌并将其存储起来,以便连接到其他服务。我们使用 OAuth,因此它会创建并附加一个 OAuth 令牌。然后,它会检查是否有可用的策略:发起调用的用户或智能体是否有权调用这个工具?So things like Claude Code, pi, OpenCode, Codex, all of them have integrations that you can trace to LangSmith. And then lastly, the LangSmith tool gateway. So I mentioned I'd talk about this. This is a way to basically secure and govern tool use for agents. So how it works, you've got all these different agents, not just LangGraph agents, but you can use the tool gateway with coding agents or kind of like any other framework you might use. The tool gateway, what does it do? It keeps track of the identity of who is calling which tool. It gets a token and gets the token and stores it for connecting to things. So we use OAuth. So it creates and attaches kind of like an OAuth token. It then looks at any policies that are available. So does the user or does the agent that's coming in have kind of like the ability to call this tool?
你们对此有什么想设置的护栏吗?如果这些条件都满足,它基本上就会转发请求,并将其记录到审计日志中。这样你就有了审计日志,可以查看所有工具调用的轨迹,以及哪些智能体代表哪些人调用了哪些工具。然后,它会将请求转发给这些工具。这些工具可以是我们托管的内置工具,也可以是远程 MCP 服务器,或者是你们自己托管的工具服务器。这是一种保障和管理智能体工具使用的方式。 在进入问答环节之前,我最后还想提一下,我们正在开展一项“智能体工程现状”调查。我们每年都会做这项调查。看看调查结果逐年如何变化非常有意思。我们有意保留了许多问题不变,这样不同年份的数据就能很好地保持连续性。Are there any guardrails you want on that? And then if all of that is met, it basically forwards the request and logs it to an audit log. So now you have this audit log. So you can see all the tool call traces and which agents are calling which tools on which humans behalf. And then it will forward it to the tools. And these can be built-in tools that we host. These can be remote MCP servers or these can be kind of like tool servers that you host as well. And so this is a way to secure and govern kind of like the tool use of agents. The very last thing I want to mention before I go to some of the Q&A is that we are running a state of agent engineering survey. we do this every year. It's very interesting to see how the aers change year-over-year. We've purposefully kept a lot of the questions the same so we have this good continuity between years.
观众提问:使用场景、权限与记忆Audience questions: use cases, permissions and memory
所以,拜托,大家去参加吧,应该会挺简单也挺有趣的。如果你参加,我们还会让你有机会赢得限量版 LangChain 周边。好,接下来进入问答环节。太棒了,问题还真不少。So, please you know, go take it. It should hopefully be pretty easy and pretty fun. and if you do so, we'll we'll enter you to win limited edition LangChain swag as well. All right, let's go to some Q&A. Awesome. Bunch of questions.
观众提问:你们还看到了持久化代理的哪些其他应用场景?Audience question: What other use cases are you seeing for persistent agents?
Harrison Chase:我认为每个用例最终都会变成一个持久运行的智能体,我对此深信不疑。就像我刚才提到的,我们正在销售领域积极构建持久运行的智能体。Clay 是另一家公司,我们刚和 Max Agency 做了一期关于它的播客。它属于市场拓展领域,也在朝着构建持久运行的智能体迈进。我认为我们内部也有某种持久运行的市场拓展智能体。Harrison Chase: I think like every use case will become a persistent agent like I very strongly believe that. So I mentioned actively in the sales space building persistent agents. Clay is another company that we just did a podcast with Max agency on that's in the go-to-market space and they are also building towards persistent agents. I think internally we have kind of like a persistent go-to-market agent as well.
所以,市场推广似乎已经是一个常见主题了。我觉得这会是最有可能迅速兴起的类别之一。不过我们也有一个营销智能体,我们称之为 Content Studio。它会在后台处理一些事情,比如维护链接和博客;它还安排并发布了一条推文——我每周五都会发这类推文,基本上就是总结我们发布了什么。我们还有一个编程智能体。代码评审显然是一个应用场景,另一个则是事故处理。事故发生时,你会希望有一个主动、持续运行的智能体来应对,也能随着时间推移从事故中学习。因此,我确实能想象,每个领域都会逐渐转向这类持续运行的智能体。So go-to-market seems to be a common theme already. I actually think that's one category that will kind of like pop off the most. But we also have a marketing agent. We call it content studio. it does things in the background like maintain links and blogs and it actually scheduled and sent a tweet that I do every Friday which is basically a roundup of what we launched. and then we also have a coding agent. And so there's stuff like reviewing reviews is one kind of like obvious one, but another one is incidents. When incidents happen, you want a proactive kind of like persistent agent to respond to them and also learn from incidents over time. and so I can really see every domain being kind of like moving towards these persistent agents.
事实上,有人在 Twitter 上回复我时提到了一件事。当时我发推谈到了持久型智能体,对方说,持久型智能体其实就是智能体。我觉得再过几年,我们就不会再称它们为持久型智能体了,只会叫它们智能体。智能体的定义一直在变化,也在不断发展。我真的认为,每个智能体最终都会成为持久型智能体。不过,再过几年,我们就只会叫它们智能体。In fact, one thing that someone responded to me on Twitter on when I tweeted about persistent agents, persistent agents are just agents. Like I think in a few years we won't call them persistent agents. We'll just call them agents. The definition of agent keeps on changing and keeps on moving forward. And I really think every agent will become a persistent agent. But it but in a few years we'll just call them agents.
观众提问:随着常驻运行的智能体不断兴起,内存容量和可扩展性可能会成为潜在瓶颈。Lang 正如何应对这一挑战?你们是否在探索软件层面的解决方案、硬件合作伙伴关系,或其他方法,以提升智能体内存的可扩展性和效率?是的,这是个好问题。Audience question: With the rise of always on agents, memory capacity and scalability could become a potential bottleneck. How is Lang approaching this challenge? Are you exploring software level solutions, hardware partnerships or other approaches to make agent memory more scalable and efficient? Yeah, it's it's a good question.
Harrison Chase:所以我觉得这里有两个不同的方面。一个基本上是,很多这类持续运行或持久化的智能体都需要在沙箱中运行。我认为,计算资源实际上是目前最紧张的环节之一。这就是我们为什么在产品中加入了沙箱。我觉得这是管理和获取计算资源的一种非常简单的方式。我们的底层使用 Google,但也集成了许多其他沙箱服务提供商。 至于智能体记忆本身,我的看法是,目前记忆的实际存储并不难。也就是说,那并不是难点。事实上,综合来看,大多数人的记忆内容都相当少。真正困难的是决定要记住什么,然后随着时间推移不断整理这些内容,并确保它们保持新鲜、及时更新。Harrison Chase: So I think there's two different dimensions here. one is basically the fact that a lot of these always on or persistent agents need to basically run in a sandbox. And I think that actually compute is where we're seeing kind of like the most kind of like squeeze for things. And so this is why we built sandboxes into our product. I think it's a really easy way to manage and get this compute. we use Google under the hood, but we also have integrations with a bunch of other sandbox providers. with agent memory itself, so my take on agent memory is right now the actual storage of memory is not that hard. Like that's not the hard part. And in fact, most people have like pretty small like memory things all things considered. The hard part is really deciding what to remember and then curating that over time and keeping that fresh and up to date.
因此,我们正在对这两件事进行更深入的研究:如何决定要记住什么,以及如何整理这些记忆?希望我们能在这方面推出一些很酷的东西。And so we are investigating much more on that on those two things. How do you decide what to remember and how do you curate that me that memory? hopefully we'll have some cool things to launch there.
观众提问:随着智能体开始执行支付等实际操作,你认为应如何制定规则,规范智能体在自动化管控中可以对记录进行哪些操作?Audience question: As agents start taking real actions like payments, how do you think the rules for what an agent may do with the records in automated control should be handled?
Harrison Chase:首先,我认为你绝对需要一份审计日志,记录代理执行过的所有操作。我认为这类功能应该放在那里;你需要类似工具网关的东西,这也是我们把它集成到 LangSmith 中的原因。我觉得这类东西就应该放在那里。而且我认为,这份审计日志对审计人员来说会非常重要,也有助于了解代理可以执行哪些规则。Harrison Chase: First, I think you absolutely need audit log of all actions that the agent has taken. and so I think that belongs I think you need something like a tool gateway and that's why we're building it into LangSmith. And so I think that sort of thing belongs there. a and I think those I think that audit log will be really important for things like auditors and getting sense there in terms of like what rules an agent can do.
我认为,这归结为两件事。第一,我认为这取决于你给工具本身设置的权限,这也正是为什么要有一个工具策略层。我们的工具(或者说工具网关)能做几件事,其中两件是:一是审计日志;二是可以配置的策略层,用来规定智能体能不能调用某个工具。它们可以调用工具,但需要有人参与审核,也就是说必须由人来批准。设置这样一个策略层后,你还可以设想在其中加入语义策略,例如规定智能体只能使用一组明确允许的输入来调用工具。这会变得非常重要。另一件事是这些智能体的对齐。I think this is I think this comes down to two things. One I think it comes down to the permissions that you set on the tools themselves and this is again why having kind of like a tool policy layer. So, so the two things our tool or our tool gateway does a few things but two of the things it does. One is this audit log. This other is this policy layer that you can set so that agents can call a tool can't call a tool. They can call a tool but there's human in the loop so a human has to approve it. And so having this policy layer and you can also imagine adding in semantic policy things into that like the agent can only call it with a defined set of allowed inputs. that'll become really important. And then the other thing is alignment of these agents.
我觉得,对齐一直被认为是这类持续运行、始终在线的智能体面临的问题。相比这些时间较短、以任务为导向的东西,我认为这要严重得多,因为现在这些东西都在后台运行,你看不到它们在做什么。这是个大问题。Like I really like alignment has always been talked about as an issue with these persistent always on agents. I think it's way more of an issue than with these shorter task-based things because now these things are running in the background. You don't see what they're doing. it's a huge issue.
听众提问:能否深入讲讲持续学习闭环?我大致明白了:从宏观上看,就是收集执行轨迹、发现错误模式、修改代码。但你们如何确信这些修改确实带来了改进?错误模式的识别方式可以定制。具体是怎么做的?这里有哪些最佳实践?Audience question: Can you go deeper on the continuous learning loop? I get it. High level. Collect traces. Spot error patterns. Make code changes. But how do you gain confidence that the changes are truly improving? Spotting error patterns can be customized. how this is done. What are best practices here?
Harrison Chase:我认为这件事有三个部分。首先是评估。评估有点像是让你确信这些改动确实在改善线上和线下表现的方式。Harrison Chase: I think there are three pieces to this. first, evals. Evals are kind of like how you have confidence that the changes are truly improving both online and offline.
所以,如果你在做改动,可以使用离线评估,先运行它们。在线评估可以用来做 A/B 测试,也可以只是确保你做出改动后,系统表现不会退步。第二件重要的事是 traces。你怎么发现错误模式?归根结底,这都要靠 traces。你需要一套记录 agent 做过什么的权威系统。这些记录非常有价值。然后我要说的第三件事,就更深入地涉及如何发现错误模式,以及如何定制这一流程。我认为,整个过程会深受“苦涩的教训”影响。我的意思是,我们有一个引擎,能做的正是你在这里说的这些事:发现错误模式。它在底层其实就是一个编程 agent。它配备了一套特定技能,以及一套特定工具和 CLI,但归根结底,它就是一个编程 agent。So offline evals can be used if you're making changes, run them before. Online evals can be used as a way to A/B test things or just like make sure that when you make changes, things don't regress. second important thing, traces. How do you spot error patterns? It all kind of like comes down to traces. You need the system of record of what agents done. Those are super valuable. And then the third thing that I'll say and this gets more into like how do you spot error patterns and how do you customize how this done? So, so I think this whole process will be very shaped by the bitter lesson and so what I mean by that is like we h we have engine does exactly what you're talking about here. It spots error patterns. under the hood it's just a coding agent. It's a coding agent with a particular set of skills and a particular set of tools and CLIs, but at the end of the day, it's just a coding agent.
而且在构建 Engine 时,我们非常有意识地想要发挥……比如,我在考虑记忆时也是这样,记忆也是如此。当我们谈到如何整理记忆时,它最终只会是一个编码代理。我认为,许多用于处理记忆的复杂系统,最终都会被配备工具和技能的通用模型取代;它本质上就是一个拥有特定技能和工具的编码代理,运行并更新某些东西。错误模式的识别也是如此。我们正在让 Engine 更容易定制。12 月第一周我们会推出一些很棒的新功能,我认为这些功能会让 Engine 更加注重目标,也更持久,并且更容易定制。And when we build engine, we very purposefully try to lean into like I when I think about memory as well, memory as well I and when we talk about kind of like how do you curate memory, it's just going to be a coding agent. I think a lot of these complex systems for doing memory are going to get replaced by general models with tools and skills and it's really just going to be a coding agent with a particular set of skills and a particular set of tools running against running and updating something. And that's same for kind of like spotting error patterns. We're making it way easier to customize engine. we're going to have some really cool launches first week of December that I think will make engine even more goal oriented and even more persistent and I think will make it easier to customize as well.
观众提问:能否进一步谈谈这些智能体的记忆是如何设计的?例如,内部采用的方法是构建一个 Wiki,还是采用其他方式?Audience question: Can you comment more on how memory is being architected for these agents? For example, internally is the approach to build a wiki or some other approach?
Harrison Chase:我花了很多时间思考记忆问题。之前我也谈到过。我认为记忆在某些方面会遵循“苦涩的教训”。我们在 LangChain 探索这一问题的方式是——希望很快能在这里有更多内容可谈——但我不认为记忆的存储格式有那么重要,而且我认为记忆有不同类型,它们可能需要不同的存储格式。比如,技能完全可以算是一种记忆。技能属于程序性记忆,也就是你如何做事。因此,你会希望维护这些技能,而技能有特定的格式。Harrison Chase: I’ve been spending a lot of time thinking about memory. I’ve touched on it before. I think memory will follow the bitter lesson in some ways. I the way that we approach it at LangChain and again hopefully we'll have more things to talk about here soon, but so I don’t think the storage format of memory matters that much and I think there's different types of memory and they might just need different storage formats. For example, skills are totally a type of memory. Skills are procedural memory, how you do things. And so you're you're going to want to maintain skills and skills have a specific format.
同样,还有另一类东西,比如知识,可能最适合存储在 OKF、Markdown 文件、Wiki,甚至图数据库里。Hex 写过一篇很棒的文章,介绍他们如何在底层使用图。所以我其实不觉得存储格式特别重要。我认为有两个关键点需要考虑,我之前也简短提到过:其一,智能体运行时能不能更新记忆;其二,能不能不更新记忆。总体来说,我们内部的共识是,它有时可以更新,也可以始终记笔记,因为智能体运行时可能会发现缺少了什么,也可能注意到哪些内容已经过时,而你肯定不想以后再重新发现这些问题。Likewise, there's other kind of like just like knowledge and that might be best stored in OKF or in markdown files or wiki or maybe even a graph database. Hex wrote a really good article and they how they use graphs under the hood. And so the storage format I actually don't think is the super important thing. I think there's kind of like two key things to think about and I touched on it briefly but one is basically as the agent runs can it make updates to memory can it not make updates to memory and generally where I think we're aligning internally is that it can some sometimes it can or it can always basically take notes because as the agent is running it might notice what's missing it might notice what's out of date and you don't want to have to rediscover that later on.
这非常有价值。所以你想给你的代理一种在运行时记笔记的方式。接下来还有一个独立的问题:这些笔记是否会立即对其他代理或其他线程可见,还是要等一个类似策展代理的角色来处理。这个策展代理就是负责“做梦”的代理。它在后台运行,按某种计划定期启动。它基本上会查看各个代理记下的内容,也会查看其他来源。具体看哪些来源,取决于情况。所以,如果你说的是技能,也就是程序性的内容——如何做事——那么最值得查看的来源就是代理轨迹。这非常有价值。如果你只是在寻找各种零散的信息,代理轨迹也有价值,但其他来源同样有用。That's super valuable. And so you want to give your agent a way to take notes as it's running. And then a separate question is like whether those notes are then immediately visible to other agents or other threads or whether you wait for kind of like a curator agent. And the curator agent is the dreaming agent. It's the agent that's running in the background. It runs on some schedule. and it will basically look at the notes that the agents have made. It will look at other sources as well. and those sources depend. So if you're talking about skills, which are procedural things, how you do things, the best source to look at is agent traces. That's super valuable. If you're looking for just like arbitrary things of information, agent traces are valuable, but so are other things.
比如,你可能会想在 Notion 或 Slack 中查看各种互动,然后开始将这些内容整合到公司的知识库中。我昨天用过一个说法,叫“知识工厂”。我觉得你们会想搭建这样的知识工厂,让知识保持最新。我还觉得,知识有不同类型,所以很难用一个通用方案来处理。过段时间我可能会为此写一篇更详细的博客。Like you might want to look across notion or across Slack and see other interactions and then start to incorporate that into a company knowledge base. one term that I used yesterday is like a knowledge factory. Like I think you'll want to build these knowledge factories for keeping knowledge up to date. And I think there's different types of knowledge which makes it hard to have a generic thing. and so I'll probably write a more detailed blog on that in a bit.
观众提问:你怎么看待让智能体在一个长期会话中持续运行,与将内容写入缓冲区作为长期记忆、然后开启新会话这两种方式?也许这就是“做梦”这一概念的核心所在。Audience question: How do you think about persistent agents running in one long session versus when you write to buffer long-term memory and start a new session? Perhaps this is what the dreaming concept is all about.
Harrison Chase:是的,我觉得……我的意思是,相关的一件事是,对于这些始终在线的智能体,你是用一个很大的对话线程,还是每次你在 Slack 里给它发消息时,它都会另开一个线程?我觉得……我不知道这有没有正确答案。我觉得像 Muse 和 Instinct 这样的产品,表面上看起来是一个很大的线程。顺便说一句,完全可以表面上只有一个大线程,但实际上在底层根据时间使用不同的线程,同时配备一个非常好的记忆系统。我不知道自己有没有很好的答案。我确实认为——无论如何,你都希望赋予智能体搜索其他对话的能力:要么只有一个很大的对话,让智能体能够搜索之前的消息;要么有一堆线程,让智能体能够跨线程搜索。Harrison Chase: Yeah, I think there's I mean so one related thing is basically like for these always on agents do you have one big thread or does each time you message it in Slack and whenever it starts a separate thread and I think like I don't know if there's a right answer here like I think things like Muse and Instinct on the surface have one big thread by the way it's totally possible to have one big thread on the surface but under the hood actually use different threads based on kind of like the time and just have a really good memory system. I don't know if I have a great answer here. I do think the I do think regardless you want to give agents an ability to search other conversations whether that's like one big conversation and you just give the agent the ability to search previous messages or it's a bunch of threads and you just give the agent the ability to search across threads.
两者都很重要。所以,关键在于:究竟是一个大的讨论串,还是一堆彼此独立的讨论串,其实没那么重要。时间到了。这里有很多很好的问题。我不太确定能不能回答所有问题,因为我正在往下滚动,问题实在太多了。在 LangChain,我觉得我们才刚刚开始探索这些持久化智能体。我们会发布更多相关内容。我会看看这些问题;如果有关于记忆之类的重复问题,我或我们的团队会针对这些内容做些分享,比如办网络研讨会、写博客文章之类的。Both are important. and so, that's the important thing whether and then whether there's one big thread or a bunch of, a bunch of separate ones doesn't matter so much. we're at time. There's a bunch of good questions here. I don't 100% I'm not going to be able to answer all of them because I'm scrolling down. There's a lot. At LangChain, I think we're at the start of these persistent agents. We're going to put out a lot more content on these. I will look at a lot of these questions and if there are repeated ones around memory or stuff like that either I or our team will we 'll we'll we'll do some stuff on that or either webinar or blog or things like that.
所以,感谢大家的到来,也感谢大家提出的所有问题。让我们一起去构建一些智能体吧。So thank you all for coming thanks for all the questions. let's go build some agents.