Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/cli/src/ui/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1739,9 +1739,10 @@ export const AppContainer = (props: AppContainerProps) => {
return;
}

// 3. Truncate API history and strip stale thinking blocks
// 3. Truncate API history to the target point.
// Do NOT strip thought parts — reasoning models (e.g. DeepSeek) require
// reasoning_content continuity across all turns in the conversation.
geminiClient.truncateHistory(apiTruncateIndex);
geminiClient.stripThoughtsFromHistory();

// 4. Truncate UI history (keep everything before the target item)
const truncatedUi = originalHistory.filter((h) => h.id < userItem.id);
Expand Down
10 changes: 0 additions & 10 deletions packages/core/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ vi.mock('../core/client.js', () => ({
GeminiClient: vi.fn().mockImplementation(() => ({
initialize: vi.fn().mockResolvedValue(undefined),
isInitialized: vi.fn().mockReturnValue(true),
stripThoughtsFromHistory: vi.fn(),
setTools: vi.fn(),
})),
}));
Expand Down Expand Up @@ -477,10 +476,6 @@ describe('Server Config (config.ts)', () => {
await config.refreshAuth(AuthType.USE_VERTEX_AI);

await config.refreshAuth(AuthType.USE_GEMINI);

expect(
config.getGeminiClient().stripThoughtsFromHistory,
).not.toHaveBeenCalledWith();
});
});

Expand Down Expand Up @@ -562,12 +557,7 @@ describe('Server Config (config.ts)', () => {

await config.refreshAuth(AuthType.QWEN_OAUTH);

const stripSpy = config.getGeminiClient().stripThoughtsFromHistory;
vi.mocked(stripSpy).mockClear();

await config.switchModel(AuthType.QWEN_OAUTH, 'coder-model');

expect(stripSpy).not.toHaveBeenCalled();
});
});

Expand Down
40 changes: 0 additions & 40 deletions packages/core/src/core/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ describe('Gemini Client (client.ts)', () => {
mockChat = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;
});
Expand Down Expand Up @@ -512,8 +511,6 @@ describe('Gemini Client (client.ts)', () => {
getHistory: mockGetHistory,
addHistory: vi.fn(),
setHistory: vi.fn(),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
} as unknown as GeminiChat;
});

Expand All @@ -534,8 +531,6 @@ describe('Gemini Client (client.ts)', () => {
const mockOriginalChat: Partial<GeminiChat> = {
getHistory: vi.fn((_curated?: boolean) => chatHistory),
setHistory: vi.fn(),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockOriginalChat as GeminiChat;

Expand Down Expand Up @@ -1227,8 +1222,6 @@ describe('Gemini Client (client.ts)', () => {
const mockChat = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
} as unknown as GeminiChat;
client['chat'] = mockChat;

Expand Down Expand Up @@ -1283,8 +1276,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1340,8 +1331,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1400,7 +1389,6 @@ hello
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1463,7 +1451,6 @@ hello
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1519,7 +1506,6 @@ hello
{ role: 'user', parts: [{ text: 'I prefer terse responses.' }] },
{ role: 'model', parts: [{ text: 'Done' }] },
]),
stripThoughtsFromHistory: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1583,8 +1569,6 @@ hello
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1623,8 +1607,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1669,8 +1651,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1758,8 +1738,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1816,8 +1794,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -1898,8 +1874,6 @@ Other open files:
.mockReturnValue([
{ role: 'user', parts: [{ text: 'previous message' }] },
]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;
});
Expand Down Expand Up @@ -2152,8 +2126,6 @@ Other open files:
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]), // Default empty history
setHistory: vi.fn(),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -2492,8 +2464,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -2530,8 +2500,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand Down Expand Up @@ -2571,8 +2539,6 @@ Other open files:
const mockChat: Partial<GeminiChat> = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;

Expand All @@ -2596,8 +2562,6 @@ Other open files:
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
setHistory: vi.fn(),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
stripOrphanedUserEntriesFromHistory: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;
Expand Down Expand Up @@ -2629,8 +2593,6 @@ Other open files:
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
setHistory: vi.fn(),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
stripOrphanedUserEntriesFromHistory: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;
Expand Down Expand Up @@ -2674,8 +2636,6 @@ Other open files:
mockChat = {
addHistory: vi.fn(),
getHistory: vi.fn().mockReturnValue([]),
stripThoughtsFromHistory: vi.fn(),
stripThoughtsFromHistoryKeepRecent: vi.fn(),
};
client['chat'] = mockChat as GeminiChat;
});
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ export class GeminiClient {
return this.getChat().getHistory(curated);
}

stripThoughtsFromHistory() {
this.getChat().stripThoughtsFromHistory();
}

private stripOrphanedUserEntriesFromHistory() {
this.getChat().stripOrphanedUserEntriesFromHistory();
}
Expand Down
Loading
Loading