fix: Altimate Base header timeout too short (10s) for reasoning backend - #1260
Conversation
The `altimate-free` loader borrowed the `openai` loader's 10s header timeout (`OPENAI_HEADER_TIMEOUT_DEFAULT`). Altimate Base's gateway holds the HTTP 200 until the backend's first token, and queue wait / cold start / reasoning latency routinely exceeds 10s — so healthy requests aborted with `Provider response headers timed out after 10000ms` (reported on beta.3). - Add `FREE_TIER_HEADER_TIMEOUT_DEFAULT` (`300_000`ms, matching the SSE chunk watchdog `DEFAULT_CHUNK_TIMEOUT`) and use it in the free-tier loader. - Add an `ALTIMATE_BASE_HEADER_TIMEOUT_MS` env override (positive ms, or `0`/`off`/`false`/`none` to disable). The free-tier provider is deliberately excluded from `opencode.json` config merging (`provider.ts` filters `PROVIDER_ID`), so this env var is the only field-tunable override for affected users. - The 5-min `chunkTimeout` still guards mid-stream hangs; the header phase only needs to tolerate the backend's real time-to-first-byte. Root cause is client-side: nginx already streams the completions path (`proxy_buffering off`, `proxy_read_timeout 900s`), so the delay is litellm holding headers until the first upstream token — the client timeout is the correct remedy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_bfa77a1f-d70a-4d82-8ade-ab5a3fd53dd8) |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughThe Altimate Base free-tier provider now uses a five-minute header timeout by default. An environment variable can set a positive timeout or disable the timeout. ChangesFree-tier timeout handling
Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit watched the headers wait Comment |
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/opencode/src/provider/provider.ts">
<violation number="1" location="packages/opencode/src/provider/provider.ts:418">
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).</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| // 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(), |
There was a problem hiding this comment.
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>
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Reviewed by deepseek-v4-pro · Input: 32.7K · Output: 7.1K · Cached: 351.4K Review guidance: REVIEW.md from base branch |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39a7beb28b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // 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 |
There was a problem hiding this comment.
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 👍 / 👎.
| // 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 |
There was a problem hiding this comment.
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 👍 / 👎.
Review-driven hardening of the free-tier header-timeout override added in #1260: - Floor the override at 1000ms. A sub-second value (a typo like `1.5`, or `10` read as seconds) previously set a ~millisecond header timeout that aborts virtually every request — worse than the bug the override fixes. Sub-floor, non-numeric, and negative values now fall back to the 5-minute default. - Drop the `0`/`off`/`false`/`none` disable path. Turning the header abort off entirely lets a dead-but-connected gateway (headers never arrive, so the SSE chunk watchdog never starts) hang the CLI forever. A user who wants a very long ceiling sets a large number instead. - Warn (once) on a rejected value so a support-set typo is not silent. - Split parsing into a pure `resolveFreeTierHeaderTimeout(raw)` (unit-testable, no env/IO) and the env-reading `freeTierHeaderTimeout()` wrapper. - Document `ALTIMATE_BASE_HEADER_TIMEOUT_MS` in `configure/providers.md`. - Update the `provider.test.ts` contract assertion to the new 300_000ms default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
One conflict, in `packages/tui/src/component/altimate-onboarding.tsx`: #1268 changed the disclosure copy (dropped the per-install-id sentence, softened "Usage is rate limited" to "Usage can be rate limited") on the constant this branch had just moved into `@opencode-ai/core/altimate-base-disclosure`. Resolved by keeping this branch's structure (the TUI re-exports the shared constant) and adopting main's new wording in the core definition, along with its improved rationale comment. So #1268's copy change now applies to the HTTP disclosure route as well, which is the point of having one definition. The route tests reference `FreeTierConsent.DISCLOSURE` rather than a literal, so they picked the new text up with no change. Also brings in main's Altimate Base header-timeout fixes (#1260, plus the parsing hardening), which addressed the "Provider response headers timed out after 10000ms" failures. Verified after merge: `bun turbo typecheck` clean across 13 packages; TUI Base dialog suite 7/7 (including #1268's new guard that the per-install-id line stays out of the gate); engine route suite 11/11. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Issue for this PR
Closes #1259
Type of change
What does this PR do?
Beta.3 users on Altimate Base hit
Provider response headers timed out after 10000ms.The
altimate-freeloader borrowed theopenailoader's 10s header timeout (OPENAI_HEADER_TIMEOUT_DEFAULT, added in #1256 to catch a hung gateway). That value is correct for OpenAI (near-instant headers) but wrong for Altimate Base: its gateway holds the HTTP 200 until the backend's first token, and queue wait / cold start / reasoning latency routinely exceeds 10s — so healthy requests abort client-side.Changes:
FREE_TIER_HEADER_TIMEOUT_DEFAULT=300_000ms (matchingDEFAULT_CHUNK_TIMEOUT, the SSE chunk watchdog) and use it in the free-tier loader instead of the 10s OpenAI default.ALTIMATE_BASE_HEADER_TIMEOUT_MSenv override (positive ms, or0/off/false/noneto disable). The free-tier provider is deliberately excluded fromopencode.jsonconfig merging (provider.tsfiltersPROVIDER_ID), so this env var is the only field-tunable override for affected users.Why it works: the 5-min
chunkTimeoutstill guards mid-stream hangs, so the header phase only needs to tolerate the backend's real time-to-first-byte. nginx already streams the completions path (proxy_buffering off,proxy_read_timeout 900s), confirming the delay is litellm holding headers until the first upstream token — so the client timeout is the correct fix.How did you verify your code works?
tsc --noEmitonpackages/opencode—provider.tscompiles clean (remaining errors are pre-existing fresh-worktree module-resolution noise, unrelated).analyze.ts --markers --base origin/main --strict).Checklist
Note
Low Risk
Scoped to Altimate Base provider options; behavior is more permissive by default with an env override, and does not alter auth or other providers.
Overview
Fixes false Provider response headers timed out after 10000ms errors on Altimate Base (
altimate-free) when the gateway is slow to return the first byte (queue, cold start, or reasoning before headers).The free-tier loader no longer reuses OpenAI’s 10s
headerTimeout. It now defaults to 300_000ms (aligned with the SSE chunk watchdog) viafreeTierHeaderTimeout(), and operators can tune or disable it withALTIMATE_BASE_HEADER_TIMEOUT_MS(positive milliseconds, or0/off/false/noneto turn the header timeout off). OpenAI’s loader is unchanged at 10s.Reviewed by Cursor Bugbot for commit 39a7beb. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Fixes Altimate Base requests aborting on healthy requests with
Provider response headers timed out after 10000ms. The free-tier loader now uses a 300s header timeout instead of OpenAI's 10s default, since Altimate's gateway holds response headers until the first token (queue wait, cold start, or reasoning).ALTIMATE_BASE_HEADER_TIMEOUT_MSenv override (positive ms, or0/off/false/noneto disable).Written for commit 39a7beb. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Configuration
ALTIMATE_BASE_HEADER_TIMEOUT_MS.0,off,false, ornoneto disable the header timeout.