GPTMap

Responses API 背景完成窗口:soonest/2h/8h 折扣档与 SDK 双包 3.52–3.53、7.58 批次解读

官方 SDK 双包给 Responses 的后台执行补上完成窗口参数:completion_window 三档,2h/8h 为折扣档,另有调度 pause_reason、compaction 默认值翻转与 Live safety_identifier。本站以 tag 源码逐文件核对。

TL;DR
openai-python v3.53.0(2026-11-17)与 openai-node v7.58.0 给 Responses API 新增 background_options——completion_window 取值 soonest/2h/8h(缺省 soonest;官方文档串写明 2h 与 8h 选择折扣背景执行,要求 background: true、Standard processing、非流式),另有 continuation_id。python 侧 v3.52.0(11-16)已落地 pause_reason 与会话错误流投递。两包类型层另有 release notes 未列的两处:Agents compaction 默认值翻转为阻塞、Live 会话 config 三处补齐 safety_identifier。本站以双包产物逐文件 diff 核对。
背景完成窗口(background completion window)是 Responses API 在 2026-11-17 的官方 SDK 批次(v3.53.0 / v7.58.0)中新增的后台执行选项:请求参数 background_options 下挂 completion_window,取值 soonest(缺省)/2h/8h,其中 2h 与 8h 按官方文档串选择折扣背景执行,并要求 background 为 true、Standard processing、stream 为 false 或省略;同对象还有用于优先化相关背景请求的 continuation_id。

背景完成窗口(completion window)是 Responses API 后台执行在 2026-11-17 的官方 SDK 批次里新增的选项:请求参数 background_options 让开发者在后台执行时选择完成窗口——缺省的 soonest,或折扣档的 2h / 8h。本文按本站 2026-11-18 当日核对:openai-python v3.52.0(11-16)与 v3.53.0(11-17)、openai-node v7.58.0(11-17)三个版本的 PyPI sdist 与 npm tarball 逐文件 diff,类型层每一个参数名、每个枚举值、每处机制描述都出自当次提取;官方定价页与 background 指南当日对本站 403,涉及价格与行为语义的地方只转述类型文档串原文。

1. 参数形状:BackgroundOptions 与三档完成窗口

v3.53.0 的 src/openai/types/responses/response_create_params.py 新增请求参数 background_options: BackgroundOptions,类定义原文如下:

class BackgroundOptions(TypedDict, total=False):
    """Options for background execution on HTTP requests.

    The `2h` and `8h`
    completion windows require `background: true`, Standard processing,
    and `stream: false` or omitted.
    """

    completion_window: Literal["soonest", "2h", "8h"]
    """The completion window for background execution.

    Defaults to `soonest`; `2h` and `8h` select discounted background execution.
    """

    continuation_id: str
    """
    A customer-provided opaque identifier used to prioritize related background
    requests. It does not add prior history to the input.
    """

三档的官方口径:

取值官方文档串口径
soonest缺省值——不传 completion_window 时的行为
2h折扣背景执行档;要求 background: true、Standard processing、stream: false 或省略
8h折扣背景执行档;前置要求与 2h 相同

