Skip to content

Retry transient OpenAI Responses failures#532

Merged
ericdallo merged 1 commit into
editor-code-assistant:masterfrom
itkonen:retry-openai-responses-failures
Jul 15, 2026
Merged

Retry transient OpenAI Responses failures#532
ericdallo merged 1 commit into
editor-code-assistant:masterfrom
itkonen:retry-openai-responses-failures

Conversation

@itkonen

@itkonen itkonen commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Codex sessions can get interrupted by response.failed events while streaming, which currently just surface an error without attempting a retry. This PR routes those failure events through ECA's existing retry flow, so the session can continue when the error is transient and no partial response has already been shown.

AI Summary

This PR adds structured handling for OpenAI Responses API failures in both streaming and synchronous requests. When a stream emits response.failed, ECA now stops consuming the stream immediately, closes the HTTP reader, and only then forwards the failure to the existing retry orchestration. This also prevents stale events appearing after the failure from emitting text, preparing tool calls, or completing the response.

The full provider error payload is preserved for diagnostics and classification. ECA also records the response ID, normalized request ID, and response headers when available. HTTP 200 responses made with stream: false now recognize a failed response body and produce the same structured error shape as the streaming path.

Retry classification remains deliberately conservative. Structured server_error failures are treated as overloaded, while rate_limit_exceeded failures use the existing rate-limit handling. The generic transient message observed from Codex is accepted only as a fallback when OpenAI did not provide a structured error code or type. Unknown structured failures remain non-retryable, and user-defined retry rules continue to take precedence.

Retries reuse ECA's existing bounded retry implementation, including exponential backoff, rate-limit reset headers, retry limits, cancellation checks, and retry notifications. No separate provider-specific retry loop was introduced.

To avoid duplicating content, automatic retries are allowed only before user-visible output has been emitted. Text, reasoning, tool-call preparation, web-search activity, and image-generation activity all disable further retries for that response. Synchronous responses remain safe to retry because their output is buffered until the request succeeds.

Regression tests cover structured streaming and non-streaming failures, stream cleanup and trailing-event suppression, request and response metadata, transient and non-transient classification, custom retry-rule precedence, asynchronous and synchronous retry success, and prevention of retries after partial output.


  • I added a entry in changelog under unreleased section.
  • This is not an AI slop.

🤖 Generated with ECA (openai/gpt-5.6-sol - max)

Route structured response.failed errors through the existing bounded retry flow while avoiding retries after visible output.

🤖 Generated with [ECA](https://eca.dev) (openai/gpt-5.6-sol - max)

Co-Authored-By: eca-agent <git@eca.dev>

@ericdallo ericdallo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ericdallo ericdallo merged commit 1a68eb9 into editor-code-assistant:master Jul 15, 2026
9 checks passed
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.

2 participants