Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Give model fetches a 60s headers timeout (#974)

Chirag Jainb6a77812771d
diff --git a/.changeset/model-headers-timeout-60s.md b/.changeset/model-headers-timeout-60s.md
new file mode 100644
index 000000000..1c00e33a2
--- /dev/null
+++ b/.changeset/model-headers-timeout-60s.md
@@ -0,0 +1,6 @@
+---
+"@truefoundry/trueforge": patch
+"@truefoundry/trueforge-core": patch
+---
+
+Raise the default model HTTP headers timeout to 60 seconds so slow first-token responses are not dropped.
diff --git a/packages/trueforge-core/src/core/util/outboundFetch.ts b/packages/trueforge-core/src/core/util/outboundFetch.ts
index 36b810fae..708ff5979 100644
--- a/packages/trueforge-core/src/core/util/outboundFetch.ts
+++ b/packages/trueforge-core/src/core/util/outboundFetch.ts
@@ -10,7 +10,7 @@ export const DEFAULT_OUTBOUND_HTTP_BODY_TIMEOUT_MS = 5_000;
export const DEFAULT_OUTBOUND_HTTP_MAX_RETRIES = 2;
/** Model outbound undici headersTimeout. Env: `MODEL_HTTP_HEADERS_TIMEOUT_MS`. */
-export const DEFAULT_MODEL_HTTP_HEADERS_TIMEOUT_MS = 5_000;
+export const DEFAULT_MODEL_HTTP_HEADERS_TIMEOUT_MS = 60_000;
/** Model outbound undici connect timeout. Env: `MODEL_HTTP_CONNECT_TIMEOUT_MS`. */
export const DEFAULT_MODEL_HTTP_CONNECT_TIMEOUT_MS = 5_000;
/** Model outbound undici bodyTimeout. Env: `MODEL_HTTP_BODY_TIMEOUT_MS`. */
diff --git a/packages/trueforge/.env.example b/packages/trueforge/.env.example
index 28c8f83f1..bae9825e3 100644
--- a/packages/trueforge/.env.example
+++ b/packages/trueforge/.env.example
@@ -169,7 +169,7 @@ TRUEFORGE_API_KEY=placeholder-value-please-generate-your-own
# OUTBOUND_HTTP_BODY_TIMEOUT_MS=5000
# OUTBOUND_HTTP_MAX_RETRIES=2
## Model-provider undici timeouts/retries.
-# MODEL_HTTP_HEADERS_TIMEOUT_MS=5000
+# MODEL_HTTP_HEADERS_TIMEOUT_MS=60000
# MODEL_HTTP_CONNECT_TIMEOUT_MS=5000
## undici bodyTimeout for model fetch (idle between body chunks). Default 60000.
# MODEL_HTTP_BODY_TIMEOUT_MS=60000
diff --git a/packages/trueforge/src/config.ts b/packages/trueforge/src/config.ts
index aa2ef1f09..c5dd617d0 100644
--- a/packages/trueforge/src/config.ts
+++ b/packages/trueforge/src/config.ts
@@ -861,7 +861,7 @@ export interface SharedServerConfiguration {
MODEL_HTTP_CONNECT_TIMEOUT_MS: number;
/**
* undici headersTimeout for model-provider outbound fetch.
- * Env: `MODEL_HTTP_HEADERS_TIMEOUT_MS`. Default 5000.
+ * Env: `MODEL_HTTP_HEADERS_TIMEOUT_MS`. Default 60000.
*/
MODEL_HTTP_HEADERS_TIMEOUT_MS: number;
/**
@@ -1229,7 +1229,7 @@ const shared: SharedServerConfiguration = {
MODEL_HTTP_HEADERS_TIMEOUT_MS: parsePositiveInt({
envKey: 'MODEL_HTTP_HEADERS_TIMEOUT_MS',
raw: getEnv('MODEL_HTTP_HEADERS_TIMEOUT_MS'),
- defaultValue: 5_000,
+ defaultValue: 60_000,
}),
MODEL_HTTP_BODY_TIMEOUT_MS: parsePositiveInt({
envKey: 'MODEL_HTTP_BODY_TIMEOUT_MS',