用 Codex App Server 构建自己的智能体界面
原题Building on the Codex Harness — Dominik Kundel, OpenAI
看前速览
Dominik Kundel 展示怎样复用 Codex App Server 的会话与工具接口,构建定制智能体客户端。
Codex App Server 是封装 Codex Harness 的开放协议。
它支撑官方应用和 IDE 扩展,也可供 JetBrains、Xcode 等第三方客户端使用;协议提供比通用 Agent Client Protocol 更细的 Harness 控制,并允许连接兼容 Responses API 的模型。
120 多种客户端消息向自定义界面开放应用级能力。
消息涵盖会话与轮次管理、目标、插件、文件搜索和文件系统操作。用户还可通过 ChatGPT 登录,让使用量计入自己的 Codex 配额。
用开发者指令和延迟加载的动态工具定制行为。
开发者指令追加到针对模型调优的系统提示之后,动态工具可经工具搜索按需发现,减少上下文占用;模型、供应商和沙箱权限也能按会话配置。
应用应自带匹配版本的 Harness 二进制。
App Server 随 Codex CLI 发布,协议会随版本演进。随应用打包二进制,并生成对应版本的 TypeScript 绑定或 JSON Schema,可以降低兼容性风险;Python SDK 也是可用入口。
完整交互客户端用 App Server,脚本任务用 codex exec。
codex exec 适合 CI 等非交互任务;App Server 更适合自定义客户端和并行会话。Doom 演示表明界面可以脱离传统聊天形态。
完整摘要
OpenAI 的 Dominik Kundel 介绍 Codex App Server 如何向官方和第三方客户端提供会话、事件、工具与权限接口。他演示检查协议消息、追加开发者指令和注册动态工具,并说明脚本任务与交互式客户端应选择不同接入方式。协议持续演进,因此客户端应配套分发匹配的二进制与类型定义。
文字稿
简要说明Brief Description
Building on the Codex Harness — Dominik Kundel, OpenAI
目录Table of Contents
- 简介Intro
- 什么是应用服务器?What is the App Server?
- Codex 背后的协议The protocol behind Codex
- 开源,支持任意模型提供商Open source, any model provider
- 工作原理How it works
- 演示:检查实时事件Demo: inspecting live events
- 120 多条客户消息120+ client messages
- 使用 ChatGPT 登录Sign in with ChatGPT
- 开发者指令Developer instructions
- 动态工具与延迟加载工具Dynamic and deferred tools
- 交付二进制文件Shipping the binary
- 绑定与传输Bindings and transports
- Python SDKThe Python SDK
- 或者直接问 Codex】【。Or just ask Codex
- 《Doom》中的 CodexCodex inside Doom
- 演示:为 Doom 提供工具Demo: giving Doom tools
- 应用服务器 vs codex execApp Server vs codex exec
- 三个技巧Three tips
简介Intro
好了,各位。大家好。嗯,我想先请大家快速举一下手。你们当中有多少人自己搭建过智能体运行框架?好。有多少人觉得搭建智能体运行框架实在太让人望而生畏了?好,不错。那么接下来的大约 18 分钟里,我想和大家聊聊如何基于 Codex harness 进行构建,希望能让大家更轻松一些,不再觉得那么难以着手,从而真正为智能体运行框架构建自己的界面。希望这个过程也能有点乐趣。呃,我叫 Dom,在 OpenAI 工作,主要负责 Codex 的开发者体验。嗯,我还想再请大家举一次手。All right, everyone. Hi, everyone. Um, I want to start with a quick raise of hands. How many of you have built your own agent harness? All right. How many of you um, feel like it's way too intimidating to build an agent harness? Okay, cool. So, uh, over the next 18 minutes or so, I want to talk to you all about how you can actually build on top of the Codex harness and hopefully make it a bit easier and less daunting for you to um, actually build your own interfaces on an on an agent harness. And hopefully also a little bit fun. Uh, my name is Dom. I work uh, at OpenAI on developer experience specifically for Codex. Um, and I have one more raise of hands.
什么是应用服务器?What is the App Server?
我保证会让大家歇一会儿。嗯,有多少人听说过 Codex app server?好,这个问题有点像个陷阱,因为如果你们昨天参加了主题演讲,就都应该举手。嗯,不然你们大概就没听 Roman 讲了。嗯,不过我们昨天简短地提到过它,但并没有真正解释 app server 是什么。I promise I'm going to give you all a break. Um, but how many of you have heard of the Codex app server? All right, and this was a bit of a trick question because if you attended the keynote yesterday, all of you should have raised your hand. Um, otherwise you probably didn't listen to Roman. Um, but uh, we talked briefly about it yesterday, but we didn't really explain what the app server is.
Codex 背后的协议The protocol behind Codex
嗯,实际上,app server 是一种封装 Codex harness 的协议。嗯,如果你了解过 agent client protocol 之类的东西,就会发现这是一个非常相似的概念:我们有一种协议,让你能够直接基于这个 harness 构建,并与它深度集成。我们也会在演讲中简单聊聊 app server 和 ACP 之间有什么区别。Um, so the app server is actually the protocol that wraps the Codex harness. Um, if you've ever looked into something like agent client protocol, this is a very similar concept where basically we have a protocol that allows you to directly build on top of the uh, harness and deeply integrate into it. And we'll talk a bit in the talk about what the differences are between uh, app server and ACP.
开源,支持任意模型提供商Open source, any model provider
呃,这里最重要的一点是,Codex 运行框架和应用服务器本身都是开源的。我们会介绍几种你可以参与其中的方式。嗯,更重要的是,明天下午我们会深入探讨其中一些功能在幕后是如何运作的;当然,你也可以随时让 Codex 阅读代码仓库,深入了解。它采用 Apache 2.0 许可证,所以欢迎你 fork、改造并打造属于自己的版本,尽情享受其中的乐趣。只要其他模型提供商有兼容 Responses API 的接口,你甚至可以将它连接到任何其他模型提供商。我们还提供了便捷的设置,让你能轻松连接 LM Studio 或 Ollama。Uh, the big thing here to keep in mind is both the Codex harness as well as the app server itself are open source. So, we're going to cover a couple of different things on how you can engage with it. Um, but more importantly, we're going to both dive tomorrow in the afternoon into how a couple of these things work behind the scenes, but you can also always just ask Codex to read the repo and dive really deep into it. It's Apache 2 license, so feel free to fork it, do it make it your own and have have fun with it. You can even connect it to any other model provider as long as they have a responses API capable compatible API. We even have convenience settings to connect it easily to LM Studio or Ollama.
工作原理How it works
嗯,说到它的工作方式,应用服务器协议是一种 JSON-RPC 风格的协议,我们实际上用它来驱动 Codex 应用、IDE 扩展、VS Code 扩展,也就是我们所有的第一方界面,以及第三方界面。所以,如果你曾经通过 Xcode、JetBrains IDE,甚至一些开源项目(比如 Theos T3 Code 或 Remote X)使用过 Codex,那么这些实际上都是由同一套运行框架、同一个应用服务器驱动的。今年早些时候,我们甚至也用它通过同一个应用服务器把 Codex 集成到了 Cloud Code 中。所以,如果你还在使用 Cloud Code,并且想在那里使用 Codex 来审查代码,或者把任务交给 Codex 处理,实际上可以使用那个插件;它在幕后使用的也是同一个应用服务器、同一套运行框架。如果你了解过 ACP 之类的东西,这应该会让你觉得很熟悉。Um, in terms of how it works, the app server protocol is a JSON RPC style protocol that we actually use to power the Codex app, the IDE extension, our VS Code extension, so all of our first-party interfaces, but also third-party ones. So, if you've ever used Codex through Xcode, JetBrains IDEs, or even some open-source projects like Theos T3 Code or Remote X, you can actually all of these are powered by the same harness, the same app server. We even used it earlier this year to put Codex into Cloud Code using that same app server. So, if you're still on Cloud Code and you want to use Codex from there either to have it review your code or you know, pass off tasks to Codex to handle it, you can actually use that plugin and it uses that same app server, that same harness behind the scenes. If you've looked into things like ACP, this should seem pretty familiar.
从宏观上来说,应用服务器的工作方式基本就是:我们会在客户端(也就是你正在构建的应用)和服务器(也就是 Codex 应用服务器)之间发送消息,以执行不同的操作并接收事件。不过,我没有给你看一堆假设性的消息,而是有点做过头了,实际上……At a high level, basically the app server, the way it works is we're going to send messages between the client, which is the application you're building, and the server, which is the Codex app server, to perform different actions and receive events. But, rather than showing you a bunch of hypothetical messages, I went a bit overboard and actually
演示:检查实时事件Demo: inspecting live events
我构建了一个小型检查器,用来拦截真实 Codex 应用和 Codex 应用服务器之间的所有事件,这样我们就能查看一些真实事件。现在我切换到 Codex 应用这边。嗯,我在 Codex 应用的浏览器中加载了同一个检查器。所以,如果我们发送一条消息,就会看到这里涌入一大堆不同的事件。乍一看可能会让人有点不知所措,但当你逐条浏览这些消息时,其中很多内容应该会让你觉得相当熟悉。我们可以看看这里的内容……嗯,有些可能是……我再操作一次。嗯,我想之前缓冲了一些旧事件,所以我会重新开始一个。嗯,好了。还有,别在意我上面的 Codex pad。呃,你会看到各种不同的消息,比如线程启动时带有不同的配置,说明实际发生了什么、我们正在处理哪个项目,接着还有配置读取。built a little inspector that intercepts all of the events between the real Codex app and the Codex app server, so we can look at some real events. Let me actually switch over here to the Codex app. So, I loaded up that same inspector in the um, that browser here of the Codex app. And so, if we send a message, we're going to see here a bunch of different events coming in. This might seem daunting at first, but as you're sort of going through some of these messages, a lot of this should feel relatively familiar. So, we can look through here um Some of these might be a Let me do this once more. Um I think I had some old ones buffered, so I'm just going to start a new one. Um There we go. Also, don't mind my Codex pad up here. Uh but you're going to see like different messages from like threads being started with sort of your different configurations of what is actually happening, what project are we working on, over to configuration reads.
嗯,新线程是在这里启动的,接下来这里展示的是一些增量消息,比如数据实际流入的情况。因此,你可以在这里找到很多额外信息。让这个协议如此灵活的一大原因是,我们实际上公开了应用中的所有内容,也就是关键功能。这意味着,如果我们正在流式传输内容、执行文件搜索,所有这些信息都会在应用服务器和应用之间来回传递。因此,如果你正在构建自己的 harness 集成或客户端,就可以利用相同的功能。事实上,我们目前有超过 120 个……Um Where is new threads being started, and then here's like some of your delta messages of like data actually being streamed in. And so, there's a lot of additional information that you can find here. And one of the big things that makes this protocol so flexible is that we're really exposing anything that is really in the app, a key functionality. Meaning, if we're streaming in things, we're doing file search, all of that information is actually handed back and forth between the app server and the and the app. And so, if you're building your own harness harness integration, your own client, you can actually leverage the same capabilities. In fact, we have right now over 120
120 多条客户消息120+ client messages
因此,这是各种客户端消息,我们会持续添加更多内容。嗯,范围涵盖从初始化开始——你可以配置一些更具体的客户端设置——到线程修改和轮次,这些大概是你最熟悉的经典功能。但也包括设置目标(如果你想实现自己的目标模式)、列出插件,以及应用中可能出现的各种其他功能,乃至文件搜索和修改文件系统。这样你就能获得完整的访问权限。我们也尽量让配置底层代理变得简单。这与 ACP 略有不同,ACP 是一种更通用的协议。通过我们的协议,我们实际上还能让你更好地控制 Harness 的各个部分。so different client client messages that we continuously add more to. Um and this goes from everything from initialization where you're able to configure some of the more like specific things to your client, over thread modifications and turns, which are sort of the things that you would assume are like the most classic things. But also stuff like setting a goal if you want to implement your own version of goal mode, and listing plugins, doing all of the different other aspects that you might see in the app, all the way to things like file search and modification modifying the file system. So you can really have that full access. We also try to make it easy so that you can configure the underlying agent. And that's a bit different to ACP where it's a more more generic protocol. We can actually give you more control over the individual parts of the harness as well through the protocol.
我们稍后会深入探讨这一点。另一件让很多人兴奋的事情是,你实际上可以……And we'll look into that in a second. The other thing that is exciting for a lot of people is you can actually
使用 ChatGPT 登录Sign in with ChatGPT
如果你使用这个协议,就可以把使用 ChatGPT 登录作为其中一部分。这意味着,如果有人在使用你的应用,他们仍然可以使用自己的 ChatGPT 订阅,而相关用量会计入他们的 Codex 使用限额。所以,如果你使用 T3 Code 或类似产品,实际上用的就是这种方式。至于自定义智能体,如果你正在构建应用,最值得关注的可能是两件事——最大、最重要的两件事。if you're using this protocol, you can have sign in with chat GPT as part of that, meaning that if someone is using your app, they can still bring their own chat GPT subscription and it goes off their Codex use usage limits. So if you use something like T3 code or similar, you're actually using that. In terms of customizing the agent, the most the biggest two things that you might want to look at if you're building
开发者指令Developer instructions
在这个应用服务器之上,还有开发者指令,你可以通过它来扩展实际应用的系统指令,同时引入工具。因此,使用开发者指令时,我们实际上是在 Codex 的系统提示词之上追加内容。你也可以在代码仓库中查看 Codex 的实际系统提示词。不过,我们通常建议你使用开发者指令在其基础上追加内容。这样一来,你既能利用我们为针对各个模型调整提示词所做的工作,又能根据你使用的运行框架的具体场景进行定制。例如,加载 Codex 应用时我们就是这么做的,因为有些功能是应用特有的,而不是 IDE 扩展或……on top of this app server is developer instructions as a way for you to augment the instructions the system instructions of the actual app, as well as bringing tools. So with developer instructions, we're actually appending on top of the system prompt of Codex. You can look at the actual system prompt of Codex as well as in the repo. Um but we generally recommend that you actually append to that using the developer instructions. That way you're still leveraging all of the work that we put into tweaking the prompts for the individual models, while still customizing it for your specific use case of the harness. This is for example what we do when you load up the Codex app, since there's some functionality that is more specific for the app over like the IDE extension or
动态工具和延迟加载工具Dynamic and deferred tools
CLI 示例。另一方面是动态工具,你可以公开希望代理能够使用的其他函数。你可以使用 MCP,或者使用类似 Agent Client Protocol 中的其他方式;也可以直接定义工具,还可以将它们标记为延迟加载。这意味着你无需将这些工具注入系统提示词,而是允许 Codex 使用工具搜索工具(我们明天的另一场会议会进一步介绍),通过搜索来查找这些工具,而不是让它们占用整个上下文窗口。此外,你甚至可以针对每个线程修改代理的其他配置。比如,设置不同的模型提供商、选择不同的模型,或者对沙盒进行精细控制,例如指定它可以访问哪些网络连接,或可以修改哪些文件。CLI example. And then the other part of this is dynamic tools, where you can expose additional functions that you want to that you want the agent to be able to use. You could use MCP or other things similar to what you would do in like the agent client protocol, but you can also just straight up define tools, and you can actually mark them as deferred loading, which means that rather than injecting them into the system prompt, it allows Codex to use a tool search tool, which we'll cover more tomorrow in the other session, but it allows it to find these tools through tool search rather than polluting the overall context window. And then on top of that, you can even on a per thread basis modify any other configuration that you might have for your agent. So, think about setting a different model provider, choosing a different model, or even doing fine-grained control on the sandbox, like what network connections it should have access to, or what files it can modify.
说到如何实际使用应用服务器,首先要做的是In terms of how you can actually use the app server, the first thing to
分发二进制文件Shipping the binary
我们知道的是,应用服务器实际上是 Codex CLI 的一部分。它们是同一个二进制文件。因此,如果你的系统上已经安装了 Codex CLI,现在就可以直接用它启动应用服务器。不过,你也可以看看我们是如何随 Codex 应用一起发布它的。例如,Codex 应用的实际安装包中就包含了这个二进制文件。如果你查看已安装的 Codex 应用,应该能在安装包内容中找到它;每次更新应用,这个二进制文件也会随之更新。我们会在后台发布新版 CLI。在 Windows 上,我们实际上会随应用发布两个版本的二进制文件:一个是 Linux 编译版,另一个是 Windows 版。这样,如果你在 WSL 模式下加载应用,它就会使用 Linux 版;否则,它会在 Windows 原生环境中启动应用服务器。know is that the app server actually comes as part of the Codex CLI. It's the same binary. So, if you have the Codex CLI already on your system, you can just use that to spin up the app server right now. But you can also look at how we're, for example, shipping it with the Codex app. So, the Codex app has the binary as part of the actual bundle. So, if you're looking into your installed Codex app, you should find it in the contents of that bundle, and it changes with every version of the app that you're updating. We're shipping a new version of the CLI behind the scenes. On Windows, we actually ship with two versions of the binary, both the Linux compiled one and the Windows one, so that if you're loading the app in WSL mode, it uses the Linux one, and otherwise it starts up the app server in Windows native.
嗯,从这里开始,你实际上还有很多不同的额外便捷功能。首先,你可以让 Codex 针对那个特定版本的应用服务器为你生成 TypeScript】【。Um from here, you actually have a lot of different um, additional convenience functionality. One, you can have Codex generate you for that particular version of the app server, the TypeScript
绑定与传输方式Bindings and transports
绑定,或者说 JSON schema,这非常有帮助,因为这个协议在不同版本之间经常变化。这也是为什么你实际上会想把它和应用程序一起打包——我们在 Codex 应用中就是这么做的,这样你就能完全掌控你预期要基于哪个版本构建,以及该版本实际具备哪些能力。嗯,说到协议,你可以通过标准输入输出(STDIO)或 WebSocket 来启动应用服务器。具体取决于你的使用场景;说实话,想知道哪种方式更适合你,最简单的办法可能就是直接问 Codex。嗯,接下来有两种最简单的集成方式。第一种是 Python……bindings or the um, JSON schema, which is incredibly helpful since this uh, protocol regularly changes between versions, which is also why you actually want to bundle it with your application, which is what we're doing with the Codex app, so that you have full control over what are the actual capabilities of the version that you're expecting to build against. Um, in terms of protocols, you can spin up the app server both using standard input output, so STDIO, or you can use web sockets. It's going to depend on your use case and honestly the easiest way to figure out what works better for you is probably to just ask Codex. Um, from here there's two ways that you can integrate it um, most easily. The first one is the Python
Python SDKThe Python SDK
我们最近重新——呃,发布了 SDK。它会为你处理很多生命周期管理方面的事情,所以你不必操心这些。除此之外,它还能让你更轻松地集成诸如“使用 ChatGPT 登录”之类的功能,并为你提供一个熟悉的界面。话虽如此,我们现在是在一场 AI 工程师大会上,所以嗯,你们中的大多数人可能都会选择……SDK that we recently re- uh, released. It handles a lot of the life cycle management for you, so you don't have to deal with any of that. And then on top of that, it makes it a bit easier for you to like integrate things like sign in with ChatGPT and gives you like a familiar interface. That being said, we are at an AI engineer conference, so um, probably most of you are going to choose
或者直接问 Codex。Or just ask Codex
第二种方式就是直接问 Codex。所以不出所料,Codex 非常擅长实现这个协议,你基本上只需要把文档交给它就行。大多数情况下,甚至不需要这么做,不过有时稍微提示它一下会有帮助。从这里开始,你可以把它和我们的任何插件结合使用,比如构建 macOS 应用——如果你想快速搭建点什么,或者彻底放开手脚都可以。举例来说,我用它通过 Visual Basic 构建了一个客户端,做成了真正原生的 Windows 应用,而且基本上一次就完成了。所以,借助它,你可以在相当短的时间内构建出非常出色的应用,而不必学习构建智能体的所有琐碎细节。不过,对我来说,这个应用服务器最有意思的一点是,你并不局限于经典的智能体聊天界面。option two, which is you just ask Codex. So unsurprisingly, Codex is incredibly good at implementing this protocol and you largely just have to point it at um, the documentation. In most cases, you don't even have to do that, but sometimes helps it to nudge it. Um, and from here you can combine it with any of our plugins like build macOS apps um, if you want to quickly spin up something or completely go wild. I used it for example to build a client using um, Visual Basic uh, to have a like truly Windows native app um, and it did it largely in one shot. So uh, you can build really impressive applications with this in a fairly short amount of time without you having to learn all the nitty-gritty parts of of building an agent. The most interesting thing for me with this with this app server though is that you're not limited to sort of the classic agent chat interface.
你真的可以尽情发挥创意,比如说,嗯,你究竟想如何在 UI 和现有应用中触发它,或者让它在后台运行;也可以像麦迪经常做的那样,把它放到一些奇怪的硬件上;又或者像我一样,你会考虑……You can really be creative whether it's um you how you actually like trigger it inside of your UI and your existing app, whether you're running in the background, whether you put it on weird hardware like Maddie does all the time, um or if you're like me, you think about
《毁灭战士》中的 CodexCodex inside Doom
我怎么才能把这个塞进电子游戏里呢?嗯,最近,大概一个月前吧,我在想,怎么才能真的在 Doom 里面运行 Codex,而不是在 Codex 里面运行 Doom。嗯,我想,不如现在就现场试试吧,我先把这几条消息关掉。呃,我有一个 Codex 应用的 Doom 版本,不过刚才在错误的窗口里启动了,我把它切过来。好了。这个……呃,控制操作出问题了,怪我。等一下。这个双显示器设置有时会搞乱控制输入的捕获,希望现在能好些。嗯,好了。这个是一个 Electron 应用,它使用了 Cloudflare 的 Doom Wasm 渲染器。呃,游戏引擎本身大部分是用 C 实现的,然后它加载了 FreeDoom 游戏,不过我实际上让 Codex 修改了游戏文件。所以你们可以看到,这些内容是直接在游戏里用它的游戏引擎渲染出来的。how can I shove this into video games, um and recently um I think like a month ago or so I thought about how can I actually run Codex inside of Doom rather than running Doom inside of Codex. Um and I figured let's actually do that live and I'm going to dismiss a couple of messages here. Uh so I have this Codex app Doom version and I booted up in the wrong window, so let me pull that over. There we go. So this is uh it messed up the controls, my bad. One sec. Something with this like dual monitor setup sometimes messes with the control capture, so let's hope that this works better now. Yep. Okay, so this is um an Electron app that has uh uses Cloudflare's Doom Wasm render um and it's uh so the most of the game engine itself is implemented in uh C and then it loads the FreeDoom game except that I actually manipulate had Codex change the game file, so you can see here this is rendered natively in the video game using all of their that game engine.
嗯,如果我们在这里实际与它交互,就会启动 Codex。再说一次,它是在真正的电子游戏内部原生渲染的,然后通过 Electron 的 IPC 协议将其传递给应用服务器。所以,如果我们在这里说“你好”,嗯,就能看到 Codex 做出响应。这里用的是 5.5。有趣的部分是……Um and if we actually interact with it here, we're booting up Codex and again this is rendered natively inside the um actual video game and then passes the passes it to the app server using Electron's um IPC protocol. So, if we say hello here, um we can see Codex actually responding. So, this is using 5.5. The fun part
演示:为 Doom 提供工具Demo: giving Doom tools
不过,你实际上可以使用动态工具来开放更多功能。所以很自然地,嗯,我们可以获取所有的护甲和生命值,而调用这些工具就能把这些信息都给我;甚至可以说,获取所有武器及其弹药。嗯,它会调用所有不同的工具。它就是这样与这些工具交互的。不过再提醒一下,这仍然是一个实际运行在我机器上的应用服务器。所以,如果我问“目录是什么?”,它实际上会调用 Z shell,获取当前工作目录。你可以看到这里渲染出来的——它有自己的工作区。所以,如果你愿意,可以直接在 Doom 里面编写代码。呃,我不确定是否会推荐这么做。我觉得 Codex 应用稍微好用一些。不过,你完全可以在这里玩得很开心,还可以实现自己的界面。though is you can actually use dynamic tools to expose additional functionality. So, naturally, um we can get um we can get all of the um armor and health, and it's calling the tools gives me all of that, or even say like all the weapons with all ammo. Um and it's calling all of the different tools. And so, it's interacting with that, but again, remember this is still an app server actually running on my machine. So, if I say like um what's the directory? It's actually calling Z shell, getting the current working directory, and you can see here it's rendering is ha it has its own workspace. So, if you want, you can write code directly into code in inside Doom. Uh not sure if I would recommend it. Uh I think the app the Codex app is slightly better for this. But, you can really have fun here and and implement your own interface.
太棒了。呃,节目期间我已经和你们中的几位聊过应用服务器,很多人都问到了一个问题……Awesome. Uh I talked with a couple of you already during the show about uh the app server, and one question that came up a lot of
应用服务器 vs codex execApp Server vs codex exec
那么,Codex Exec 有什么区别呢?如果你以前用过 Codex CLI,可能对它比较熟悉。还有一个叫 Codex Exec 的命令,它会启动一个非交互式界面,让你向 Codex 传递任务并启动执行。这非常适合编写脚本。如果你正在构建 CI/CD 流程,想把某些操作写成脚本,比如自动修复 PR,那这就是个很好的选择。 但是,如果你想构建一个更全面的客户端,用来与智能体交互、向用户展示智能体;或者更重要的是,如果你想同时启动多个不同的 Codex 线程,比如运行自己的评估工具,或者想使用类似 /goal 的功能,那么应用服务器就能大显身手了,因为你可以完全控制整个执行框架,也不必自己想办法并行调用所有 Codex Exec,只需发送一批新的线程事件,以这种方式启动任务即可。times is what's the difference with Codex Exec. So, if you've used the Codex CLI before, you're might be familiar with this. There's another command called Codex Exec, which spins up a non-interactive interface for you to uh pass uh to kick off tasks to Codex. This is great for scripting. If you're building a CI/CD implementation, and you want to script certain acts like auto fixing a PR, um this is a great opportunity. But, if you're trying to build like a more comprehensive client uh where you're interfacing where you're showing the agent or more importantly if you're trying to do something where you're spinning up a bunch of different Codex threads at the same time. For example, you're running you're running your own like eval harness or you want to use like slash goal. That's where the app server really shines because you have that full control over the harness and you don't have to figure out your own way of parallelizing all of the Codex exact calls rather than just sending off a bunch of like new thread events and spinning off tasks that way.
三个技巧Three tips
在让大家去听主题演讲之前,我还有三个小建议,来回顾一下我们刚才谈到的内容:如果你在使用应用服务器,有几件事需要牢记。第一,你应该随产品一起发布自己的 harness 版本。如果你依赖用户安装的 CLI,就会不断遇到各种麻烦,比如破坏性变更——尽管我们正努力尽量避免这类变更,但如果你依赖实验性功能,这种情况还是可能发生。此外,你也不必担心用户是否已经更新了版本、是否拥有你想使用的最新功能,或者是否需要催促他们更新。所以,请随产品一起发布自己的 harness 版本。另一个建议是,你绝对应该将新函数作为接口的一部分公开。Before I let you all go to the keynote, I have a three more tips just to recap what we talked about, things that you should keep in mind if you're using the app server. The first one is you should actually ship your own version of the harness. This will eliminate so many headaches for you if you're if you're relying on the user's installed CLI, you're going to constantly run into things from like breaking changes even though we are trying to minimize them, but if you're relying on experimental features that might happen. But you also don't have to worry about whether a user has actually updated their version and has the latest feature that you want to use or have them nudge them updating it. So ship your own version of the harness. The other part is you should absolutely expose new functions as part of your interface.
例如,我们会通过 Codex 应用来实现这一点,让它能够在 Codex 对话线程中控制自身,比如启动自动化任务等。不过,要将这些功能标记为延后加载。这样一来,你添加的各种额外功能就不会不必要地占用上下文窗口,同时这些功能仍可供智能体使用,也不至于让它感到困惑。如果你要修改指令,尽量先从添加开发者指令之类的做法入手,而不是直接改动基础指令。你可能会觉得自己想立刻着手编写专属的系统提示词,但在构建运行框架时,我们始终需要考虑许多不同的因素,以确保实际提示词能够得到分发,并确保智能体表现良好。We do this with a Codex app, for example, for it to be able to control itself as part of the Codex thread, like spinning up automations, etc. But mark them as deferred. That way you're not polluting the context window unnecessarily with all of the different additional functions that you're adding and instead still have them available for the agent without necessarily confusing it. And if you are changing the instructions, try to start with over like adding developer instructions rather than changing the base instructions. It might feel like you want to immediately rush to I'm going to write my own system prompt, but there is a lot of different things that we constantly have to think about when we're building a harness to make sure that the actual prompt is in distribution and make sure that the agent performs well.
如果你真的开始自己编写系统提示词,就会错失这一切。所以,如果你打算这么做,一定要谨慎。好了,非常感谢大家。感谢你们抽出时间。如果想拿到幻灯片,可以扫描那个二维码。我接下来大约 15 分钟都会在 OpenAI 展台附近,欢迎来问我任何问题。非常感谢。And you're losing out on all of that if you're actually jumping in and like writing your own system prompt. So be careful there uh if you're doing that. With that, thank you so much. Uh thanks for taking your time. Feel free to scan that QR code if you want to have the slides and I'll be around for uh like the next 15 minutes at the Open AI booth if you want to ask me any questions there. Thank you so much.