fix(providers): name the failing phase of a stalled OpenAI call, and reject a failed generation - #6283
Merged
waleedlatif1 merged 5 commits intoAug 5, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryCursor Bugbot is generating a summary for commit 76c8e91. Configure here. |
6 tasks
Contributor
Greptile SummaryThe PR improves OpenAI failure diagnostics and rejects unsuccessful or unusable non-streaming generations.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains within the scope of this follow-up review.
|
| Filename | Overview |
|---|---|
| apps/sim/providers/openai/core.ts | Adds transport-phase diagnostics, bounded error parsing, generation-status validation, and cause-preserving provider errors. |
| apps/sim/providers/types.ts | Extends ProviderError to accept standard ErrorOptions and retain wrapped causes. |
| apps/sim/executor/handlers/agent/agent-handler.ts | Classifies timeout and abort failures through the cause chain while preserving provider diagnostics. |
| apps/sim/providers/openai/core.response-status.test.ts | Covers failed and incomplete response handling, truncated tool calls, and continuation turns. |
| apps/sim/providers/openai/core.transport-phase.test.ts | Covers header/body phase annotation, request metadata, bounded error bodies, and fallback behavior. |
| apps/sim/executor/handlers/agent/agent-handler.test.ts | Verifies wrapped timeout and abort classification at the agent-handler boundary. |
Sequence Diagram
sequenceDiagram
participant Agent as Agent Handler
participant Provider as OpenAI Provider
participant API as OpenAI Responses API
Agent->>Provider: Execute model request
Provider->>API: Fetch response
alt Transport failure
API--xProvider: Timeout or abort
Provider->>Provider: Attach phase and response metadata
Provider--xAgent: ProviderError with preserved cause
Agent->>Agent: Classify cause-chain timeout
else HTTP 200 response
API-->>Provider: Response payload
Provider->>Provider: Validate generation status
alt Failed or unusable generation
Provider--xAgent: Reject generation
else Completed or usable truncated prose
Provider-->>Agent: Return provider response
end
end
Reviews (4): Last reviewed commit: "fix(providers): name the body phase when..." | Re-trigger Greptile
…reject a failed generation An agent block hung ~4.5 minutes with an empty trace and surfaced only the runtime's own `TimeoutError: The operation timed out.` The cause was a runaway generation: the model repeated one tool call until it consumed the whole 128,000-token output budget, which takes minutes, and `/v1/responses` withholds its 200 until generation finishes — so the client waited, bounded only by an undocumented runtime socket deadline, and gave up before the response existed. Nothing in the trace could distinguish that from a request the provider never answered, or from one whose body never arrived. - Name the phase a transport failure died in — `awaiting-response-headers` vs `reading-response-body` — with status, ttfb, content-length and `x-request-id`. undici draws the same line as two error types (UND_ERR_HEADERS_TIMEOUT / UND_ERR_BODY_TIMEOUT); the OpenAI SDK captures `x-request-id` for the same reason. It rides the error message because that reaches the trace span, which survives when a task stops shipping logs. - Carry the cause through `ProviderError` so a transport timeout still classifies after wrapping overwrites `name`. - Reject a 200 that reports a failed or unusable generation instead of returning empty content with billed tokens, and stop truncated tool calls from executing. Matches `streamResponsesTurn`, which already did this, and `@ai-sdk/openai`, which throws on the same condition. - Bound non-JSON error bodies so a gateway error page cannot become the user-facing block error. Deliberately not included: a response-body deadline (the observed failure is in the headers phase, and the body transfers in ~1ms) and status-based retries (worth doing, unrelated to this, and separable).
waleedlatif1
force-pushed
the
fix/openai-provider-transport-diagnostics-v2
branch
from
August 5, 2026 05:46
bdeea33 to
d0dce45
Compare
Collaborator
Author
Collaborator
Author
|
@cursor review |
Collaborator
Author
Collaborator
Author
|
@cursor review |
Collaborator
Author
Collaborator
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 678384b. Configure here.
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TimeoutError: The operation timed out.Root cause: the model repeated one tool call until it consumed the full 128,000-token output budget./v1/responseswithholds its 200 until generation finishes, so the client waited — bounded only by an undocumented runtime socket deadline — and gave up before the response existed. Confirmed against OpenAI's stored response (status: incomplete,reason: max_output_tokens).awaiting-response-headersvsreading-response-body— with status, ttfb, content-length andx-request-id. Precedent: undici splits these intoUND_ERR_HEADERS_TIMEOUT/UND_ERR_BODY_TIMEOUT; the OpenAI SDK capturesx-request-id. It rides the error message because that reaches the trace span, which survives when a task stops shipping logs.ProviderErrorso a transport timeout still classifies after wrapping overwritesname.streamResponsesTurn(already did this) and@ai-sdk/openai(throws on the same condition).Deliberately excluded: a response-body deadline (the observed failure is in the headers phase; body transfer measured at ~1 ms) and status-based retries (worth doing, unrelated, separable).
Type of Change
Testing
Tested manually against the live API plus 14 new unit tests.
/v1/responseswithholds its 200 until generation completes (14,545 ms to headers, 1 ms of body), which is why only the headers phase matters here./v1/responsespayloads (completed,incomplete/max_output_tokens, tool-call) through the provider — none rejected by the new guard.Checklist