Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ const DEFAULT_CHUNK_TIMEOUT = 300_000
const OPENAI_HEADER_TIMEOUT_DEFAULT = 10_000
const HEADER_TIMEOUT = Symbol.for("opencode.provider.header-timeout")
// altimate_change end
// altimate_change start — Altimate Base needs a far more generous header timeout than OpenAI.
// Its gateway can queue for a capacity slot, cold-start the backend, or reason before flushing
// response headers — any of which exceeds OpenAI's near-instant reply. OpenAI's 10s default
// therefore false-positives on healthy Altimate Base requests ("Provider response headers timed
// out after 10000ms"). Default to the same 5min the SSE chunk watchdog uses, and expose an env
// override so it is tunable in the field without a release: a positive number of milliseconds,
// or 0/off/false/none to disable the header timeout entirely.
const FREE_TIER_HEADER_TIMEOUT_DEFAULT = 300_000

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the pinned Altimate Base timeout assertion

When ALTIMATE_BASE_HEADER_TIMEOUT_MS is unset, this changes the loader's value to 300_000, but packages/opencode/test/provider/provider.test.ts:85 still asserts that base.options.headerTimeout is 10_000. That test will deterministically fail once the suite can start, blocking CI; update the assertion and ideally add coverage for the documented environment-variable values.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the pinned Altimate Base timeout assertion

When ALTIMATE_BASE_HEADER_TIMEOUT_MS is unset, this changes the managed provider's timeout to 300_000, but packages/opencode/test/provider/provider.test.ts:85 still asserts that base.options.headerTimeout is 10_000. The normal test run will therefore fail on this existing provider contract test; update the assertion and its now-stale comment to match the new default.

Useful? React with 👍 / 👎.

function freeTierHeaderTimeout(): number | false {
const raw = Env.get("ALTIMATE_BASE_HEADER_TIMEOUT_MS")?.trim()
if (raw) {
if (["0", "off", "false", "none"].includes(raw.toLowerCase())) return false
const parsed = Number(raw)
if (Number.isFinite(parsed) && parsed > 0) return parsed
}
return FREE_TIER_HEADER_TIMEOUT_DEFAULT
}
// altimate_change end

export namespace Provider {
const log = Log.create({ service: "provider" })
Expand Down Expand Up @@ -393,9 +411,11 @@ export namespace Provider {
// authorizedFetch. Provider options are serialized by public provider APIs.
apiKey: FreeTier.MANAGED_API_KEY_PLACEHOLDER,
fetch: FreeTier.authorizedFetch,
// BUG FIX: without this, a hung gateway response never times out client-side, unlike
// the openai loader below which already sets this.
headerTimeout: OPENAI_HEADER_TIMEOUT_DEFAULT,
// Without a header timeout a hung gateway (connected, never replies) never aborts
// client-side — the SSE chunk watchdog only starts once headers arrive. OpenAI's 10s
// is far too tight for Altimate Base's queue/cold-start/reasoning latency to first
// byte, so use the free tier's generous, env-tunable value instead.
headerTimeout: freeTierHeaderTimeout(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This change leaves the existing Altimate Base provider test asserting the removed 10-second default, so the provider test suite fails whenever the free-tier loader is exercised. Update the assertion and its comment to cover the 5-minute default (and ideally the environment override).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/opencode/src/provider/provider.ts, line 418:

<comment>This change leaves the existing Altimate Base provider test asserting the removed 10-second default, so the provider test suite fails whenever the free-tier loader is exercised. Update the assertion and its comment to cover the 5-minute default (and ideally the environment override).</comment>

<file context>
@@ -393,9 +411,11 @@ export namespace Provider {
+          // client-side — the SSE chunk watchdog only starts once headers arrive. OpenAI's 10s
+          // is far too tight for Altimate Base's queue/cold-start/reasoning latency to first
+          // byte, so use the free tier's generous, env-tunable value instead.
+          headerTimeout: freeTierHeaderTimeout(),
         },
       }
</file context>

},
}
},
Expand Down
Loading