From bec120bf905087fc33fc16dc9d598e086a178998 Mon Sep 17 00:00:00 2001 From: Devansh Jain <31609257+devanshrj@users.noreply.github.com> Date: Tue, 24 Feb 2026 18:54:50 -0800 Subject: [PATCH] fix: remove redundant --default flag and allow --conv default with --new-agent (#1127) --- src/headless.ts | 19 +++---------------- src/index.ts | 17 ++--------------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/headless.ts b/src/headless.ts index 0c51d26..421f567 100644 --- a/src/headless.ts +++ b/src/headless.ts @@ -258,7 +258,6 @@ export async function handleHeadlessCommand( continue: { type: "boolean", short: "c" }, resume: { type: "boolean", short: "r" }, conversation: { type: "string" }, - default: { type: "boolean" }, // Alias for --conv default "new-agent": { type: "boolean" }, new: { type: "boolean" }, // Deprecated - kept for helpful error message agent: { type: "string", short: "a" }, @@ -414,20 +413,8 @@ export async function handleHeadlessCommand( let agent: AgentState | null = null; let specifiedAgentId = values.agent as string | undefined; let specifiedConversationId = values.conversation as string | undefined; - const useDefaultConv = values.default as boolean | undefined; const shouldContinue = values.continue as boolean | undefined; const forceNew = values["new-agent"] as boolean | undefined; - - // Handle --default flag (alias for --conv default) - if (useDefaultConv) { - if (specifiedConversationId && specifiedConversationId !== "default") { - console.error( - "Error: --default cannot be used with --conversation (they're mutually exclusive)", - ); - process.exit(1); - } - specifiedConversationId = "default"; - } const systemPromptPreset = values.system as string | undefined; const systemCustom = values["system-custom"] as string | undefined; const systemAppend = values["system-append"] as string | undefined; @@ -541,8 +528,8 @@ export async function handleHeadlessCommand( specifiedConversationId = "default"; } - // Validate --conv default requires --agent - if (specifiedConversationId === "default" && !specifiedAgentId) { + // Validate --conv default requires --agent (unless --new-agent will create one) + if (specifiedConversationId === "default" && !specifiedAgentId && !forceNew) { console.error("Error: --conv default requires --agent "); console.error("Usage: letta --agent agent-xyz --conv default"); console.error(" or: letta --conv agent-xyz (shorthand)"); @@ -1091,7 +1078,7 @@ export async function handleHeadlessCommand( } else { // Default for headless: always create a new conversation to avoid // 409 "conversation busy" races (e.g., parent agent calling letta -p). - // Use --default or --conv default to explicitly target the agent's + // Use --conv default to explicitly target the agent's // primary conversation. const conversation = await client.conversations.create({ agent_id: agent.id, diff --git a/src/index.ts b/src/index.ts index d09f90a..9f8a5f6 100755 --- a/src/index.ts +++ b/src/index.ts @@ -416,7 +416,6 @@ async function main(): Promise { continue: { type: "boolean" }, // Deprecated - kept for error message resume: { type: "boolean", short: "r" }, // Resume last session (or specific conversation with --conversation) conversation: { type: "string", short: "C" }, // Specific conversation ID to resume (--conv alias supported) - default: { type: "boolean" }, // Alias for --conv default (use agent's default conversation) "new-agent": { type: "boolean" }, // Force create a new agent new: { type: "boolean" }, // Deprecated - kept for helpful error message "init-blocks": { type: "string" }, @@ -525,20 +524,8 @@ async function main(): Promise { const shouldResume = (values.resume as boolean | undefined) ?? false; let specifiedConversationId = (values.conversation as string | undefined) ?? null; // Specific conversation to resume - const useDefaultConv = (values.default as boolean | undefined) ?? false; // --default flag const forceNew = (values["new-agent"] as boolean | undefined) ?? false; - // Handle --default flag (alias for --conv default) - if (useDefaultConv) { - if (specifiedConversationId && specifiedConversationId !== "default") { - console.error( - "Error: --default cannot be used with --conversation (they're mutually exclusive)", - ); - process.exit(1); - } - specifiedConversationId = "default"; - } - // --new: Create a new conversation (for concurrent sessions) const forceNewConversation = (values.new as boolean | undefined) ?? false; @@ -558,8 +545,8 @@ async function main(): Promise { specifiedConversationId = "default"; } - // Validate --conv default requires --agent - if (specifiedConversationId === "default" && !specifiedAgentId) { + // Validate --conv default requires --agent (unless --new-agent will create one) + if (specifiedConversationId === "default" && !specifiedAgentId && !forceNew) { console.error("Error: --conv default requires --agent "); console.error("Usage: letta --agent agent-xyz --conv default"); console.error(" or: letta --conv agent-xyz (shorthand)");