Uh oh!
There was an error while loading. Please reload this page.
fix(providers): name the failing phase of a stalled OpenAI call, and reject a failed generation - #6283
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. |
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).
bdeea33 to
d0dce45Comparewaleedlatif1
commented
Aug 5, 2026
waleedlatif1
commented
Aug 5, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Aug 5, 2026
waleedlatif1
commented
Aug 5, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Aug 5, 2026
waleedlatif1
commented
Aug 5, 2026
@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.
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