fix(provider): port upstream 5min OpenAI header timeout (anomalyco/opencode#37770)

DE
16h ago
+7-2

Issue for this PR

Closes #1475

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Ports upstream https://github.com/anomalyco/opencode/pull/37770.

The built-in openai provider sets a 10s headerTimeout (OPENAI_HEADER_TIMEOUT_DEFAULT). With large prompts or high reasoning effort, OpenAI can take longer than 10s to send response headers, so healthy requests get aborted with Provider response headers timed out after 10000ms, then retried or failed. Upstream raised the default to 5 minutes. This PR does the same; the value now matches the 5min SSE chunk watchdog and the Altimate Base header timeout. Users can still set provider.openai.options.headerTimeout to override it, or false to disable it.

Relation to #1426: that PR adds a generic 5min DEFAULT_HEADER_TIMEOUT for providers that have none, but leaves OPENAI_HEADER_TIMEOUT_DEFAULT = 10_000. So OpenAI still gets the 10s abort there, and this PR doesn't duplicate it. The two touch neighbouring lines in provider.ts, so whichever merges second may need a trivial rebase.

How did you verify your code works?

  • Updated OpenAI API auth gets default headerTimeout to expect 300_000.
  • bun test test/provider/header-timeout.test.ts: 6 pass, 0 fail. That includes the existing abort, opt-in and disable-by-config tests.
  • bun run typecheck in packages/opencode: passes.
  • bun run script/upstream/analyze.ts --markers --base origin/main --strict: exit 0. The upstream remote couldn't be fetched here, so it used the pattern-based fallback.
  • bun script/check-tracker-leaks.ts: passes.

Screenshots / recordings

N/A, not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Written by Devin


Summary by cubic

Bumps the built-in openai provider's default header timeout from 10s to 5 minutes, porting anomalyco/opencode#37770 and closing #1475. Slow but healthy requests with large prompts or high reasoning effort were aborted with Provider response headers timed out after 10000ms before headers arrived; they now match the 5-minute SSE chunk watchdog and remain overridable via provider.openai.options.headerTimeout (or false to disable).