From 1475dd6b4bfcf554fb42084e371e0dab344d530b Mon Sep 17 00:00:00 2001 From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com> Date: Thu, 18 Dec 2025 11:18:39 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20feat:=20disable=20auto=20truncat?= =?UTF-8?q?ion=20by=20default=20for=20OpenAI=20models?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the default value of disableAutoTruncation from false to true, so the dev-only 'No Trunc' checkbox is checked by default. --- .../contexts/ProviderOptionsContext.tsx | 28 +++++++++++++++---- src/browser/utils/messages/sendOptions.ts | 2 +- tests/ipc/sendMessage.heavy.test.ts | 20 +++++++++++-- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/browser/contexts/ProviderOptionsContext.tsx b/src/browser/contexts/ProviderOptionsContext.tsx index 148bb09aa0..fbd02bb67f 100644 --- a/src/browser/contexts/ProviderOptionsContext.tsx +++ b/src/browser/contexts/ProviderOptionsContext.tsx @@ -1,5 +1,9 @@ -import React, { createContext, useContext } from "react"; -import { usePersistedState } from "@/browser/hooks/usePersistedState"; +import React, { createContext, useContext, useLayoutEffect } from "react"; +import { + readPersistedState, + updatePersistedState, + usePersistedState, +} from "@/browser/hooks/usePersistedState"; import type { MuxProviderOptions } from "@/common/types/providerOptions"; interface ProviderOptionsContextType { @@ -11,6 +15,10 @@ interface ProviderOptionsContextType { const ProviderOptionsContext = createContext(undefined); +const OPENAI_OPTIONS_KEY = "provider_options_openai"; +// One-time migration key: force disableAutoTruncation to true for existing users +const OPENAI_TRUNCATION_MIGRATION_KEY = "provider_options_openai_truncation_migrated"; + export function ProviderOptionsProvider({ children }: { children: React.ReactNode }) { const [anthropicOptions, setAnthropicOptions] = usePersistedState< MuxProviderOptions["anthropic"] @@ -19,12 +27,20 @@ export function ProviderOptionsProvider({ children }: { children: React.ReactNod }); const [openaiOptions, setOpenAIOptions] = usePersistedState( - "provider_options_openai", - { - disableAutoTruncation: false, - } + OPENAI_OPTIONS_KEY, + { disableAutoTruncation: true } ); + // One-time migration: force disableAutoTruncation to true for existing users + useLayoutEffect(() => { + const alreadyMigrated = readPersistedState(OPENAI_TRUNCATION_MIGRATION_KEY, false); + if (alreadyMigrated) { + return; + } + updatePersistedState(OPENAI_OPTIONS_KEY, { disableAutoTruncation: true }); + updatePersistedState(OPENAI_TRUNCATION_MIGRATION_KEY, true); + }, []); + const [googleOptions, setGoogleOptions] = usePersistedState( "provider_options_google", {} diff --git a/src/browser/utils/messages/sendOptions.ts b/src/browser/utils/messages/sendOptions.ts index 30e6c1b0b6..685952ce85 100644 --- a/src/browser/utils/messages/sendOptions.ts +++ b/src/browser/utils/messages/sendOptions.ts @@ -26,7 +26,7 @@ function getProviderOptions(): MuxProviderOptions { { use1MContext: false } ); const openai = readPersistedState("provider_options_openai", { - disableAutoTruncation: false, + disableAutoTruncation: true, }); const google = readPersistedState("provider_options_google", {}); diff --git a/tests/ipc/sendMessage.heavy.test.ts b/tests/ipc/sendMessage.heavy.test.ts index dcf9d83630..41228daca9 100644 --- a/tests/ipc/sendMessage.heavy.test.ts +++ b/tests/ipc/sendMessage.heavy.test.ts @@ -41,13 +41,21 @@ describeIntegration("sendMessage heavy/load tests", () => { await withSharedWorkspace(provider, async ({ env, workspaceId, collector }) => { // Build up large conversation history to exceed context limit // This approach is model-agnostic - it keeps sending until we've built up enough history + // Use auto-truncation enabled (disableAutoTruncation: false) so history builds up successfully const largeMessage = "x".repeat(50_000); for (let i = 0; i < 10; i++) { await sendMessageWithModel( env, workspaceId, `Message ${i}: ${largeMessage}`, - modelString(provider, model) + modelString(provider, model), + { + providerOptions: { + openai: { + disableAutoTruncation: false, + }, + }, + } ); await collector.waitForEvent("stream-end", 30000); collector.clear(); @@ -93,8 +101,14 @@ describeIntegration("sendMessage heavy/load tests", () => { env, workspaceId, "This should succeed with auto-truncation", - modelString(provider, model) - // disableAutoTruncation defaults to false (auto-truncation enabled) + modelString(provider, model), + { + providerOptions: { + openai: { + disableAutoTruncation: false, + }, + }, + } ); expect(successResult.success).toBe(true);