Skip to content

fix(provider): retry OpenAI Responses API on 404 errors#10507

Closed
zerone0x wants to merge 1 commit intoanomalyco:devfrom
zerone0x:fix/issue-10505-openai-404-retry
Closed

fix(provider): retry OpenAI Responses API on 404 errors#10507
zerone0x wants to merge 1 commit intoanomalyco:devfrom
zerone0x:fix/issue-10505-openai-404-retry

Conversation

@zerone0x
Copy link
Contributor

Summary

  • Add isRetryable callback to openaiFailedResponseHandler to mark transient errors as retryable
  • OpenAI's Responses API can return 404 for transient "Item not found" errors
  • Enables automatic retry through the existing SessionProcessor retry mechanism

Retryable status codes: 404, 408, 429, 500, 502, 503, 504

Fixes #10505

Changes

  • packages/opencode/src/provider/sdk/openai-compatible/src/responses/openai-error.ts - Added RETRYABLE_STATUS_CODES set and isRetryable callback

Test plan

  • Verify OpenAI 404 errors are retried automatically
  • Verify other retryable status codes (429, 500, etc.) trigger retry
  • Verify non-retryable errors (400, 401, 403) do not retry

🤖 Generated with Claude Code

OpenAI's Responses API can return 404 for transient errors (e.g., "Item
with id 'msg_xxx' not found"). Add isRetryable callback to mark these
errors as retryable, enabling automatic retry through the existing retry
mechanism in SessionProcessor.

Retryable status codes: 404, 408, 429, 500, 502, 503, 504

Fixes anomalyco#10505

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@tim-smart
Copy link
Contributor

I tried this change and it does not fix the issue.

@zerone0x
Copy link
Contributor Author

Thanks for testing! A few diagnostic questions:

  1. Are you seeing the 404 on the initial request or mid-stream? This fix targets the openaiFailedResponseHandler which handles HTTP errors from the initial API call.

  2. Could you share the full error message/output? The "Item not found" error might be coming through a different code path.

  3. Is this happening with streaming enabled? If the 404 occurs during the SSE stream (as an error event rather than HTTP status), it might bypass this handler.

I traced the code flow and the isRetryable callback is being set correctly and should propagate through:

  • openaiFailedResponseHandlerAPICallError.isRetryableMessageV2.APIError.data.isRetryableSessionRetry.retryable()

If you can share more details about the specific scenario, I can investigate further or add logging to pinpoint where the issue is.

@tim-smart
Copy link
Contributor

Fixed in #10590

@zerone0x zerone0x closed this Jan 27, 2026
@zerone0x zerone0x deleted the fix/issue-10505-openai-404-retry branch January 27, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If openai responds with a 404 status, retry the request

2 participants