Skip to content

Commit 178c452

Browse files
committed
🤖 feat: disable auto truncation by default for OpenAI models
Change the default value of disableAutoTruncation from false to true, so the dev-only 'No Trunc' checkbox is checked by default.
1 parent cac3cb0 commit 178c452

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

src/browser/contexts/ProviderOptionsContext.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { createContext, useContext } from "react";
2-
import { usePersistedState } from "@/browser/hooks/usePersistedState";
1+
import React, { createContext, useContext, useLayoutEffect } from "react";
2+
import { updatePersistedState, usePersistedState } from "@/browser/hooks/usePersistedState";
33
import type { MuxProviderOptions } from "@/common/types/providerOptions";
44

55
interface ProviderOptionsContextType {
@@ -11,6 +11,10 @@ interface ProviderOptionsContextType {
1111

1212
const ProviderOptionsContext = createContext<ProviderOptionsContextType | undefined>(undefined);
1313

14+
// Force disableAutoTruncation to true on startup (overrides any stored value)
15+
const OPENAI_OPTIONS_KEY = "provider_options_openai";
16+
const FORCED_OPENAI_OPTIONS: MuxProviderOptions["openai"] = { disableAutoTruncation: true };
17+
1418
export function ProviderOptionsProvider({ children }: { children: React.ReactNode }) {
1519
const [anthropicOptions, setAnthropicOptions] = usePersistedState<
1620
MuxProviderOptions["anthropic"]
@@ -19,12 +23,17 @@ export function ProviderOptionsProvider({ children }: { children: React.ReactNod
1923
});
2024

2125
const [openaiOptions, setOpenAIOptions] = usePersistedState<MuxProviderOptions["openai"]>(
22-
"provider_options_openai",
23-
{
24-
disableAutoTruncation: false,
25-
}
26+
OPENAI_OPTIONS_KEY,
27+
FORCED_OPENAI_OPTIONS
2628
);
2729

30+
// Force disableAutoTruncation to true on every app start
31+
useLayoutEffect(() => {
32+
if (!openaiOptions?.disableAutoTruncation) {
33+
updatePersistedState(OPENAI_OPTIONS_KEY, FORCED_OPENAI_OPTIONS);
34+
}
35+
}, []);
36+
2837
const [googleOptions, setGoogleOptions] = usePersistedState<MuxProviderOptions["google"]>(
2938
"provider_options_google",
3039
{}

src/browser/utils/messages/sendOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function getProviderOptions(): MuxProviderOptions {
2626
{ use1MContext: false }
2727
);
2828
const openai = readPersistedState<MuxProviderOptions["openai"]>("provider_options_openai", {
29-
disableAutoTruncation: false,
29+
disableAutoTruncation: true,
3030
});
3131
const google = readPersistedState<MuxProviderOptions["google"]>("provider_options_google", {});
3232

tests/ipc/sendMessage.heavy.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,21 @@ describeIntegration("sendMessage heavy/load tests", () => {
4141
await withSharedWorkspace(provider, async ({ env, workspaceId, collector }) => {
4242
// Build up large conversation history to exceed context limit
4343
// This approach is model-agnostic - it keeps sending until we've built up enough history
44+
// Use auto-truncation enabled (disableAutoTruncation: false) so history builds up successfully
4445
const largeMessage = "x".repeat(50_000);
4546
for (let i = 0; i < 10; i++) {
4647
await sendMessageWithModel(
4748
env,
4849
workspaceId,
4950
`Message ${i}: ${largeMessage}`,
50-
modelString(provider, model)
51+
modelString(provider, model),
52+
{
53+
providerOptions: {
54+
openai: {
55+
disableAutoTruncation: false,
56+
},
57+
},
58+
}
5159
);
5260
await collector.waitForEvent("stream-end", 30000);
5361
collector.clear();
@@ -93,8 +101,14 @@ describeIntegration("sendMessage heavy/load tests", () => {
93101
env,
94102
workspaceId,
95103
"This should succeed with auto-truncation",
96-
modelString(provider, model)
97-
// disableAutoTruncation defaults to false (auto-truncation enabled)
104+
modelString(provider, model),
105+
{
106+
providerOptions: {
107+
openai: {
108+
disableAutoTruncation: false,
109+
},
110+
},
111+
}
98112
);
99113

100114
expect(successResult.success).toBe(true);

0 commit comments

Comments
 (0)