Background responses failures lack a stable code/name that maps to an exception class
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- python
調査の方向性
openai/_client.py とその _make_status_error メソッドから開始し、GET /v1/responses/{id} を介した background=true の POST /v1/responses のポーリングを追跡します。同期的な HTTP ステータスのマッピングと、失敗した Response および未完了の Response の処理を比較します。選択した安定したマッピングまたは文書化された契約が、これらのバックグラウンドの結果とその再試行可能性をカバーすれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Confirm this is a feature request for the Python library and not the underlying OpenAI API.
- This is a feature request for the Python library
Describe the feature or improvement you're requesting
When the Responses API runs in background mode (background=True) and a run terminates in status="failed" (or status="incomplete"), the SDK does not surface a stable, machine-readable identifier that callers can map to an existing exception class.
The failure payload looks like:
{
"status": "failed",
"error": { "code": "server_error", "message": "..." },
"incomplete_details": null
}
The HTTP poll itself returns 200 OK, so the SDK's status-code dispatcher is never invoked and no typed exception is raised. The only signal of what kind of failure occurred is the free-form error.code string, which:
- is not documented as a stable enum,
- does not correspond 1:1 to any SDK exception class (
server_error≠InternalServerError,rate_limit_exceeded≠RateLimitError, etc.), - is not guaranteed to be present or non-null for every failure mode (e.g.
incompleteruns surface their reason inincomplete_details.reasoninstead, with yet another vocabulary), - and may carry values not enumerated anywhere the SDK or callers can rely on.
What exists today (synchronous mode)
For synchronous calls there is a clean, code-driven mapping in openai/_client.py keyed on HTTP status code:
def _make_status_error(self, err_msg, *, body, response):
data = body.get("error", body) if is_mapping(body) else body
if response.status_code == 400: return BadRequestError(...)
if response.status_code == 401: return AuthenticationError(...)
if response.status_code == 403: return PermissionDeniedError(...)
if response.status_code == 404: return NotFoundError(...)
if response.status_code == 409: return ConflictError(...)
if response.status_code == 422: return UnprocessableEntityError(...)
if response.status_code == 429: return RateLimitError(...)
if response.status_code >= 500: return InternalServerError(...)
return APIStatusError(...)
So the synchronous path has a fully deterministic, documented contract: HTTP code → exception class. The background path has no equivalent — neither in the response body (no stable code) nor in the SDK (no dispatcher).
Why this matters
In synchronous mode the SDK gives us a clean contract. In background mode the same root cause surfaces only as an opaque string with no contract. Any retry/backoff logic built around isinstance(e, InternalServerError) or isinstance(e, RateLimitError) simply cannot work for background runs, even though those are exactly the conditions where retry would be most useful.
Suggested feature
Either:
-
Add a stable, documented field to background-run failure payloads (e.g.
error.typeorerror.class) whose values directly correspond to existing SDK exception classes — e.g.internal_server_error,rate_limit_error,bad_request_error,content_filter_error, etc. The SDK can then mechanically map this field to the right exception class, mirroring what_make_status_errordoes today for HTTP status codes. -
Or: publish a documented, versioned mapping from each possible
error.code/incomplete_details.reasonvalue to the SDK exception class (or "no class") and to a retryable flag. Treat it as part of the public API contract.
Either approach gives background runs the same deterministic contract synchronous calls already enjoy.
Environment
openaiPython SDK version:<fill in>- API:
POST /v1/responseswithbackground=true, polled viaGET /v1/responses/{id}
Additional context
No response
- 主要言語
- Python
- スター
- 32.2k
- フォーク
- 5.8k
- 平均マージ
- 12時間 29分
- マージ済み PR(30日)
- 112
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openai/openai-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
openai/openai-python#4338 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
openai/openai-python#4337 ·
メンテナーはふだん 1 日以内に返信
-
`BaseClient._prepare_url()` corrupts relative endpoint URLs when `base_url` contains query parameters対応中かも @Rewaskc02-lang が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openai/openai-python#4311 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openai/openai-python#4310 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
openai/openai-python#4309 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
openai/openai-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
bad-antics/lateralus-lang#1140 ·
メンテナーはふだん 4 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 3 日以内に返信
-
fixture good first issue help wanted vendor:cisco
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100