From 6707af5930a0b41cca8558ec71a85bebca2c8c13 Mon Sep 17 00:00:00 2001 From: amysguan <64990783+amysguan@users.noreply.github.com> Date: Thu, 26 Feb 2026 18:00:23 -0800 Subject: [PATCH] feat(tui): add self modes to /compact (#1119) Co-authored-by: Amy Guan --- bun.lock | 4 ++-- package.json | 2 +- src/cli/App.tsx | 42 ++++++++++++++++++++---------------- src/cli/commands/registry.ts | 2 +- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/bun.lock b/bun.lock index 283a66d..2c9104d 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "@letta-ai/letta-code", "dependencies": { - "@letta-ai/letta-client": "^1.7.8", + "@letta-ai/letta-client": "^1.7.9", "glob": "^13.0.0", "ink-link": "^5.0.0", "open": "^10.2.0", @@ -93,7 +93,7 @@ "@isaacs/brace-expansion": ["@isaacs/brace-expansion@5.0.0", "", { "dependencies": { "@isaacs/balanced-match": "^4.0.1" } }, "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA=="], - "@letta-ai/letta-client": ["@letta-ai/letta-client@1.7.8", "", {}, "sha512-l7BGsAZOI8b+H1RO2IMzMv3P0VXj6Of2wXLCg5LZejOk0dHLLBi2me4WspLg+6zWPGIRJwMRsxmfp4kV9Zzh6g=="], + "@letta-ai/letta-client": ["@letta-ai/letta-client@1.7.9", "", {}, "sha512-ZoUH71/c5t7/7H5DF52lduAKGCet/UoAe2PZTwKCt7CpENdyVlAsM1gV3q8xABmu4RZ1zmwiOjbQT8yWty6w3g=="], "@types/bun": ["@types/bun@1.3.7", "", { "dependencies": { "bun-types": "1.3.7" } }, "sha512-lmNuMda+Z9b7tmhA0tohwy8ZWFSnmQm1UDWXtH5r9F7wZCfkeO3Jx7wKQ1EOiKq43yHts7ky6r8SDJQWRNupkA=="], diff --git a/package.json b/package.json index ac672b5..dbd18d9 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "access": "public" }, "dependencies": { - "@letta-ai/letta-client": "^1.7.8", + "@letta-ai/letta-client": "^1.7.9", "glob": "^13.0.0", "ink-link": "^5.0.0", "open": "^10.2.0", diff --git a/src/cli/App.tsx b/src/cli/App.tsx index ee4a070..5e47a19 100644 --- a/src/cli/App.tsx +++ b/src/cli/App.tsx @@ -7689,11 +7689,16 @@ export default function App({ } // Special handling for /compact command - summarize conversation history - // Supports: /compact, /compact all, /compact sliding_window + // Supports: /compact, /compact all, /compact sliding_window, /compact self_compact_all, /compact self_compact_sliding_window if (msg.trim().startsWith("/compact")) { const parts = msg.trim().split(/\s+/); const rawModeArg = parts[1]; - const validModes = ["all", "sliding_window"]; + const validModes = [ + "all", + "sliding_window", + "self_compact_all", + "self_compact_sliding_window", + ]; if (rawModeArg === "help") { const cmd = commandRunner.start( @@ -7709,13 +7714,20 @@ export default function App({ " /compact — compact with default mode", " /compact all — compact all messages", " /compact sliding_window — compact with sliding window", + " /compact self_compact_all — compact with self compact all", + " /compact self_compact_sliding_window — compact with self compact sliding window", " /compact help — show this help", ].join("\n"); cmd.finish(output, true); return { submitted: true }; } - const modeArg = rawModeArg as "all" | "sliding_window" | undefined; + const modeArg = rawModeArg as + | "all" + | "sliding_window" + | "self_compact_all" + | "self_compact_sliding_window" + | undefined; // Validate mode if provided if (modeArg && !validModes.includes(modeArg)) { @@ -7753,23 +7765,15 @@ export default function App({ const client = await getClient(); - // Compute model handle from llmConfig - const modelHandle = - llmConfig?.model_endpoint_type && llmConfig?.model - ? `${llmConfig.model_endpoint_type}/${llmConfig.model}` - : llmConfig?.model || null; - // Build compaction settings if mode was specified - // Pass mode-specific prompt to override any agent defaults - const compactParams = - modeArg && modelHandle - ? { - compaction_settings: { - mode: modeArg, - model: modelHandle, - }, - } - : undefined; + // On server side, if mode changed, summarize function will use corresponding default prompt for new mode + const compactParams = modeArg + ? { + compaction_settings: { + mode: modeArg, + }, + } + : undefined; // Use agent-level compact API for "default" conversation, // otherwise use conversation-level API diff --git a/src/cli/commands/registry.ts b/src/cli/commands/registry.ts index 75ee943..a7235e9 100644 --- a/src/cli/commands/registry.ts +++ b/src/cli/commands/registry.ts @@ -448,7 +448,7 @@ export const commands: Record = { }, "/compact": { desc: "Summarize conversation history (compaction) with optional mode", - args: "[all|sliding_window]", + args: "[all|sliding_window|self_compact_all|self_compact_sliding_window]", handler: () => { // Handled specially in App.tsx to access client and agent ID return "Compacting conversation...";