Skip to content

Commit d7da0fc

Browse files
authored
🤖 Re-enable thinking for Anthropic models in compaction (#324)
Now that tools are disabled during compaction, Anthropic models can use thinking without conflicts. Also includes continue message in compaction prompt to help focus the summarization. ## Changes - Remove Anthropic-specific thinking restriction in compactionOptions.ts - Add continue message context to compaction prompt when provided - Update tests to reflect new behavior ## Testing - ✅ Unit tests pass (compactionOptions.test.ts) - ✅ Slash command tests pass (compact.test.ts) - ✅ Type checking passes _Generated with `cmux`_
1 parent e910f1c commit d7da0fc

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/utils/chatCommands.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,12 @@ export function prepareCompactionMessage(options: CompactionOptions): {
135135
} {
136136
const targetWords = options.maxOutputTokens ? Math.round(options.maxOutputTokens / 1.3) : 2000;
137137

138-
const messageText = `Summarize this conversation into a compact form for a new Assistant to continue helping the user. Use approximately ${targetWords} words.`;
138+
// Build compaction message with optional continue context
139+
let messageText = `Summarize this conversation into a compact form for a new Assistant to continue helping the user. Use approximately ${targetWords} words.`;
140+
141+
if (options.continueMessage) {
142+
messageText += `\n\nThe user wants to continue with: ${options.continueMessage}`;
143+
}
139144

140145
// Handle model preference (sticky globally)
141146
const effectiveModel = resolveCompactionModel(options.model);

src/utils/messages/compactionOptions.test.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,20 @@ describe("applyCompactionOverrides", () => {
3131
expect(result.model).toBe("anthropic:claude-haiku-4-5");
3232
});
3333

34-
it("sets thinking to off for Anthropic models", () => {
35-
const compactData: CompactionRequestData = {
34+
it("preserves workspace thinking level for all models", () => {
35+
// Test Anthropic model
36+
const anthropicData: CompactionRequestData = {
3637
model: "anthropic:claude-haiku-4-5",
3738
};
38-
const result = applyCompactionOverrides(baseOptions, compactData);
39-
40-
expect(result.thinkingLevel).toBe("off");
41-
});
39+
const anthropicResult = applyCompactionOverrides(baseOptions, anthropicData);
40+
expect(anthropicResult.thinkingLevel).toBe("medium");
4241

43-
it("preserves workspace thinking level for non-Anthropic models", () => {
44-
const compactData: CompactionRequestData = {
42+
// Test OpenAI model
43+
const openaiData: CompactionRequestData = {
4544
model: "openai:gpt-5-pro",
4645
};
47-
const result = applyCompactionOverrides(baseOptions, compactData);
48-
49-
expect(result.thinkingLevel).toBe("medium");
46+
const openaiResult = applyCompactionOverrides(baseOptions, openaiData);
47+
expect(openaiResult.thinkingLevel).toBe("medium");
5048
});
5149

5250
it("applies maxOutputTokens override", () => {

src/utils/messages/compactionOptions.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ export function applyCompactionOverrides(
2626
// Use custom model if specified, otherwise use workspace default
2727
const compactionModel = compactData.model ?? baseOptions.model;
2828

29-
// Anthropic models don't support thinking, always use "off"
30-
// Non-Anthropic models keep workspace default (backend will enforce policy)
31-
const isAnthropic = compactionModel.startsWith("anthropic:");
32-
3329
return {
3430
...baseOptions,
3531
model: compactionModel,
36-
thinkingLevel: isAnthropic ? "off" : baseOptions.thinkingLevel,
32+
// Keep workspace default thinking level - all models support thinking now that tools are disabled
33+
thinkingLevel: baseOptions.thinkingLevel,
3734
maxOutputTokens: compactData.maxOutputTokens,
3835
mode: "compact" as const,
3936
toolPolicy: [], // Disable all tools during compaction

0 commit comments

Comments
 (0)