Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat(llm): Apply the configurable request timeout to the Tinfoil provider

Gabriel Steinf2407757f71f
diff --git a/src/services/ai/inferenceProviders/tinfoil.ts b/src/services/ai/inferenceProviders/tinfoil.ts
index 0efad49a8..a49b70278 100644
--- a/src/services/ai/inferenceProviders/tinfoil.ts
+++ b/src/services/ai/inferenceProviders/tinfoil.ts
@@ -4,10 +4,10 @@ import { withRetry, createApiRetryStrategy } from "../../../utils/retry";
import logger from "../../../utils/logger";
import { applyChatCompletionsParams, isTruncatedFinishReason } from "../chatRequestBody";
import { getTinfoilChatClient } from "../tinfoilClient";
+import { getSettings } from "../../../stores/settingsStore";
+import { resolveLlmRequestTimeoutSeconds } from "../../../helpers/llmRequestTimeout.js";
import { wrapCleanupTranscript } from "../../../config/prompts";
-const REQUEST_TIMEOUT_MS = 30_000;
-
export const tinfoilProvider: InferenceProvider = {
id: "tinfoil",
async call({ text, model, agentName, config, ctx }) {
@@ -40,12 +40,14 @@ export const tinfoilProvider: InferenceProvider = {
const requestBody: Record<string, unknown> = { model, messages };
applyChatCompletionsParams(requestBody, { model, provider: "tinfoil", config, maxTokens });
- // 30s per attempt like sibling providers; SDK-internal retries off so
- // withRetry stays the single retry layer.
+ // Configurable timeout per attempt like sibling providers; SDK-internal
+ // retries off so withRetry stays the single retry layer.
+ const timeoutMs =
+ resolveLlmRequestTimeoutSeconds(getSettings().llmRequestTimeoutSeconds) * 1000;
const response = await withRetry(
() =>
client.chat.completions.create(requestBody as any, {
- timeout: REQUEST_TIMEOUT_MS,
+ timeout: timeoutMs,
maxRetries: 0,
}),
createApiRetryStrategy()
diff --git a/test/helpers/llmRequestTimeout.test.js b/test/helpers/llmRequestTimeout.test.js
index 579bbcde8..460e1f523 100644
--- a/test/helpers/llmRequestTimeout.test.js
+++ b/test/helpers/llmRequestTimeout.test.js
@@ -19,6 +19,12 @@ test("clamps below the 10s floor", async () => {
assert.equal(resolveLlmRequestTimeoutSeconds(1), 10);
});
+test("clamps 0 and negative values to the 10s floor rather than disabling", async () => {
+ const { resolveLlmRequestTimeoutSeconds } = await load();
+ assert.equal(resolveLlmRequestTimeoutSeconds(0), 10);
+ assert.equal(resolveLlmRequestTimeoutSeconds(-5), 10);
+});
+
test("clamps above the 600s ceiling", async () => {
const { resolveLlmRequestTimeoutSeconds } = await load();
assert.equal(resolveLlmRequestTimeoutSeconds(9999), 600);
@@ -46,3 +52,11 @@ test("streaming's floor lets a high configured value raise it above 60s", async
);
assert.equal(streamingTimeout, 120);
});
+
+test("millisecond conversion for SDK timeouts (tinfoil) honors default and override", async () => {
+ const { resolveLlmRequestTimeoutSeconds } = await load();
+ // The Tinfoil provider passes resolveLlmRequestTimeoutSeconds(x) * 1000 as the
+ // SDK per-attempt timeout; pin the arithmetic for the default and an override.
+ assert.equal(resolveLlmRequestTimeoutSeconds(undefined) * 1000, 30_000);
+ assert.equal(resolveLlmRequestTimeoutSeconds(90) * 1000, 90_000);
+});