跳到主内容
@wquguru
精选88OpenAI Agents SDK Python(GitHub Releases)AI 编程与模型

OpenAI Agents SDK v0.24.0-alpha.7:write_policy默认严格化

Agents SDK v0.24.0-alpha.7

原文
发到 X
推荐理由

Alpha版本包含write_policy默认策略收紧、MCP参数重命名及回调签名变更等破坏性更新。依赖此SDK的开发者务必在升级前检查环境配置与代码签名,避免运行失败或逻辑错误。

Agents SDK v0.24.0-alpha.7

Highlights

亮点

  • Use Classic workflows alongside native execution. Import the retained v0 runtime through agents.classic. This alpha also changes executor write defaults; review the upgrade actions before opening existing environments.
  • Keep conversations in your own storage. Add durable root Sessions with CustomStorage, and reconcile uncertain tool effects before resuming work.
  • Add voice and hosted tools to native agents. Connect speech workflows to a Session, or use FileSearch, CodeInterpreter, and ImageGeneration through compatible Responses providers.
  • Control context, completion, and usage. Transform model input, retain selected context during compaction, review proposed answers, and limit observed root usage.
  • 将经典工作流与原生执行并行使用。通过 agents.classic 导入保留的 v0 运行时。此 Alpha 版本还更改了 executor 写入默认值;在打开现有环境之前,请审阅升级操作。
  • 将对话保存在您自己的存储中。使用 CustomStorage 添加持久的根会话(Sessions),并在恢复工作之前协调不确定的工具效果。
  • 为原生代理添加语音和托管工具。将语音工作流连接到 Session,或通过兼容的 Responses 提供商使用 FileSearch、CodeInterpreter 和 ImageGeneration。
  • 控制上下文、补全和使用量。转换模型输入,在压缩期间保留选定的上下文,审查建议的答案,并限制观察到的根使用量。

Upgrading from 0.24.0-alpha.6

