Skip to content

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

fix(notes): stop saving the raw transcript as the enhanced note when the model returns nothing (#2177)

Gabriel Steinb0cccf148a99
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9af6d130a..9bb13a0c5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Notes
+
+- **Generate AI Summary no longer saves your transcript back as the "Enhanced" note.** With an OpenAI reasoning model such as GPT-5.6 Terra, the summary could finish with no error and an Enhanced tab that was just the raw transcript run together. Whenever the model returned no text, the OpenAI provider fell back to handing its input straight back, and the app saved that as the enhanced note. The fallback now only applies to plain dictation cleanup, which its callers already guard; a summary or any other prompted task reports an error instead, including a refusal or a response that ran out of tokens before writing anything. Every other reasoning path, bring-your-own-key, local, enterprise, and OpenWhispr Cloud alike, also reports an error on a blank result rather than saving a blank page. OpenAI's reasoning models additionally get at least 25k output tokens so hidden reasoning cannot crowd out the answer.
+- **Detailed Notes gets a shorter, sharper prompt.** The 1.10.0 prompt was three times longer than it needed to be, described the transcript layout incorrectly, ended with a self-check list that added reasoning time, and asked for action items in a shape the editor's owner tagging could never match, so nobody got an owner chip. The rewrite keeps the rules that matter, uses the same `- [ ] Action — Owner` shape as Generate Notes, drops the "Owner not specified" filler, corrects transcription misspellings of names from the participant list and custom dictionary, only lists actions someone actually took on, and says what to do with plain notes that have no transcript. Tested side by side against the old prompt on real meetings of 30, 60, and 90 minutes. Anyone still on the shipped prompt moves to the new one automatically; an edited prompt is left alone.
+
### Transcription
- **Your own Deepgram key works again.** Every Deepgram connection failed with `Unexpected server response: 401`, even though the same key tested fine in Settings and worked against Deepgram directly. Deepgram accepts a raw API key only under its `Token` authorization scheme and reserves `Bearer` for the short-lived tokens OpenWhispr Cloud mints on your behalf — and the app was presenting your key as a `Bearer`. This broke bring-your-own-key dictation as well as Note Recording. (#2140, thanks @nikhilmaddirala)
diff --git a/src/helpers/builtinActions.js b/src/helpers/builtinActions.js
index 0fd68038f..604e95fcb 100644
--- a/src/helpers/builtinActions.js
+++ b/src/helpers/builtinActions.js
@@ -11,7 +11,9 @@ export const FOLLOW_UP_EMAIL_KEY = "notes.actions.builtin.followUpEmail";
const GENERATE_NOTES_PROMPT =
"Transform the provided content into clean, well-structured notes in markdown. Preserve the user's intent and all substantive information. Remove filler, small talk, false starts, and redundant content. For personal notes, improve grammar and structure for readability. For meeting transcripts, extract key discussion points, decisions, action items, and follow-ups.";
-const DETAILED_NOTES_PROMPT = `You are an expert meeting-notes editor. Convert the provided meeting material into accurate, comprehensive, and easy-to-scan notes in Markdown.
+// Shipped in 1.10.0; kept so rows seeded with it upgrade. Its Owner/Due
+// action-item shape never matched the owner tagger.
+const DETAILED_NOTES_PROMPT_1_10_0 = `You are an expert meeting-notes editor. Convert the provided meeting material into accurate, comprehensive, and easy-to-scan notes in Markdown.
The source may contain:
- meeting context, such as the calendar title or participant names;
@@ -77,6 +79,40 @@ Before responding, verify that:
Return only the finished Markdown notes.`;
+// Action items must end in "— Owner" so the editor can turn owners into
+// mention chips (see tagActionItemOwners); a trailing due-date clause would
+// take the owner's place.
+const DETAILED_NOTES_PROMPT = `Convert the provided material into accurate, comprehensive, easy-to-scan notes in Markdown. Priorities, in order: factual accuracy, preservation of specifics, complete coverage of substantive topics, clear decisions and action items, concise presentation.
+
+RULES:
+- Use only information supported by the material. Never invent facts, decisions, owners, deadlines, or names.
+- Keep the exact names of people, clients, companies, projects, products, tools, and acronyms, and the exact numbers, dates, deadlines, and document names. Never replace a named entity with a generic noun such as "the client" or "the project". If a name is unclear, write "[name unclear]" rather than guessing.
+- Speech-to-text misspells names. When the transcript's spelling is an obvious variant of a name in the Meeting Context, the participants' email addresses, the manual notes, or the custom dictionary, use that spelling instead.
+- Distinguish what was discussed, proposed, or requested from what was actually decided.
+- Treat the user's manual notes as a signal of what matters most, reconciled against the transcript.
+- Consolidate repeated discussion into one point. Drop greetings, filler, and false starts. Give longer meetings proportionally more detail.
+- If there is no transcript, structure the user's own notes and skip the meeting-specific sections.
+
+FORMAT:
+- No title, date, attendee list, preamble, table, or horizontal rule. Omit any section with nothing to say.
+
+## Summary
+3–5 bullets: purpose, key subjects, major outcomes, immediate next steps.
+
+## Discussion
+Descriptive topic subheadings named after the actual client, project, or initiative, with enough context that someone who missed the meeting understands what happened and why.
+
+## Decisions
+Only decisions that were explicitly made or clearly agreed.
+
+## Action Items
+Only actions someone committed to or was asked to do; never turn a discussion topic into an action item. One checkbox per item in the form \`- [ ] Action — Owner\`. Put a stated due date inside the action text, for example \`- [ ] Send the revised proposal by Friday — Alice\`. The owner is the person the transcript shows taking the action on or being asked to, not whoever raised the topic; name them whenever the transcript shows it. Use "You" or "Them" only when no name is available. When the transcript shows no owner, end the line after the action; never write a placeholder such as "Owner not specified".
+
+## Open Questions
+Unresolved questions, dependencies, and requested follow-ups.
+
+Return only the finished Markdown notes.`;
+
const FOLLOW_UP_EMAIL_PROMPT = `You are an expert at writing follow-up emails after meetings. Draft the follow-up email the user ("You") would send to the other participants, based only on the provided meeting material: meeting context, the user's manual notes, and the transcript.
RULES:
@@ -114,7 +150,7 @@ export const BUILTIN_ACTIONS = [
description: "Clean up, structure, and enhance your notes",
prompt: GENERATE_NOTES_PROMPT,
// A pre-release build briefly shipped the detailed prompt under this key.
- previousPrompts: [DETAILED_NOTES_PROMPT],
+ previousPrompts: [DETAILED_NOTES_PROMPT_1_10_0],
icon: "sparkles",
sortOrder: 0,
},
@@ -123,7 +159,7 @@ export const BUILTIN_ACTIONS = [
name: "Detailed Notes",
description: "Accurate, comprehensive meeting notes with decisions and action items",
prompt: DETAILED_NOTES_PROMPT,
- previousPrompts: [],
+ previousPrompts: [DETAILED_NOTES_PROMPT_1_10_0],
icon: "sparkles",
sortOrder: 1,
},
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index 269edceaa..13b4bfcc3 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -28,6 +28,7 @@ import {
} from "./ai/openaiBase";
import {
applyChatCompletionsParams,
+ emptyResponseError,
fetchWithParamFallback,
isTruncatedFinishReason,
} from "./ai/chatRequestBody";
@@ -430,7 +431,10 @@ class ReasoningService extends BaseReasoningService {
hasMessage: !!choice.message,
response: JSON.stringify(choice).substring(0, 500),
});
- throw new Error(`${providerName} returned empty response`);
+ throw (
+ emptyResponseError(providerName, config, isTruncatedFinishReason(choice.finish_reason)) ??
+ new Error(`${providerName} returned empty response`)
+ );
}
logger.logReasoning(`${providerName.toUpperCase()}_RESPONSE`, {
diff --git a/src/services/ai/chatRequestBody.ts b/src/services/ai/chatRequestBody.ts
index 940308c04..2599ba055 100644
--- a/src/services/ai/chatRequestBody.ts
+++ b/src/services/ai/chatRequestBody.ts
@@ -70,6 +70,24 @@ export function isTruncatedFinishReason(reason: unknown): boolean {
return reason === "length" || reason === "max_tokens";
}
+/**
+ * Error for a completion that produced no text, or null when the caller may
+ * echo its input instead. Only the default cleanup transform (no systemPrompt)
+ * may echo: a prompted task would take its raw material as the finished result.
+ */
+export function emptyResponseError(
+ providerName: string,
+ config: ReasoningConfig,
+ responseIncomplete: boolean
+): Error | null {
+ if (config.requireCompleteOutput) return new Error("Model returned an empty selection edit");
+ if (responseIncomplete) {
+ return new Error("Model ran out of output tokens before producing a response");
+ }
+ if (config.systemPrompt) return new Error(`${providerName} returned empty response`);
+ return null;
+}
+
/**
* Shaped params a backend may reject by name with a 400/422. Only params this
* module's shaping layer added are strippable — never messages or model — so a
diff --git a/src/services/ai/inferenceProviders/openai.ts b/src/services/ai/inferenceProviders/openai.ts
index 77c9373ed..57cbb63cb 100644
--- a/src/services/ai/inferenceProviders/openai.ts
+++ b/src/services/ai/inferenceProviders/openai.ts
@@ -1,12 +1,13 @@
import type { InferenceProvider } from "./types";
import { API_ENDPOINTS, TOKEN_LIMITS, buildApiUrl } from "../../../config/constants";
-import { getOpenAiApiConfig } from "../../../models/ModelRegistry";
+import { getCloudModel, getOpenAiApiConfig } from "../../../models/ModelRegistry";
import { getSettings } from "../../../stores/settingsStore";
import { withRetry, createApiRetryStrategy, httpError } from "../../../utils/retry";
import logger from "../../../utils/logger";
import { canBorrowCleanupCustomKey, resolveConfiguredOpenAIBase } from "../openaiBase";
import {
applyChatCompletionsParams,
+ emptyResponseError,
fetchWithParamFallback,
isTruncatedFinishReason,
} from "../chatRequestBody";
@@ -18,6 +19,10 @@ import { openCodeSessionHeaders } from "../openCodeSession";
const OPENAI_ENDPOINT_PREF_STORAGE_KEY = "openAiEndpointPreference";
const PROBE_TIMEOUT_MS = 2_000;
+// OpenAI counts a reasoning model's hidden reasoning against the output cap and
+// recommends reserving at least 25k tokens for reasoning plus output. A cap,
+// not a spend: an unused allowance costs nothing.
+const REASONING_MODEL_MIN_OUTPUT_TOKENS = 25_000;
const endpointPreferenceCache = new Map<string, "responses" | "chat">();
const probedBases = new Set<string>();
@@ -224,7 +229,7 @@ export const openaiProvider: InferenceProvider = {
const timeoutSeconds = getLlmRequestTimeoutSeconds();
const timeoutId = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
try {
- const maxTokens =
+ const requestedMaxTokens =
config.maxTokens ||
Math.max(
4096,
@@ -235,6 +240,14 @@ export const openaiProvider: InferenceProvider = {
TOKEN_LIMITS.TOKEN_MULTIPLIER
)
);
+ // A known endpoint host knows its own request shape better than the model id does.
+ const apiConfig = dialect ?? getOpenAiApiConfig(model, resolvedProvider);
+ // Only registry-known OpenAI reasoning models on OpenAI's own host: an
+ // unknown id (fine-tune, proxy) may reject a cap above its output limit.
+ const maxTokens =
+ !isCustomEndpoint && getCloudModel(model)?.supportsTemperature === false
+ ? Math.max(requestedMaxTokens, REASONING_MODEL_MIN_OUTPUT_TOKENS)
+ : requestedMaxTokens;
const requestBody: Record<string, unknown> = { model };
@@ -242,8 +255,6 @@ export const openaiProvider: InferenceProvider = {
requestBody.input = buildMessages(type);
requestBody.store = false;
requestBody.max_output_tokens = maxTokens;
- // A known endpoint host knows its own request shape better than the model id does.
- const apiConfig = dialect ?? getOpenAiApiConfig(model, resolvedProvider);
if (apiConfig.supportsTemperature) {
requestBody.temperature = config.temperature ?? (config.systemPrompt ? 0.3 : 0);
}
@@ -326,14 +337,12 @@ export const openaiProvider: InferenceProvider = {
const isResponsesApi = Array.isArray(response?.output);
const isChatCompletions = Array.isArray(response?.choices);
- if (config.requireCompleteOutput) {
- const responseIncomplete =
- response?.status === "incomplete" ||
- !!response?.incomplete_details ||
- response?.choices?.some((choice: any) => isTruncatedFinishReason(choice?.finish_reason));
- if (responseIncomplete) {
- throw new Error("Model output was truncated before the selection edit completed");
- }
+ const responseIncomplete =
+ response?.status === "incomplete" ||
+ !!response?.incomplete_details ||
+ response?.choices?.some((choice: any) => isTruncatedFinishReason(choice?.finish_reason));
+ if (config.requireCompleteOutput && responseIncomplete) {
+ throw new Error("Model output was truncated before the selection edit completed");
}
logger.logReasoning("OPENAI_RAW_RESPONSE", {
@@ -350,6 +359,7 @@ export const openaiProvider: InferenceProvider = {
});
let responseText = "";
+ let refusal = "";
if (isResponsesApi) {
for (const item of response.output) {
@@ -359,6 +369,9 @@ export const openaiProvider: InferenceProvider = {
responseText = content.text.trim();
break;
}
+ if (content.type === "refusal" && content.refusal) {
+ refusal = content.refusal;
+ }
}
if (responseText) break;
}
@@ -406,9 +419,11 @@ export const openaiProvider: InferenceProvider = {
});
if (!responseText) {
- if (config.requireCompleteOutput) {
- throw new Error("Model returned an empty selection edit");
+ if (refusal) {
+ throw new Error(`Model declined the request: ${refusal}`);
}
+ const error = emptyResponseError("OpenAI", config, !!responseIncomplete);
+ if (error) throw error;
logger.logReasoning("OPENAI_EMPTY_RESPONSE_FALLBACK", {
model,
originalTextLength: text.length,
diff --git a/src/services/ai/inferenceProviders/tinfoil.ts b/src/services/ai/inferenceProviders/tinfoil.ts
index 26f5b5d51..b5be6d267 100644
--- a/src/services/ai/inferenceProviders/tinfoil.ts
+++ b/src/services/ai/inferenceProviders/tinfoil.ts
@@ -2,7 +2,11 @@ import type { InferenceProvider } from "./types";
import { TOKEN_LIMITS } from "../../../config/constants";
import { withRetry, createApiRetryStrategy } from "../../../utils/retry";
import logger from "../../../utils/logger";
-import { applyChatCompletionsParams, isTruncatedFinishReason } from "../chatRequestBody";
+import {
+ applyChatCompletionsParams,
+ emptyResponseError,
+ isTruncatedFinishReason,
+} from "../chatRequestBody";
import { getTinfoilChatClient } from "../tinfoilClient";
import { getLlmRequestTimeoutSeconds } from "../../../helpers/llmRequestTimeout.js";
import { wrapCleanupTranscript } from "../../../config/prompts";
@@ -56,10 +60,10 @@ export const tinfoilProvider: InferenceProvider = {
.find((content: unknown) => typeof content === "string" && content.trim())
?.trim() || "";
- if (
- config.requireCompleteOutput &&
- response.choices?.some((choice: any) => isTruncatedFinishReason(choice?.finish_reason))
- ) {
+ const responseIncomplete = response.choices?.some((choice: any) =>
+ isTruncatedFinishReason(choice?.finish_reason)
+ );
+ if (config.requireCompleteOutput && responseIncomplete) {
throw new Error("Model output was truncated before the selection edit completed");
}
@@ -72,9 +76,8 @@ export const tinfoilProvider: InferenceProvider = {
});
if (!responseText) {
- if (config.requireCompleteOutput) {
- throw new Error("Model returned an empty selection edit");
- }
+ const error = emptyResponseError("Tinfoil", config, !!responseIncomplete);
+ if (error) throw error;
logger.logReasoning("TINFOIL_EMPTY_RESPONSE_FALLBACK", {
model,
originalTextLength: text.length,
diff --git a/src/stores/actionProcessingStore.ts b/src/stores/actionProcessingStore.ts
index b347ecaa2..ff0d639ba 100644
--- a/src/stores/actionProcessingStore.ts
+++ b/src/stores/actionProcessingStore.ts
@@ -187,6 +187,12 @@ export function runBackgroundAction(
...providerOverrides,
});
+ // IPC-bridged providers relay whatever the model returned; a blank
+ // result must not be saved as the enhanced note.
+ if (!enhanced.trim()) {
+ throw new Error("Model returned no text");
+ }
+
if (cancelledFlags.get(noteId)) return;
let title: string | undefined;
diff --git a/test/services/openaiReasoningOutput.test.js b/test/services/openaiReasoningOutput.test.js
new file mode 100644
index 000000000..babceea47
--- /dev/null
+++ b/test/services/openaiReasoningOutput.test.js
@@ -0,0 +1,234 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+const load = () => import("../../src/services/ai/inferenceProviders/openai.ts");
+
+// A reasoning model's hidden reasoning is billed against max_output_tokens, so
+// a summary-sized cap could be spent entirely on reasoning. The Responses API
+// then answers "incomplete" with only a reasoning item, and the provider used
+// to hand the caller its own input back as if it were the model's output —
+// Generate AI Summary saved the raw transcript as the enhanced note.
+
+const TRANSCRIPT = "## Meeting Transcript\nYou: we agreed to ship on Friday.\n".repeat(50);
+
+function makeCtx() {
+ return {
+ getApiKey: async () => "test-key",
+ getSystemPrompt: () => "Clean the transcript",
+ getCustomDictionary: () => [],
+ getPreferredLanguage: () => "en",
+ getUiLanguage: () => "en",
+ callChatCompletionsApi: async () => {
+ throw new Error("Unexpected chat completions delegation");
+ },
+ calculateMaxTokens: () => 4096,
+ };
+}
+
+const jsonResponse = (body, status = 200) =>
+ new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });
+
+/** Serve /models as unavailable and /responses via `respond(parsedBody)`. */
+function installFetch(t, respond) {
+ const originalFetch = globalThis.fetch;
+ t.after(() => {
+ globalThis.fetch = originalFetch;
+ });
+ const bodies = [];
+ globalThis.fetch = async (input, init = {}) => {
+ const endpoint = String(input);
+ if ((init.method || "GET") === "GET" && endpoint.endsWith("/models")) {
+ return jsonResponse({ error: { message: "unauthorized" } }, 401);
+ }
+ if (endpoint.endsWith("/responses")) {
+ const body = JSON.parse(init.body);
+ bodies.push(body);
+ return respond(body);
+ }
+ if (endpoint.endsWith("/chat/completions")) {
+ const body = JSON.parse(init.body);
+ bodies.push(body);
+ return respond(body);
+ }
+ throw new Error(`Unexpected request: ${endpoint}`);
+ };
+ return bodies;
+}
+
+const completeMessage = (text) =>
+ jsonResponse({
+ status: "completed",
+ output: [{ type: "message", content: [{ type: "output_text", text }] }],
+ });
+
+test("an OpenAI reasoning model gets an output cap that leaves room for its reasoning", async (t) => {
+ const bodies = installFetch(t, () => completeMessage("# Notes"));
+ const { openaiProvider } = await load();
+
+ const result = await openaiProvider.call({
+ text: TRANSCRIPT,
+ model: "gpt-5.6-terra",
+ agentName: null,
+ config: { provider: "openai", systemPrompt: "Summarize", maxTokens: 4096 },
+ ctx: makeCtx(),
+ });
+
+ assert.equal(result, "# Notes");
+ assert.equal(bodies.length, 1);
+ assert.ok(
+ bodies[0].max_output_tokens >= 25_000,
+ `expected reasoning headroom, got ${bodies[0].max_output_tokens}`
+ );
+});
+
+test("a non-reasoning OpenAI model keeps the caller's output budget", async (t) => {
+ const bodies = installFetch(t, () => completeMessage("# Notes"));
+ const { openaiProvider } = await load();
+
+ await openaiProvider.call({
+ text: TRANSCRIPT,
+ model: "gpt-4.1",
+ agentName: null,
+ config: { provider: "openai", systemPrompt: "Summarize", maxTokens: 4096 },
+ ctx: makeCtx(),
+ });
+
+ assert.equal(bodies[0].max_output_tokens, 4096);
+});
+
+test("a model id the registry does not know keeps the caller's output budget", async (t) => {
+ // A fine-tune or proxy id may sit on a model that rejects a cap above its own limit.
+ const bodies = installFetch(t, () => completeMessage("# Notes"));
+ const { openaiProvider } = await load();
+
+ await openaiProvider.call({
+ text: TRANSCRIPT,
+ model: "ft:gpt-4o-2024-08-06:acme::abc123",
+ agentName: null,
+ config: { provider: "openai", systemPrompt: "Summarize", maxTokens: 4096 },
+ ctx: makeCtx(),
+ });
+
+ assert.equal(bodies[0].max_output_tokens, 4096);
+});
+
+test("a custom endpoint keeps the caller's output budget even for a reasoning-shaped model id", async (t) => {
+ const bodies = installFetch(t, () => completeMessage("# Notes"));
+ const { openaiProvider } = await load();
+
+ await openaiProvider.call({
+ text: TRANSCRIPT,
+ model: "gpt-5.6-terra",
+ agentName: null,
+ config: {
+ provider: "custom",
+ baseUrl: "https://reasoning-proxy.example/v1/responses",
+ customApiKey: "test-key",
+ systemPrompt: "Summarize",
+ maxTokens: 4096,
+ },
+ ctx: makeCtx(),
+ });
+
+ assert.equal(bodies[0].max_output_tokens, 4096);
+});
+
+test("a Responses result that ran out of tokens before any text is an error, not the input echoed back", async (t) => {
+ installFetch(t, () =>
+ jsonResponse({
+ status: "incomplete",
+ incomplete_details: { reason: "max_output_tokens" },
+ output: [{ type: "reasoning", summary: [] }],
+ })
+ );
+ const { openaiProvider } = await load();
+
+ await assert.rejects(
+ openaiProvider.call({
+ text: TRANSCRIPT,
+ model: "gpt-5.6-terra",
+ agentName: null,
+ config: { provider: "openai", systemPrompt: "Summarize", maxTokens: 4096 },
+ ctx: makeCtx(),
+ }),
+ /ran out of output tokens/
+ );
+});
+
+test("a Chat Completions result cut off before any text is an error, not the input echoed back", async (t) => {
+ installFetch(t, () =>
+ jsonResponse({ choices: [{ message: { content: "" }, finish_reason: "length" }] })
+ );
+ const { openaiProvider } = await load();
+
+ await assert.rejects(
+ openaiProvider.call({
+ text: TRANSCRIPT,
+ model: "gpt-5.6-terra",
+ agentName: null,
+ config: {
+ provider: "custom",
+ baseUrl: "https://chat-only.example/v1/chat/completions",
+ customApiKey: "test-key",
+ systemPrompt: "Summarize",
+ maxTokens: 4096,
+ },
+ ctx: makeCtx(),
+ }),
+ /ran out of output tokens/
+ );
+});
+
+test("an empty but complete response on a task with its own prompt is an error, not the input echoed back", async (t) => {
+ installFetch(t, () => completeMessage(""));
+ const { openaiProvider } = await load();
+
+ await assert.rejects(
+ openaiProvider.call({
+ text: TRANSCRIPT,
+ model: "gpt-5.6-terra",
+ agentName: null,
+ config: { provider: "openai", systemPrompt: "Summarize", maxTokens: 4096 },
+ ctx: makeCtx(),
+ }),
+ /empty response/
+ );
+});
+
+test("a refusal surfaces as an error carrying the model's reason", async (t) => {
+ installFetch(t, () =>
+ jsonResponse({
+ status: "completed",
+ output: [
+ { type: "message", content: [{ type: "refusal", refusal: "I can't help with that." }] },
+ ],
+ })
+ );
+ const { openaiProvider } = await load();
+
+ await assert.rejects(
+ openaiProvider.call({
+ text: TRANSCRIPT,
+ model: "gpt-5.6-terra",
+ agentName: null,
+ config: { provider: "openai", systemPrompt: "Summarize", maxTokens: 4096 },
+ ctx: makeCtx(),
+ }),
+ /declined the request: I can't help with that\./
+ );
+});
+
+test("an empty but complete response still falls back to the input for cleanup", async (t) => {
+ installFetch(t, () => completeMessage(""));
+ const { openaiProvider } = await load();
+
+ const result = await openaiProvider.call({
+ text: "raw dictation",
+ model: "gpt-4.1",
+ agentName: null,
+ config: { provider: "openai" },
+ ctx: makeCtx(),
+ });
+
+ assert.equal(result, "raw dictation");
+});
diff --git a/test/services/tinfoilReasoningOutput.test.js b/test/services/tinfoilReasoningOutput.test.js
new file mode 100644
index 000000000..b7bfc850a
--- /dev/null
+++ b/test/services/tinfoilReasoningOutput.test.js
@@ -0,0 +1,87 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");
+
+// Tinfoil serves open-weight reasoning models whose thinking counts against
+// max_tokens. When the cap is hit before any text, the provider used to hand
+// the caller its own input back as if the model had produced it.
+
+async function loadProvider(t) {
+ installBrowserGlobals(t);
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-tinfoil-output-test-",
+ mockModules: {
+ "/tinfoilClient": `
+ export const getTinfoilChatClient = async () => ({
+ chat: { completions: { create: async () => globalThis.__tinfoilResponse } },
+ });
+ `,
+ },
+ });
+ t.after(() => {
+ delete globalThis.__tinfoilResponse;
+ });
+ const { tinfoilProvider } = await vite.ssrLoadModule(
+ "/services/ai/inferenceProviders/tinfoil.ts"
+ );
+ return tinfoilProvider;
+}
+
+const ctx = {
+ getApiKey: async () => "test-key",
+ getSystemPrompt: () => "Clean the transcript",
+ calculateMaxTokens: () => 4096,
+};
+
+test("a Tinfoil result cut off before any text is an error, not the input echoed back", async (t) => {
+ const tinfoilProvider = await loadProvider(t);
+ globalThis.__tinfoilResponse = {
+ choices: [{ message: { content: "" }, finish_reason: "length" }],
+ };
+
+ await assert.rejects(
+ tinfoilProvider.call({
+ text: "## Meeting Transcript\nYou: ship on Friday.",
+ model: "gpt-oss-120b",
+ agentName: null,
+ config: { systemPrompt: "Summarize", maxTokens: 4096 },
+ ctx,
+ }),
+ /ran out of output tokens/
+ );
+});
+
+test("an empty but complete Tinfoil response on a task with its own prompt is an error", async (t) => {
+ const tinfoilProvider = await loadProvider(t);
+ globalThis.__tinfoilResponse = {
+ choices: [{ message: { content: "" }, finish_reason: "stop" }],
+ };
+
+ await assert.rejects(
+ tinfoilProvider.call({
+ text: "## Meeting Transcript\nYou: ship on Friday.",
+ model: "gpt-oss-120b",
+ agentName: null,
+ config: { systemPrompt: "Summarize", maxTokens: 4096 },
+ ctx,
+ }),
+ /empty response/
+ );
+});
+
+test("an empty but complete Tinfoil response still falls back to the input for cleanup", async (t) => {
+ const tinfoilProvider = await loadProvider(t);
+ globalThis.__tinfoilResponse = {
+ choices: [{ message: { content: "" }, finish_reason: "stop" }],
+ };
+
+ const result = await tinfoilProvider.call({
+ text: "raw dictation",
+ model: "gpt-oss-120b",
+ agentName: null,
+ config: {},
+ ctx,
+ });
+
+ assert.equal(result, "raw dictation");
+});
diff --git a/test/stores/actionProcessingNoteOutput.test.js b/test/stores/actionProcessingNoteOutput.test.js
index c6f73f081..f1ba196bf 100644
--- a/test/stores/actionProcessingNoteOutput.test.js
+++ b/test/stores/actionProcessingNoteOutput.test.js
@@ -31,7 +31,7 @@ async function loadStore(t) {
export default {
processText: async (text, model, agentName, config) => {
globalThis.__processTextCalls.push({ text, model, config });
- return "# Notes\\n- decided things";
+ return globalThis.__processTextResult ?? "# Notes\\n- decided things";
},
};
`,
@@ -41,6 +41,7 @@ async function loadStore(t) {
globalThis.__processTextCalls = calls;
t.after(() => {
delete globalThis.__processTextCalls;
+ delete globalThis.__processTextResult;
});
const store = await vite.ssrLoadModule("/stores/actionProcessingStore.ts");
@@ -96,3 +97,22 @@ test("a truncated summary is still saved rather than discarded", async (t) => {
await waitFor(() => updates.length > 0, "the note to be written");
assert.notEqual(calls[0].config.requireCompleteOutput, true);
});
+
+test("a blank result is reported as an error and never saved as the enhanced note", async (t) => {
+ // IPC-bridged providers (local, enterprise, OpenWhispr Cloud) relay whatever
+ // the model returned, including nothing at all.
+ const { store, updates } = await loadStore(t);
+ globalThis.__processTextResult = " ";
+
+ store.runBackgroundAction(
+ 9,
+ "## Meeting Transcript\nYou: ship on Friday.",
+ "hash",
+ ACTION,
+ { modelId: "gpt-4.1", isCloudMode: true, isMeetingNote: true },
+ LABELS
+ );
+
+ await waitFor(() => store.consumeErrorEvents().length > 0 || updates.length > 0, "an outcome");
+ assert.equal(updates.length, 0);
+});