Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

responses.parse() with background=True returns unparseable Response from retrieve() - missing ParsedResponse support for background mode

未关闭
#2,830 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@shouryamaanjain 已经在做这个了。

开始于 2026年3月1日。

  • #2909 来自 @shouryamaanjain —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
api

调研方向

从 responses.parse() 和 responses.retrieve() 入口开始,使用 background=True 和 MySchema 运行提供的 AsyncOpenAI 复现代码。跟踪每次调用如何构造其 response,然后将完成定义为以下二者之一:在检索过程中保留已解析的输出,或明确拒绝不受支持的工作流,并为所选行为添加覆盖。

由索引模型根据 Issue 内容生成。

描述

bug
Confirm this is an issue with the Python library and not an underlying OpenAI API
  • This is an issue with the Python library
Describe the bug

When using responses.parse() with background=True and a text_format (structured output), the initial call returns a ParsedResponse wrapper. However, when polling for completion using responses.retrieve(), a plain Response object is returned instead of ParsedResponse.

This means output_parsed is not available on the retrieved response, and users must manually parse output_text using their schema's model_validate_json().

The SDK accepts background=True in parse() without warning, but doesn't provide a way to complete the workflow with proper parsing.

Expected behavior:
Either:

  • retrieve() should accept a text_format parameter to return ParsedResponse
    A new retrieve_parsed() method should exist
  • Or parse() should raise an error/warning when background=True is used
To Reproduce

from openai import AsyncOpenAI
from pydantic import BaseModel

class MySchema(BaseModel):
name: str
value: int

client = AsyncOpenAI()

Start background request with structured output

response = await client.responses.parse(
model="gpt-4.1",
input="Generate a name and value",
text_format=MySchema,
background=True
)

Poll for completion

while response.status in ("in_progress", "queued"):
await asyncio.sleep(0.5)
response = await client.responses.retrieve(response.id)

This fails - Response has no output_parsed attribute

print(response.output_parsed) # AttributeError: 'Response' object has no attribute 'output_parsed'

Workaround required:

result = MySchema.model_validate_json(response.output_text)

Code snippets

OS

macOS

Python version

Python v3.12

Library version

openai v2.15.0

主要语言
Python
星标
31.8k
派生
7.3k
平均合并
1 天 1 小时
30 天内合并 PR
137

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openai/openai-python 的其他 Issue

查看 openai/openai-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。