从 0.24.0-alpha.6 升级

  • Review Environment write policies. New Environments default to write_policy="strict", which requires a compatible Linux or macOS executor. The working directory remains writable; use writable_roots for additional directories. To retain the previous remote policy, including on Windows executors, set write_policy="legacy" and leave writable_roots=None. Local execution requires strict mode. When restoring legacy remote checkpoints or profiles, select legacy explicitly; reopening does not upgrade their policy. See the executor policy and restore rules.
  • Check implicit reasoning settings. The bundled model catalog changes the default reasoning effort from low to medium for gpt-6-astra, gpt-6.1-sol, and gpt-5.6-sol. Set model_settings={"reasoning_effort": "low"} explicitly if you need the previous effort. This describes bundled metadata; an explicit setting or provider model metadata can select another value. (#5517)
  • Rename MCP approval modes. Replace approval_mode="auto" with "native", and "approve" with "preapproved". The old values are rejected; the new names preserve their respective approval behavior.
  • Update child step callbacks. NativeAgents.before_step now receives one ChildStepContext, with context, child, and step_index, instead of separate child and step-index arguments. Root before_step callbacks keep their existing signature.
  • Handle MCP forms and URLs separately. ElicitationRequest is now the union FormRequest | UrlRequest. Use FormRequest.reply() or respond() for forms; use UrlRequest.reply_url_accept() or accept_url() for URL consent.
  • 审阅环境写入策略。新环境默认设置为 write_policy="strict",这需要兼容的 Linux 或 macOS 执行器。工作目录仍然可写;使用 writable_roots 设置其他目录。若要保留之前的远程策略(包括在 Windows 执行器上),请设置 write_policy="legacy" 并将 writable_roots 留为 None。本地执行需要严格模式。当恢复旧的远程检查点或配置文件时,请显式选择 legacy;重新打开不会升级其策略。请参阅执行器策略和恢复规则。
  • 检查隐式推理设置。捆绑的模型目录将 gpt-6-astra、gpt-6.1-sol 和 gpt-5.6-sol 的默认推理强度从 low 改为 medium。如果需要之前的强度,请显式设置 model_settings={"reasoning_effort": "low"}。这描述的是捆绑元数据;显式设置或提供商模型元数据可以选择另一个值。(#5517)
  • 重命名 MCP 批准模式。将 approval_mode="auto" 替换为 "native",将 "approve" 替换为 "preapproved"。旧值将被拒绝;新名称保留了各自的批准行为。
  • 更新子步骤回调。NativeAgents.before_step 现在接收一个 ChildStepContext 参数,包含 context、child 和 step_index,而不是单独的 child 和 step-index 参数。Root before_step 回调保持其现有签名。
  • 分别处理 MCP 表单和 URL。ElicitationRequest 现在是 FormRequest | UrlRequest 的联合类型。对于表单,请使用 FormRequest.reply() 或 respond();对于 URL 同意,请使用 UrlRequest.reply_url_accept() 或 accept_url()。

Added

新增

  • Application-owned conversation storage. SessionStore, SQLiteSessionStore, and CustomStorage persist root history and automatic Python tool results. This initial profile excludes native tools, Environments, children, planning tools, generated-code execution, manual tools, and portable checkpoints. SQLiteSessionStore requires one host and a local POSIX filesystem. Both local profiles and custom stores can report uncertain root calls for explicit reconciliation; neither automatically replays those effects. (#5514, #5502)
  • Provider-hosted tools and storage. Add FileSearch, CodeInterpreter, and ImageGeneration, Code Interpreter caller policies, and provider-managed storage. Hosted tools require an API-key provider and a compatible standard Responses model; they exclude Responses Lite and Codex login. Hosted web search adds domain and location controls and retains citations. (#5576, hosted-tool guide)
  • Context and completion hooks. Agent.transform_context changes sampled input without changing stored history. before_compact and selected-item retention control compaction. before_complete can accept, return ContinueTurn, or stop a proposed answer; rejected text may already have streamed and remains in history. Advanced prepare_request editing supports a restricted HTTP profile. See the hook contracts and limits.
  • Observed usage budgets. RunBudget limits root request admissions, reported tokens, or estimated cost before the next request. An admitted request can exceed a limit. Children are excluded; missing usage stops further admission by default. Active budgeted operations cannot use portable checkpoints. (#5555)
  • MCP resources, prompts, and reconnection. Use Session.list_mcp_resources(), list_mcp_resource_templates(), read_mcp_resource(), list_mcp_prompts(), and get_mcp_prompt() with a selected HTTP or stdio server while the Session is idle. Retrieved data does not enter model context automatically. Scoped tool selection and explicit reconnection preserve control over admitted tools without replaying uncertain calls. (#5597, #5604, #5556)
  • Local execution and project search. Environment.local() runs supported executor tools locally. On Linux, LocalStorageMount(source=path) grants read-only access to an existing canonical directory; source and destination must match. project_glob and project_grep search beneath the Environment's fixed working directory without granting command execution. (#5501, #5575, #5574)
  • Integration and supervision. Add native A2A client and server adapters through the a2a extra, explicit TraceContext, workflow tracing controls, API-key rate-limit snapshots, turn receipts, exact-turn steering, and attention waits. Classic integrations use the classic and classic-* extras; Classic and native objects and checkpoints remain separate.
  • Speech with native history and policies. agents.voice.NativeSessionVoiceWorkflow uses a caller-owned text-output Session with the speech pipeline. It speaks accepted final text after completion review and output validation. The application handles interactions and Session lifetime. Install the voice extra; Realtime agents remain under agents.classic.realtime. (#5596)
  • 应用拥有的对话存储。SessionStore、SQLiteSessionStore 和 CustomStorage 持久化根历史记录和自动 Python 工具结果。此初始配置不包含原生工具、环境(Environments)、子会话、规划工具、生成代码执行、手动工具和便携式检查点。SQLiteSessionStore 需要一个主机和本地 POSIX 文件系统。本地配置和自定义存储均可报告不确定的根调用以进行显式对账;两者均不会自动重放这些效果。(#5514, #5502)
  • 提供商托管的工具和存储。添加 FileSearch、CodeInterpreter 和 ImageGeneration,设置代码解释器调用策略以及由提供商管理的存储。托管工具需要 API 密钥提供商和兼容的标准 Responses 模型;它们不支持 Responses Lite 和 Codex 登录。托管网络搜索增加了域和位置控制并保留引用。(#5576, 托管工具指南)
  • 上下文和完成钩子。Agent.transform_context 在不更改存储历史的情况下改变采样输入。before_compact 和 selected-item retention 控制压缩过程。before_complete 可以接受、返回 ContinueTurn 或停止建议的答案;被拒绝的文本可能已经流式传输并保留在历史记录中。高级 prepare_request 编辑支持受限的 HTTP 配置。请参阅钩子契约和限制。
  • 观测到的使用预算。RunBudget 在下一个请求之前限制根请求的准入、报告的令牌数或预估成本。一个已获准的请求可能会超出限制。子会话被排除在外;默认情况下,缺失的使用量会阻止进一步准入。处于活动状态的预算操作不能使用便携式检查点。(#5555)
  • MCP 资源、提示词和重新连接。在 Session 空闲时,使用选定的 HTTP 或 stdio 服务器调用 Session.list_mcp_resources()、list_mcp_resource_templates()、read_mcp_resource()、list_mcp_prompts() 和 get_mcp_prompt()。检索到的数据不会自动进入模型上下文。作用域工具选择和显式重新连接可在无需重放不确定调用的情况下保持对已准入工具的控制。(#5597, #5604, #5556)
  • 本地执行和项目搜索。Environment.local() 在本地运行支持的执行器工具。在 Linux 上,LocalStorageMount(source=path) 授予对现有规范目录的只读访问权限;source 和 destination 必须匹配。project_glob 和 project_grep 在 Environment 的固定工作目录下进行搜索,但不授予命令执行权限。(#5501, #5575, #5574)
  • 集成与监督。通过 a2a extra 添加原生 A2A 客户端和服务器适配器,支持显式 TraceContext、工作流追踪控制、API 密钥速率限制快照、轮次收据、精确轮次引导以及注意力等待。经典集成使用 classic 和 classic-* extras;Classic 和原生对象及检查点保持分离。
  • 带有原生历史记录和策略的语音功能。agents.voice.NativeSessionVoiceWorkflow 使用由调用方拥有的文本输出 Session 配合语音管道。在完成审查和输出验证后,它会朗读已接受的最终文本。应用程序负责处理交互和 Session 生命周期。安装 voice extra;Realtime agents 仍位于 agents.classic.realtime 下。(#5596)

Changed

变更

  • Choose function-tool timeout handling. timeout_behavior="error_as_result" returns a timeout error to the model, with optional timeout_error_function formatting. Raising remains the default. (#5605)
  • Optional buffered Responses. NativeProvider(response_mode="buffered") reads each complete HTTP JSON response before emitting model output. Select a standard Responses model explicitly; the default model uses Responses Lite. Buffered mode requires API-key authentication and excludes WebSockets, native children, and Codex login. Streaming remains the default. (#5589)
  • Experimental saved-login reuse. NativeProvider(auth=CodexLogin()) can use a saved Codex login over HTTP. Omit api_key and base_url. This experimental feature may change or be removed; see the authentication guidance and limits.
  • 选择函数工具超时处理。timeout_behavior="error_as_result" 将超时错误返回给模型,并可选地格式化 timeout_error_function。默认行为仍是抛出异常。(#5605)
  • 可选的缓冲响应。NativeProvider(response_mode="buffered") 在发出模型输出前读取每个完整的 HTTP JSON 响应。需显式选择标准 Responses 模型;默认模型使用 Responses Lite。缓冲模式需要 API 密钥认证,且不支持 WebSockets、原生子级和 Codex 登录。流式传输仍为默认行为。(#5589)
  • 实验性的保存登录复用。NativeProvider(auth=CodexLogin()) 可通过 HTTP 使用已保存的 Codex 登录信息。省略 api_key 和 base_url。此实验性功能可能会更改或移除;请参阅认证指南和限制说明。

Fixed

修复

  • Keep Classic mount credential files private during creation and replacement, and bound Classic sandbox archive extraction.
  • Stop deferred work and automatic compaction after cancellation. Retain cleanup owners so callers can retry unfinished release of resources without repeating reconciliation or tool effects.
  • Stop sampling retries after terminal provider authentication failures. Report typed output-failure reasons and captured context limits, and preserve cache-write token counts.
  • Retain provider response observations and execution details under their configured policies. Reduce native startup and event-reading overhead.
  • 在创建和替换期间保持 Classic 挂载凭证文件的私密性,并限制 Classic 沙盒归档的提取操作。
  • 取消后停止延迟工作和自动压缩。保留清理所有者,以便调用方可以重试未完成资源释放的操作,而无需重复执行协调或工具效果。
  • 终端提供商身份验证失败后停止采样重试。报告类型化的输出失败原因和捕获的上下文限制,并保留缓存写入令牌计数。
  • 在其配置的策略下保留提供商响应观察结果和执行详情。减少原生启动和事件读取开销。

Release verification

发布验证

Source: c27b24cc6c4fa7e89ab54fa9f795ef4f2d4d5fb9.

来源:c27b24cc6c4fa7e89ab54fa9f795ef4f2d4d5fb9。

Built and tested by Tests #42453125392.

由测试 #42453125392 构建和测试。

Fresh-install checks passed on CPython 3.10 and 3.14 for Linux, macOS, and Windows: installation verification.

在 Linux、macOS 和 Windows 上的 CPython 3.10 和 3.14 上通过了全新安装检查:安装验证。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件