Agents SDK 预览版将 Codex 接入 Python 运行时

Agents SDK 发布首个预览版,把 Codex 作为可选模型提供方接入 Python。该版本通过 PyO3 内嵌 Codex Core,省去 app-server 启动与 JSON-RPC 调用,并支持工具审批、会话压缩和沙箱清单保存。

## 特工 SDK v1.0.0 - alpha.1 此首个预览来自 `feat/simple-codex` 添加 Codex 作为 Python 代理 SDK 的选入模式提供者。 预建 `openai-agents` 轮子(版本) `1.0.0a1`)完全通过GitHub发布. ## 突出内容 - **每跑一次选择代码 。** 导入 `CodexProvider` 从 `agents.models.codex` 创建 `provider = CodexProvider()`传球 `RunConfig(model_provider=provider)` 到 Runner 。 Codex 使用您保存的登录。对于 API 密钥认证, 请使用 `CodexProvider(api_key=...)`。提供方为使用模型名称或默认模型的代理商选择模型。 [运行同一代理 。](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/models/codex.md#run-one-agent-with-either-provider>) - **在Python内部重新使用 Codex Core.** 轮子嵌入未修改的 Codex 核心 `rust-v0.166.0` 通过PyO3. 直接呼叫核心删除 `codex app-server` 启动和 JSON - RPC 重用提供者共享一个 `ThreadManager` 。每个呼叫都获得一条新线索。使用 SDK 会话记录历史,并关闭提供者 `await provider.aclose()` 当你完成。 [线程寿命和历史](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/models/codex.md#streaming-history-and-cancellation>) · [代码来源](<https://github.com/openai/codex/commit/6ff1e1ca3b30fc8b914720681fcf5fe62e95f856>) - **使用SDK工具和批准.** 流转文本, 交给专家, 在 Python 工具运行前暂停审批, 并验证输入输出。 本地命令遵循 Codex 的沙盒和批准设置。 本地批准提示结束模式调用 。 [执行和核准](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/models/codex.md#configure-execution>) · [支持的工具和模型设置](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/models/codex.md#supported-features-and-limits>) ## 安装并尝试 用标准的CPython 3.10 – 3.14 激活虚拟环境。复制您的平台链接并替换 `WHEEL_URL` 。每个链接都包含 SHA-256 文摘,该文摘将在下载轮盘时检查。 [所有四个轮子的校验和](<https://github.com/openai/openai-agents-python/releases/download/v1.0.0-alpha.1/SHA256SUMS>) [Linux x86-64 (glibc 2.28 +) (英语).](<https://github.com/openai/openai-agents-python/releases/download/v1.0.0-alpha.1/openai_agents-1.0.0a1-cp310-abi3-manylinux_2_28_x86_64.whl#sha256=bfc5db104b0bb36d7119c8fb3f1d2831b6b8b7d95b63b09b2162bb721433057d>) · [Linux ARM64 (glibc 2.28 +) (英语).](<https://github.com/openai/openai-agents-python/releases/download/v1.0.0-alpha.1/openai_agents-1.0.0a1-cp310-abi3-manylinux_2_28_aarch64.whl#sha256=8a776dccb6baa8c197c090305138818bb70411fa34706c128cca8e1acb080e15>) · [macOS 11 + 苹果硅](<https://github.com/openai/openai-agents-python/releases/download/v1.0.0-alpha.1/openai_agents-1.0.0a1-cp310-abi3-macosx_11_0_arm64.whl#sha256=19a49f51ff30a201252ab1059e7b3ca00ab2b53f9d935ae65c489a6ee3284eba>) · [视窗 x64](<https://github.com/openai/openai-agents-python/releases/download/v1.0.0-alpha.1/openai_agents-1.0.0a1-cp310-abi3-win_amd64.whl#sha256=4bd8f0910bc39ac0074663f1b6a19c6345ab221f1bddb6758e8ad4588a94efa8>) ``` python -m pip install --only-binary=:all: "WHEEL_URL" ``` 试试野生生物的例子,看看 `v1.0.0-alpha.1` 并用安装的轮子从寄存器根中运行下面的命令。如果您唯一的证书是保存的 Codex 登录,则设置 `OPENAI_AGENTS_DISABLE_TRACING=1` 首先在你的壳里。 [野生动物的例子](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/examples/model_providers/codex_provider.py>) · [认证](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/models/codex.md#authenticate>) ``` python -I examples/model_providers/codex_provider.py --codex ``` ## 固定 - 自动会话压缩为 Codex 使用本地对话历史, 包括批准暂停之后。 Concession 需要自己的 OpenAI 客户端或证书 。 [会话压缩](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/sessions/index.md#openai-responses-compaction-sessions>) - 保存的沙盒表会在您恢复运行时保存内置二进制文件。 如果您共享这些表单, 请在保存 non-UTF-8 内容之前更新所有阅读器 。 使用 `LocalFile` 当年长的SDK需要读取清单时. [显式兼容性](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/sandbox/guide.md#manifest>) ## 从带子预览中移动 如果使用的话 `Agent.run()` 或 时 间 `Session.submit()` 输入 `v0.24.0-alpha.8`中,将执行移至 `Runner.run()` 或 时 间 `Runner.run_streamed()` 选择 `CodexProvider` 在运行配置中。如果您使用 `agents.classic`导入 `Agent`, `Runner`,以及 `RunConfig` 从 `agents`. [上一个调制解禁](<https://github.com/openai/openai-agents-python/releases/tag/v0.24.0-alpha.8>) · [运行示例](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/models/codex.md#run-one-agent-with-either-provider>) 在您的 alpha.8 环境中完成待本地运行和审批。 `SessionState` 检查点使用与 Runner 不同的格式 `RunState`。以 alpha.1. 为对话历史启动新的 SDK 会话。 [SDK会议](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/docs/sessions/index.md#quick-start>) ## 释放核查 SDK套房通过合并 `feat/simple-codex` 承诺. CI 在每个平台的CPython 3.10 和 3.14 上建造了所有四个轮子,并测试了新的安装。 `SHA256SUMS`. [来源 `87e8f533`](<https://github.com/openai/openai-agents-python/commit/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc>) · [SDK测试](<https://github.com/openai/openai-agents-python/actions/runs/44792830595>) · [造轮和安装检查](<https://github.com/openai/openai-agents-python/actions/runs/44792830563>) 我们还在CPython 3.12上运行了野生动物模型和Linux x86-64轮子。专家从照片中辨认出一只美国野牛,称为Python目录工具,并返回了一张带有记录的ID的打字报告。 `synthetic-bison-001`. [实例和断言](<https://github.com/openai/openai-agents-python/blob/87e8f533c3b457fe632a5eb38ac42590d7f4d9fc/examples/model_providers/codex_provider.py>)

查看原始来源