Skip to content

fix(providers): name the header phase on streaming OpenAI requests - #6288

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/openai-streaming-transport-phase
Aug 5, 2026
Merged

fix(providers): name the header phase on streaming OpenAI requests#6288
waleedlatif1 merged 1 commit into
stagingfrom
fix/openai-streaming-transport-phase

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Streaming requests call fetchResponsesWithSummaryFallback directly and never reach postResponses, which is where fix(providers): name the failing phase of a stalled OpenAI call, and reject a failed generation #6283 put the header-phase annotation — so a chat or SSE run that stalled waiting for headers still surfaced the bare runtime TimeoutError: The operation timed out. with no phase, elapsed time, or request id
  • Moved the annotation down to the one place every Responses request actually leaves through, so streaming and non-streaming are named identically
  • Net simplification: the two duplicated fetchImpl blocks collapse into a single postOnce helper, and postResponses loses its now-redundant try/catch

Caught by Greptile on #6283. Non-streaming was already covered (webhook, scheduled, async, and sync-API runs are all non-streaming), so this closes the gap for chat, SSE, and streaming-mode API calls.

Type of Change

  • Bug fix

Testing

Added a test that a streaming request whose fetch rejects with a TimeoutError carries phase=awaiting-response-headers and elapsedMs. Verified it fails without the fix (along with the existing non-streaming header test), then passes with it.

Providers + agent-handler suites: 109 files / 1416 tests passing. Typecheck, lint, and check:api-validation clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedAug 5, 2026 5:15pm

Request Review

@cursor

cursorBot commented Aug 5, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Localized provider transport error formatting with no auth, data, or API contract changes; behavior only improves error messages on fetch failures.

Overview
Header-phase transport errors on OpenAI Responses calls now get the same phase=awaiting-response-headers and elapsedMs metadata for streaming chat/SSE runs, not only non-streaming paths that go through postResponses.

The fix introduces a shared postOnce helper that wraps every outbound fetch and applies annotateTransportFailure there. Streaming code calls fetchResponsesWithSummaryFallback directly, so it previously missed the annotation that lived only around postResponses. Initial and reasoning-summary retry requests both use postOnce, and the redundant header-phase catch on postResponses is removed.

A transport test runs with stream: true and asserts the annotated timeout message.

Reviewed by Cursor Bugbot for commit 0343bb9. Configure here.

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR moves response-header transport-failure annotation into the shared outbound request helper so streaming and non-streaming OpenAI Responses requests receive consistent diagnostics.

  • Routes initial and reasoning-summary fallback fetches through a single postOnce helper.
  • Removes the redundant non-streaming annotation boundary.
  • Adds regression coverage for header timeouts during streaming requests.

Confidence Score: 5/5

The PR appears safe to merge, with the shared helper consistently annotating streaming and non-streaming header failures.

The refactor preserves fetch arguments, retry timing, and abort recognition while extending the existing transport diagnostics to streaming paths, and no actionable regression remains.

Important Files Changed

FilenameOverview
apps/sim/providers/openai/core.tsCentralizes outbound fetch execution and response-header failure annotation without changing request arguments, fallback behavior, or abort classification.
apps/sim/providers/openai/core.transport-phase.test.tsAdds focused regression coverage confirming streaming header timeouts include phase and elapsed-time diagnostics.

Sequence Diagram

sequenceDiagram
participant Caller as Streaming or non-streaming caller
participant Fetcher as fetchResponsesWithSummaryFallback
participant Post as postOnce
participant OpenAI as OpenAI endpoint
Caller->>Fetcher: payload, startedAt, abortSignal
Fetcher->>Post: initial request
Post->>OpenAI: POST Responses request
alt Fetch rejects before headers
Post-->>Caller: annotated transport failure
else Reasoning summaries rejected
Fetcher->>Post: retry without summary
Post->>OpenAI: POST fallback request
Post-->>Caller: response or annotated failure
else Request succeeds
OpenAI-->>Caller: response
end
Loading

Reviews (1): Last reviewed commit: "fix(providers): name the header phase on..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit 53c3bea into stagingAug 5, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/openai-streaming-transport-phase branch August 5, 2026 17:22
Sign up for freeto 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.

1 participant

@waleedlatif1