Agents SDK 新增工具审批与自定义模型客户端
Agents SDK v0.24.0-alpha.8 引入 Python 工具调用前审批、可接入自有模型客户端与 Session 实时语音,并新增工具搜索与 MCP 审批的可观测事件,同时调整流式 HTTP 与工具结果预算配置。
## 特工人员 SDK v0.24.0 - alpha.8. ## 突出内容 - **运行前批准 Python 工具调用 。** 校对:Soup [管理核准实例](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/examples/codex/managed_approvals/README.md#inspect-and-decide>) - **连接自己的模型客户端 。** 本土工具循环与Async Response and Chat Refults客户端,LiteLLM,AnyLLM,以及自定义适配器合作. [应用程序拥有的模型客户](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/models.md#use-an-application-owned-model-client>) - **向会话添加实时语音 。** 使用服务器WebSocket,在WebRTC上连接浏览器,或附在现有的SIP呼叫上. [实时连接选项](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/examples/codex/native_voice.md#choose-a-connection>) - **复作诸业.** 保存所支持的待决工具请求和批准。 请求和令牌预算会保留您恢复所支持的检查点时已经花费的用途 。 [以预算恢复检查站](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/examples/codex/budgeted-recovery.md>) - **在更多的Linux系统上安装.** 预览增加了一个ARM64轮子,两个Linux轮子都支持glibc 2.28或更新. [预览轮式平台要求](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/.github/RELEASING.md#L44>) ## 已添加 - 浏览工具搜索呼叫、工具搜索结果,并托管 MCP 批准决定通过 `ModelOutputItemCompleted`使用时 `include_execution_details=True` 以接收完整项目; 默认接收摘要。 [实时工具观测](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/packages/codex/src/_agents_codex/observation.py#L238-L267>) - 使用本地会话实时 API 从 `agents.realtime.native`,包括: `RealtimeAgentConfig(is_tool_enabled=...)`保留经典/ v0 实时进口 `agents.realtime`. [原声](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/examples/codex/native_voice.md#choose-a-connection>) · [经典进口](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/CLASSIC.md#compatible-voice-and-realtime-imports>) - 处理管理的函数核准 `FunctionToolApprovalRequest` 财务报告和财务报告 `FunctionToolApprovalDecision`设置 `run_input_policy_before_approval=True` 在批准前以及执行前执行输入政策。 `FinishTurn(output)` 从 `tool_batch_completion` 提出最后价值,并进行产出验证和完成检查。 [管理下的核准](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/examples/codex/managed_approvals/README.md#inspect-and-decide>) · [完成工具批次](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/outputs.md#finish-after-a-tool-batch>) - 仅在需要时创建远程对话 `ConversationsHistory.ensure_conversation_id()`。保留一个已检查的历史前缀。 `Session.replace_history_suffix(keep_prefix_count=...)`,并附加设置了检查点输入 `SessionState.with_appended_pending_input()`中读取 Unix毫秒 `StoredTurn.started_at_ms` 财务报告和财务报告 `completed_at_ms`. [历史 APIs](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/reference.md#history-and-storage-apis>) · [历史编辑](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/state.md#read-and-edit-original-history>) - 使用( U) `SQLAlchemySQLiteSessionStore` 用于一个应用程序拥有的同步SQLite引擎,以及 `ResponsesSocketFactoryOptions` 用于解析的 WebSocket 连接参数。通过 `TextLogprobsFact`, `TokenLogprob`, `TokenLogprobAlternative`,以及 `MalformedLogprobsFact`,但序列式记录类型不变。 `ModelRunOwner` 从 `agents.models` 财务报告和财务报告 `ApplicationToolOutput` 从 `agents.state`. [SQLite 存储](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/state.md#sqlalchemy-sqlite-storage>) · [模型所有权和套接字选项](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/reference.md#model-run-ownership-and-websocket-options>) · [日志事实](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/streaming.md#inspect-provider-logprobs>) - 组合新会话的快速缓存路由, 并明确 `TraceOptions.group_id`。在恢复会话时保留保存的缓存密钥。设置一个借用的模型适配器 `prompt_cache_key` 仅覆盖适配器发出的密钥。将路由作为亲和性处理,而不保证缓存命中 。 [快速缓存路由](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/observability.md#prompt-cache-routing-for-fresh-sessions>) - 道路工作,通过本地发货或请专家 `Agent.as_tool()`。添加输入和输出护栏,或使用 `Agent.decide()` 对于有明确投入的单独打字的决定。 [交接](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/sessions.md#hand-off-the-conversation-to-another-agent>) · [类型决定](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/examples/codex/decisions-guide.md>) - 使用独立的 Python 函数工具,并用别名选择 MCP 工具。 `ToolSearch`。函数工具还支持严格的计划、输出计划以及忽略额外参数的选项。 [Python 工具声明](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/tools.md#python-functions>) · [工具计划发现](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/tools.md#discover-tool-schemas>) - 使用 Redis, MongoDB, SQLAlchemy 或 Dapr Redis 状态组件存储支持的根对话通过 `CustomStorage`兼容性响应提供者还支持提供者管理的对话历史。 [应用程序自有存储](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/state.md#store-history-in-an-application-backend>) - 使用普通手动 `FunctionTool` 请求和预先核准 `HttpMCP` 工具为: `CustomStorage`。暂停一个支持的手动请求并恢复到独立的内存。要继续通过原后端,请使用一个未更改的检查点,并有一个未解决的普通手动呼叫。在等待MCP请求时,保留管理功能批准,并在同一后端恢复路径之外进行输入。 [CustomStorage 支持和检查站限制](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/state.md#store-history-in-an-application-backend>) - 打开只读执行环境, 提供技能, 或执行命令和补丁工具, 并附带应用程序的调用。 调用会随应用程序的权限运行 。 [仅读的工作空间](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/execution.md#inspect-a-read-only-workspace>) · [本地技能](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/execution.md#supply-native-skills>) - 为取样、重试、截止日期和快速缓存设定每个请求的模型选项。请求从一发运行中生成了项目和历史,或者选择输入提供推理摘要和工具参数三角洲。 [模式请求控制](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/models.md#model-request-controls>) · [流转和保留历史](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/streaming.md#inspect-observations-and-retained-history>) ## 已更改 - 原生流式HTTP可以谈判HTTP / 2. 缓冲响应继续使用HTTP / 1.1. - 设定 `NativeProvider(tool_output_token_limit=...)` 来调整模型上下文的大致工具-结果预算。留待设置后再使用模型的默认值。设置与最后的答案限制是分开的。 [工具输出限制引用](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/packages/codex/src/_agents_codex/agent.py#L488-L497>) ## 固定 - 接受工作前拒绝无效的网络启动请求机构并提示。 拒绝深度嵌入 JSON 、 非对象机构, 以及文本, 而无需有效的 UTF-8 编码 。 [网络启动请求验证](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/examples/codex/web_starter/app.py#L433-L474>) - 取消时等待确认的远程命令退出 。 执行者在确认退出时确认停止时报告失败 。 - 当经典收缩包装器没有明确的设置时, 保留后置商店配置的历史限制。 明确包装器和每个运行的限制仍然优先 。 - 严格 Python 工具在原参数失败验证时, 在批准或召回执行前, 将一个可重试错误返回模型。 需要时, 更正的调用仍会经过批准 。 [函数参数验证参考](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/packages/codex/src/_agents_codex/_function_tools.py#L1390-L1404>) - 在支持的检查站恢复时保存完成的工具结果。 在重启本地配置文件与中断的童工工作之前, 报告对和解的呼声不确定 。 [中断后恢复](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/state.md#recover-after-interruption>) - 保存已接受的模型设置和历史, 覆盖支持的交割和重试。 改善提供者错误报告, 以便应用程序能够查看请求失败之处 。 [检查提供者的反应尝试](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/streaming.md#inspect-response-attempts>) - Harden 保护本地工作空间元数据和证书文件。 减少简单运行的启动工作, 并重用符合条件的 HTTP 连接 。 ## 从0.24.0 - alpha.7升级 - 使用 alpha.8 方向盘处理这些注释中的特性。 有些链接的指南仍然提及开发构建。 如果一个实例需要寄存器的文件, 请使用这些注释中链接的修订版 。 Alpha.7 不接受更新的关键字, 如 `strict` 打开 `function_tool` 或 时 间 `model_backend` 打开 `NativeProvider`. - 对于 Linux 本地执行, 安装 `bubblewrap` 具有兼容性 `bwrap` 输入 `/usr/bin` 或 时 间 `/bin` 并允许沙盒命名空间创建。对于 Linux Docker 执行器,提供 `bwrap` 在容器图像或执行器捆绑中。 [Linux 执行器设置](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/execution.md#local-execution>) - **在升级前备份您的保存状态 。** Alpha.7 支持用于活运行的预算。 Alpha.8 添加了用于支持的待执行运行的检查点, 并附有请求或令牌预算。 检查点保存已经使用的请求或令牌, 以便它们在恢复后仍然数。 Alpha.7 拒绝这一新格式, 因为它无法执行所保存的预算。 我们核实这两个版本都可以重新开放闲置的检查点、 等待手动 Python 工具回复的检查点, 并关闭 。 `LocalStorage` Linux x86-64 上的配置文件。 这些检查使用了匹配两个版本可用的应用程序设置和特性。 如果alpha.7在回滚后无法重新打开您保存的状态, 请恢复您的升级前备份 。 [恢复一个预算编列的检查站](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/examples/codex/budgeted-recovery.md>) · [检查点恢复设置](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/state.md#supply-restore-configuration>) · [重新打开本地配置文件](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/state.md#reopen-a-conversation-from-local-storage>) - 替换赤色 `"*"` 包含精确主机或范围模式的网络域规则中的条目,例如: `"*.example.org"`。允许出站的公共主机,使用 `NetworkPolicy.allow_all()`。关于Linux,这也要求 `allow_all_unix_sockets=True` 和从主机服务和其他任务中分离出来的执行器。清晰的网络政策在Windows上仍未得到支持。 [网络政策和平台限制](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/execution.md#network-and-local-socket-access>) - 如果您依赖保存的 Codex 登录启用 ChatGPT Apps 工具, 请添加已有的 `ChatGPTAppsMCP` 向 Apps 工具声明。 提供 APps 令牌、 其账户 ID 以及您想要曝光的工具名称。 保存的 Codex 登录现在只提供模型认证 。 [ChatGPT 应用程序设置](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/mcp.md#connect-personal-chatgpt-apps>) - 如果你的代码读 `session.items()`中,每一次执行一次。 `function_call` 财务报告和财务报告 `function_call_output` 行可以随同执行的打字记录。匹配本地记录 `thread_id`, `turn_id`,以及 `call_id` 而不是数行或依赖历史光标 `id`。在升级前重新检查保存的历史阅读器和分析器。 [执行历史](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/docs/sdk/streaming.md#inspect-completed-execution>) - 如果使用经典 `WorkspaceJsonlSink`,在升级前选择日志预算。其默认值现在是 8 MiB 。超越了已存在的文件或待缓冲预算的跳动,并永久停止了该沉积;重新绑定不会重新启动它。为新的发件箱或更大的有限值创建一个新沉积 `max_bytes`,或使用 `JsonlOutboxSink` 或 时 间 `HttpProxySink` 工作空间外用于长寿日志。使用 `max_bytes=None` 仅用于需要无限读取的可信工作量。槽不会旋转或切换日志。 [工作空间吸收槽限制](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/src/agents/classic/sandbox/session/sinks.py#L143-L186>) - 如果你用这个 `classic-blaxel` 额外和插针 Blaxel, 将插针更新到 `0.2.51` 。用您的当前网络和端口设置测试保存的沙盒修复。 Brassel、 Cloudflare、 Daytona、 E2B、 Modal 和 Vercel 现在可以拒绝与当前策略相冲突的保存的设置。 创建一个新的沙盒, 设置所需的设置, 而不是放松重新使用旧状态的政策 。 [Blaxel依赖性](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/pyproject.toml#L113-L117>) · [示例恢复政策检查](<https://github.com/openai/openai-agents-python/blob/d6a81c997eabdc56108633eb3132fb3907f87d7e/src/agents/classic/extensions/sandbox/blaxel/sandbox.py#L1095-L1102>) ## 释放核查 资料来源: [`d6a81c997eabdc56108633eb3132fb3907f87d7e`](<https://github.com/openai/openai-agents-python/commit/d6a81c997eabdc56108633eb3132fb3907f87d7e>). 建造和试验 [测试 #43800450653](<https://github.com/openai/openai-agents-python/actions/runs/43800450653>). 所有四个平台上经过验证的新鲜安装有CPython 3.10和3.14. [安装检查](<https://github.com/openai/openai-agents-python/actions/runs/43805410415>)
查看原始来源