Skip to content

fix(proxy): raise first-byte timeout to 240s to cover large-context prefill (#13) - #16

Merged
Hrt-Htk merged 1 commit into
mainfrom
fix/first-byte-timeout-calibration
Jul 19, 2026
Merged

fix(proxy): raise first-byte timeout to 240s to cover large-context prefill (#13)#16
Hrt-Htk merged 1 commit into
mainfrom
fix/first-byte-timeout-calibration

Conversation

@Hrt-Htk

@Hrt-Htk Hrt-Htk commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Follow-up calibration to #13 (found by lifecycle testing on the live server).

What went wrong

The #13 first-byte timeout (60s) false-tripped on large contexts. This router withholds response headers until the worker emits its first token, so time-to-headers includes the full prompt prefill. A near-limit cold-cache prefill (131k tokens @ ~800 tok/s ≈ 165s) exceeded 60s, so the proxy declared the (healthy, busy-prefilling) worker "hung", cycled recover_worker (losing the prompt cache), and could cascade.

Observed on 2026-07-19: requests at 59.6s and 60.7s just made it (200); the next crossed 60s → false DeadWorkerError → unload/reload → 400 on the cache-cold retry. Two spurious reloads in one session.

Fix

Raise FIRST_BYTE_TIMEOUT default 60s → 240s — above worst-case legitimate cold prefill of the full 131k context. A genuinely hung worker is still detected (just later); normal large-context requests are no longer mistaken for hangs. Still overridable via $PROXY_FIRST_BYTE_TIMEOUT.

Unit tests unchanged (they use a 1s override): 3/3 pass.

Relates to #13.
🤖 Generated with Claude Code

…refill (#13)

Lifecycle testing exposed a false-positive in the #13 fix: this router
withholds response headers until the worker emits its first token, so
time-to-headers includes the full prompt prefill. A near-limit cold-cache
prefill (131k tokens at ~800 tok/s) takes ~165s; the 60s bound tripped on
large contexts and forced needless worker reloads (losing the prompt cache,
which can cascade). Raise the default to 240s — above worst-case legitimate
prefill — so a genuinely hung worker is still detected while normal
large-context requests are not. Still overridable via $PROXY_FIRST_BYTE_TIMEOUT.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Hrt-Htk
Hrt-Htk merged commit c668cb9 into main Jul 19, 2026
1 check passed
@Hrt-Htk
Hrt-Htk deleted the fix/first-byte-timeout-calibration branch July 19, 2026 19:20
Sign up for free to 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