From 232e24940c88908c17f7ec0879b9bdd706ada119 Mon Sep 17 00:00:00 2001 From: Devansh Jain <31609257+devanshrj@users.noreply.github.com> Date: Thu, 19 Mar 2026 17:34:43 -0700 Subject: [PATCH] fix: resume project-specific conversation on bare `letta` startup (#1457) Co-authored-by: Letta Code --- src/index.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index e8e9728..b9b755a 100755 --- a/src/index.ts +++ b/src/index.ts @@ -66,7 +66,7 @@ Letta Code is a general purpose CLI for interacting with Letta agents USAGE # interactive TUI - letta Resume default conversation (OG single-threaded experience) + letta Resume last conversation for this project letta --new Create a new conversation (for concurrent sessions) letta --continue Resume last session (agent + conversation) directly letta --resume Open agent selector UI to pick agent/conversation @@ -1374,9 +1374,10 @@ async function main(): Promise { const { resolveStartupTarget } = await import( "./agent/resolve-startup-agent" ); + const localSession = settingsManager.getLocalLastSession(process.cwd()); const target = resolveStartupTarget({ localAgentId, - localConversationId: null, // DEFAULT PATH always uses default conv + localConversationId: localSession?.conversationId ?? null, localAgentExists, globalAgentId, globalAgentExists, @@ -1391,8 +1392,9 @@ async function main(): Promise { if (cachedAgent && cachedAgent.id === target.agentId) { setValidatedAgent(cachedAgent); } - // Don't set selectedConversationId — DEFAULT PATH uses default conv. - // Conversation restoration is handled by --continue path instead. + if (target.conversationId && !forceNewConversation) { + setSelectedConversationId(target.conversationId); + } setLoadingState("assembling"); return; case "select": @@ -1918,7 +1920,7 @@ async function main(): Promise { process.exit(1); } } else if (selectedConversationId) { - // User selected a specific conversation from the --resume selector + // Conversation selected from --resume selector or auto-restored from local project settings try { setLoadingState("checking"); const data = await getResumeData( @@ -1934,10 +1936,18 @@ async function main(): Promise { error instanceof APIError && (error.status === 404 || error.status === 422) ) { - console.error(`Conversation ${selectedConversationId} not found`); - process.exit(1); + // Conversation no longer exists — fall back to default conversation + console.warn( + `Previous conversation ${selectedConversationId} not found, falling back to default`, + ); + conversationIdToUse = "default"; + setLoadingState("checking"); + const data = await getResumeData(client, agent, "default"); + setResumeData(data); + setResumedExistingConversation(data.messageHistory.length > 0); + } else { + throw error; } - throw error; } } else if (forceNewConversation) { // --new flag: create a new conversation (for concurrent sessions)