Skip to content

fix(dbx): make LLM request timeouts configurable via environment - #274

Open
xw-song wants to merge 1 commit into
althrussell:mainfrom
xw-song:fix/configurable-llm-timeouts
Open

fix(dbx): make LLM request timeouts configurable via environment#274
xw-song wants to merge 1 commit into
althrussell:mainfrom
xw-song:fix/configurable-llm-timeouts

Conversation

@xw-song

@xw-song xw-song commented Aug 6, 2026

Copy link
Copy Markdown

Summary

The LLM timeouts in lib/dbx/model-serving.ts are fixed constants (300s
non-streaming, 600s streaming). On a slower serving endpoint a single
reasoning-tier pass can exceed 300s and abort mid-run, surfacing as an error that
names the endpoint and reads like it is unreachable:

Request to /serving-endpoints/databricks-claude-sonnet-4-6/invocations timed out after 300000ms

Measured on an Azure workspace, databricks-claude-sonnet-4-6 pay-per-token: a
17K-token prompt returns in 6.9s, but sustained generation runs at ~41 output
tok/s — max_tokens=1500 took 36.7s, and max_tokens=4000 timed out at 321.7s.
Time to first token is fine; long generations are the constraint.

This reads both timeouts from the environment so a deployment can raise them
without a code change:

  • FORGE_LLM_TIMEOUT_MS — default 900000 (was 300000)
  • FORGE_LLM_STREAM_TIMEOUT_MS — default 1200000 (was 600000)

Malformed, zero, negative and non-finite values fall back to the default rather
than throwing.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (code restructuring, no behavior change)
  • Documentation update
  • Chore (dependencies, CI, tooling)

Pre-Merge Checklist

  • npm run lint passes
  • npm run typecheck passes
  • npm test passes
  • I have added tests that prove my fix / feature works
  • New and existing unit tests pass locally
  • I have updated documentation where applicable (AGENTS.md, docs/, CHANGELOG.md)
  • My changes generate no new warnings

234 files / 2420 tests passing. __tests__/model-serving/env-timeout.test.ts
covers unset, valid, empty, non-numeric, zero, negative and Infinity. Not
documented in docs/ — happy to add it alongside the other FORGE_* vars.

Notes for Reviewers

Demo research already runs detached from the HTTP request
(app/api/demo/research/route.ts fires void startResearch() and the client
polls for status), so a longer ceiling cannot trip a gateway timeout. This
constant was the only deadline in that path.

Trade-off: a wedged request now holds a rate-limiter slot for up to 15 minutes
instead of 5, which on a saturated pool could delay queued work.

envTimeoutMs is exported only so it can be unit-tested.

The non-streaming and streaming LLM timeouts were fixed at 300s and 600s.
Generation throughput varies between serving endpoints, so a single
reasoning-tier pass can exceed 300s and abort mid-run, surfacing as a
FetchTimeoutError naming the endpoint rather than the real cause.

Read both from FORGE_LLM_TIMEOUT_MS and FORGE_LLM_STREAM_TIMEOUT_MS,
falling back to raised defaults of 900s and 1200s. Malformed or
non-positive values fall back rather than throwing.
@xw-song
xw-song requested a review from althrussell as a code owner August 6, 2026 14:21
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

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