Skip to content

fix: Altimate Base header timeout too short (10s) for reasoning backend - #1260

Merged
anandgupta42 merged 1 commit into
mainfrom
fix/free-tier-header-timeout
Sep 8, 2026
Merged

fix: Altimate Base header timeout too short (10s) for reasoning backend#1260
anandgupta42 merged 1 commit into
mainfrom
fix/free-tier-header-timeout

Conversation

@anandgupta42

@anandgupta42 anandgupta42 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #1259

Type of change

  • Bug fix

What does this PR do?

Beta.3 users on Altimate Base hit Provider response headers timed out after 10000ms.

The altimate-free loader borrowed the openai loader'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:

  • Add FREE_TIER_HEADER_TIMEOUT_DEFAULT = 300_000ms (matching DEFAULT_CHUNK_TIMEOUT, the SSE chunk watchdog) and use it in the free-tier loader instead of the 10s OpenAI default.
  • 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.

Why it works: the 5-min chunkTimeout still 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 --noEmit on packages/opencodeprovider.ts compiles clean (remaining errors are pre-existing fresh-worktree module-resolution noise, unrelated).
  • Upstream marker guard clean (analyze.ts --markers --base origin/main --strict).
  • Static gateway audit: nginx completions path is unbuffered with a 900s read timeout, so the header delay is not a proxy-buffering issue — the client-side timeout value is the correct remedy.
  • Not verified: a live reproduction against prod (needs a managed credential); the value is chosen to comfortably exceed the backend's worst-case reasoning latency.

Checklist

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

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) via freeTierHeaderTimeout(), and operators can tune or disable it with ALTIMATE_BASE_HEADER_TIMEOUT_MS (positive milliseconds, or 0/off/false/none to 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).

  • Adds an ALTIMATE_BASE_HEADER_TIMEOUT_MS env override (positive ms, or 0/off/false/none to disable).
  • The 5-minute chunk timeout still guards mid-stream hangs.

Written for commit 39a7beb. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Improved connection reliability for the Altimate Base free tier by allowing more time for initial response headers.
    • The default header timeout is now five minutes, reducing premature timeouts during slower responses.
  • Configuration

    • Administrators can customize the header timeout in milliseconds using ALTIMATE_BASE_HEADER_TIMEOUT_MS.
    • Set the value to 0, off, false, or none to disable the header timeout.

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>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T07:38:02.567023Z 39a7beb PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4abcc728-091c-42ba-842b-bb4c501ac40d

📥 Commits

Reviewing files that changed from the base of the PR and between 67037f8 and 39a7beb.

📒 Files selected for processing (1)
  • packages/opencode/src/provider/provider.ts

Disabled knowledge base sources:

  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

The 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.

Changes

Free-tier timeout handling

Layer / File(s) Summary
Configure and apply the free-tier header timeout
packages/opencode/src/provider/provider.ts
Adds freeTierHeaderTimeout() with environment overrides and applies it to the altimate-free provider loader.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/free-tier-header-timeout

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.

❤️ Share

A rabbit watched the headers wait
Five minutes opened the gate
Env switches tune the flow
False can stop the clock below
Healthy tokens now can grow

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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(),

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>

@anandgupta42
anandgupta42 merged commit 5f9cb88 into main Sep 8, 2026
28 of 30 checks passed
@kilo-code-bot

kilo-code-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • packages/opencode/src/provider/provider.ts

Reviewed by deepseek-v4-pro · Input: 32.7K · Output: 7.1K · Cached: 351.4K

Review guidance: REVIEW.md from base branch main

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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

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 👍 / 👎.

// 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 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 👍 / 👎.

anandgupta42 added a commit that referenced this pull request Sep 8, 2026
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>
saravmajestic added a commit that referenced this pull request Sep 8, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Altimate Base: "Provider response headers timed out after 10000ms" on beta.3

1 participant