文档串没有给 2h / 8h 的折扣百分数,也没有定义"2 小时/8 小时"与完成行为的精确关系(超时后果、能否提前返回均未述)——本文按白名单纪律只写上面两行,其余以官方后续文档为准。同批可加载渠道里,官方定价页与 developers.openai.com 的 background 指南(SDK 文档串链接的 https://developers.openai.com/api/docs/guides/background)均 403,折扣幅度当日不可核。

2. 双形态:HTTP 请求参数与 WebSocket response.create

同一选项落在两个入口。HTTP 侧是上面 requests 参数;WebSocket 侧,responses_client_event.py 的 response.create 事件参数同批接受同形状对象——类名 ResponseCreateBackgroundOptions,字段为可选的 completion_window(同三值 Literal)与 continuation_id,类文档串与 HTTP 侧相同(要求三件套原文一致)。node 侧镜像:src/resources/responses/responses.ts 的 ResponseCreateParams 与 beta 变体都新增 background_options?: ResponseCreateParams.BackgroundOptions,interface 字段 completion_window?: 'soonest' | '2h' | '8h' 与 continuation_id?: string;两个入口的对象均为可选字段形状(出自当次提取)。

一个最小可用示例(HTTP 侧,python):

from openai import OpenAI

client = OpenAI()

resp = client.responses.create(
    model="gpt-5.6-terra",
    input="对这批工单做离线归类,输出标签与理由",
    background=True,  # 2h/8h 的前置条件之一
    background_options={"completion_window": "8h"},
)
print(resp.status)  # status / background 字段出自 v3.53.0 的 Response 对象类型

注意参数分工:background 决定是否后台执行,background_options 选完成窗口;2h/8h 的三个前置条件(background: true、Standard processing、非流式)全部出自类型文档串,缺一不可——文档串没有描述不满足条件时的报错形态,本文不补。

3. continuation_id:优先级排序,不带历史

continuation_id 的文档串原文是三句话:客户提供的、用于对相关背景请求做优先级排序的不透明标识符;它不会把先前的历史加进输入。字符串类型,官方未给格式约束或唯一性规则——"同一串值是否路由到同一队列"这类问题文档串没有回答,本文不推断。

4. 版本与上架时间线:python 两次、node 一次收两批

版本GitHub releaseregistry 上架(latest)内容
openai-python v3.52.02026-11-16T22:34:48ZPyPI 2026-11-16T22:41:05调度 pause_reason(#4278)、beta Agents 会话错误流投递(#4281);类型层另有 compaction 默认翻转与 Live safety_identifier 三处补齐
openai-python v3.53.02026-11-17T18:34:32ZPyPI 2026-11-17T18:41:11背景完成窗口、GPT-6.2 三个标识符(squash 提交 720bcb5)
openai-node v7.58.02026-11-17T18:13:41Znpm 2026-11-17T18:31:10v3.52.0 与 v3.53.0 两批内容的合集(#3158 调度 pause_reason;其余条目为同一 squash 提交 77e77ad)

三个时间戳口径:GitHub release 对象经 api.github.com 读取(2026-11-18 当日);PyPI 上架时间取该版本 wheel 文件的 upload_time(sdist 同版本晚数秒),npm 上架时间取 packument 的 time 字段,均当日读取。node v7.58.0 的 release notes 五条 feature 恰好是 python 两批 release notes 的并集(2h/8h 窗口、GPT-6.2 Astra Law / Astra / Sol 标识符、调度 pause reasons)——python 侧 11-16 没有对应的 node 发版,node 一次补齐。

5. v3.52.0 批次:调度 pause_reason 与错误流投递

pause_reason(#4278)。beta Agents 的两个调度对象各加一个字段:OneTimeAutomation 与 PeriodicAutomation 的 pause_reason: Optional[Literal["target_session_failed"]],文档串:Why the service paused this schedule, or null for other schedules——服务端暂停该调度的原因;取值当前只有一个(target_session_failed,目标会话失败),非暂停状态的调度该字段为 null。node 侧同批在 automations.ts 落地同名字段(pause_reason?: 'target_session_failed' | null)。

错误流投递(#4281)。release notes 标题 deliver beta Agents session errors as stream events。python 的落点可从当次提取指出:src/openai/resources/beta/agents/sessions/events.py 与 sessions.py 的四处流式调用加了 stream_mode="events";配套的 _streaming.py 里,stream_mode == "legacy" 时带内错误 payload 会被抛成 APIError,非 legacy 模式则把 payload 按普通数据解析、产出进迭代循环——即错误作为流事件到达而不是异常中断(这是本站对 tag 源码的机制解读;官方文字只有 release notes 标题)。node 侧在 v7.53.0(2026-11-06,本站 2026-11-08 批次核对)已先行落地同标题变更,python 侧本次补齐;两包的官方说明各自独立,本文不把它们画成同一条官方叙事。

6. release notes 之外的类型层变化:compaction 默认翻转与 Live safety_identifier

本批类型 diff 里有两组 release notes 没有列出的变化,两包同步:

Agents compaction 默认值翻转。涉及 python 六个类型文件(agent.py、agent_session.py、agent_update_params.py、agents/session_create_params.py、agents/automation_agent_config.py、agents/automation_target_param.py)与 node 对应文件。翻转前后的文档串(逐字):

位置v3.51.0 / v7.57.0(旧)v3.52.0+ / v7.58.0(新)
compaction 字段摘要Whether context is compacted in the background. Defaults to true.Whether context is compacted in the background. Defaults to false.
session create 的 compaction 说明Omission or null defaults to true. Set to false to use blocking compaction.Omission or null defaults to false. Set to true to enable background compaction.
null / 空对象语义null or an empty object enables background compactionnull or an empty object uses blocking compaction

也就是说:不传参数或显式传 null/空对象,行为从"后台压缩"翻转为"阻塞压缩";要后台压缩需要显式 async: true(或等价设置)。文档串同时保留既有提示:后台压缩可能增加 token 用量。这些字符串由 OpenAPI 规范生成——它证明的是官方规范改了默认值表述,服务端实际行为是否同步翻转,本批无法独立验证,以官方文档与实测为准。

Live 会话 safety_identifier(session config 三处补齐)。live 的 session config(创建参数、config 对象与 session resource 三处)自 3.52.0 起带上 safety_identifier: Optional[str](node 为 safety_identifier?: string | null,7.58.0 扩至 SessionConfig 与 SessionResource 两处),文档串:A stable identifier for your end user, used for safety monitoring and abuse detection——给终端用户的稳定标识,用于安全监控与滥用检测。这不是全新字段:python 3.51.0 的 media_session_config_param 与 session_accept_params、node 7.57.0 的 Session 与 MediaSessionConfig 已带同名字段——本批新增的是 python 的 session config 三处与 node 的 SessionConfig / SessionResource。格式约束与隐私处理口径官方未给,本文不补。

7. 同批的 GPT-6.2 标识符

v3.53.0 与 v7.58.0 的同一批 squash 提交还把 gpt-6.2-astra、gpt-6.2-sol 写进两包 ChatModel 枚举、gpt-6.2-astra-law 写进 Responses 模型联合,基线对照(v3.52.0 / v7.57.0)三处均无。模型定位、官方定价($8/$0.40/$40 与 $2/$0.10/$10)与可用性见姊妹文:《GPT-6.2 Astra 与 Sol 官宣:每 MTok $8/$40 与 $2/$10、Ultrafast 下放 Pro 200、SDK 类型层同日落地》。

8. 常见错误与排查

  • 只传 background_options 不传 background:2h/8h 的前置条件是 background: true + Standard processing + 非流式;BackgroundOptions 本身不开启后台执行,两者缺一即不构成合法的折扣背景请求形态(文档串口径)。
  • 沿用省略参数即后台压缩的旧行为:compaction 默认值已翻转(省略 = 阻塞);依赖旧默认值的代码升级 SDK 后行为会变,要后台压缩请显式设置。
  • 在流式请求上要 2h/8h:文档串写明 stream 须为 false 或省略;流式与折扣背景档按官方口径互斥。
  • 把 pause_reason 当调度失败标志:它是 Optional 字段、取值唯一(target_session_failed),且非暂停调度为 null;把它当布尔标志用会在正常调度上读到 None。
  • 在旧版 SDK 上找 background_options:该参数 v3.53.0 / v7.58.0 起才存在;v3.52.0 / v7.57.0 的请求参数里没有它(本站基线 grep 零处)。

9. 下一步

关键要点

  • 参数形状(本站以 v3.53.0 tag 源码核对):responses.create 请求参数新增 background_options: BackgroundOptions,内含 completion_window: Literal["soonest", "2h", "8h"] 与 continuation_id: str;WebSocket 的 response.create 客户端事件同批接受同形状的可选对象
  • 官方文档串口径:The 2h and 8h completion windows require background: true, Standard processing, and stream: false or omitted;completion_window 缺省 soonest,2h 与 8h 选择折扣背景执行(select discounted background execution)
  • 版本与上架(2026-11-18 本站经 GitHub API 与 registry JSON 核对):python v3.52.0 GitHub 2026-11-16T22:34:48Z / PyPI 22:41:05 即 latest;v3.53.0 GitHub 2026-11-17T18:34:32Z / PyPI 18:41:11 即 latest;node v7.58.0 GitHub 2026-11-17T18:13:41Z / npm 18:31:10 即 latest——node 一次收两批内容
  • python v3.52.0(11-16)批次:#4278 给调度对象加 pause_reason: Literal["target_session_failed"](service 暂停原因,其余调度为 null);#4281 把 beta Agents 会话错误改为流事件投递——四处调用点加 stream_mode="events",本站对 _streaming.py 的解读是非 legacy 流模式不再把带内错误 payload 抛成 APIError
  • release notes 未列出的类型层变化(两包同步):Agents compaction 默认值翻转——文档串由 Defaults to true(后台)改为 Defaults to false,null/空对象从启用后台压缩改为 blocking compaction;Live 会话 config 三处补齐 safety_identifier(string | null,用于安全监控与滥用检测;该字段在两包更早版本的个别 Live 类型已存在)
  • 同批还把 GPT-6.2 三个模型标识符写进类型层(ChatModel 与 Responses 联合),基线 v3.52.0 / v7.57.0 均无——模型定位与定价见 GPT-6.2 官宣专文

常见问题

官方 SDK 文档串只写明 2h 与 8h 选择折扣背景执行(select discounted background execution),本批可加载的官方渠道没有任何折扣百分数——官方定价页对本站 403,developers.openai.com 的 background 指南(SDK 文档串里链接的 https://developers.openai.com/api/docs/guides/background)当日同样 403 未能抓取。本文不给数字,折扣幅度以官方定价页为准。

官方参考

相关文章

订阅 GPTMap Weekly

每周一封邮件,精选 OpenAI 重要更新、深度解读与最佳实践。无广告,可随时退订。

提交后将在新标签页打开 Buttondown 完成订阅确认。

GPTMap Editorial发布于 2026-11-18 12 分钟阅读
测试环境(EEAT)
最后测试时间:2026-11-18
使用模型:Responses API(SDK v3.52.0 / v3.53.0 / v7.58.0 类型层核对)