responses.parse() with background=True returns unparseable Response from retrieve() - missing ParsedResponse support for background mode
维护者通常 1 天内回复
评估
调研方向
从 responses.parse() 和 responses.retrieve() 入口开始,使用 background=True 和 MySchema 运行提供的 AsyncOpenAI 复现代码。跟踪每次调用如何构造其 response,然后将完成定义为以下二者之一:在检索过程中保留已解析的输出,或明确拒绝不受支持的工作流,并为所选行为添加覆盖。
由索引模型根据 Issue 内容生成。
描述
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
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openai/openai-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
openai/openai-python#4022 · 19 条评论 ·
维护者通常 1 天内回复
-
fix(auth): SubjectTokenProviderError drops response and duplicates error message in workload identity providers可能已有人在做 @mohmedmm 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
openai/openai-python#4017 · 3 条评论 ·
维护者通常 1 天内回复
-
Querystring drops explicit empty-string scalar values可能已有人在做 @sylvesterkaczmarek 于 33 天前认领。 未关闭sdk-breaking-change v4
难度 2/5 1-3 小时 新手友好度 86/100
openai/openai-python#3837 ·
维护者通常 1 天内回复
-
Define + export `ServiceTiers` string literal可能已有人在做 @SparshGarg999 于 60 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
openai/openai-python#3556 · 3 条评论 ·
维护者通常 1 天内回复
-
Empty OPENAI_BASE_URL prevents fallback to default API endpoint可能已有人在做 @Sehastrajit-S 于 26 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100
openai/openai-python#2927 · 6 条评论 ·
维护者通常 1 天内回复
查看 openai/openai-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
aws-samples/sample-per-model-bedrock#191 ·
维护者通常 1 天内回复
-
area: docs enhancement
难度 2/5 1-3 小时 新手友好度 64/100
PyTomography/PyTomography#331 ·
维护者通常 1 天内回复
-
effort: low prio: low ready
难度 2/5 1-3 小时 新手友好度 82/100
digitalfabrik/integreat-cms#4616 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
FuRongJun-1999/dsh-memory#226 · 1 条评论 ·
维护者通常 1 天内回复
-
bug difficulty:2 good first issue help wanted
难度 2/5 1-3 小时 新手友好度 88/100
MakazhanAlpamys/Soup#1865 ·
维护者通常 1 天内回复