fix: remove redundant --default flag and allow --conv default with --new-agent (#1127)

This commit is contained in:
Devansh Jain
2026-02-24 18:54:50 -08:00
committed by GitHub
parent f12d091668
commit bec120bf90
2 changed files with 5 additions and 31 deletions

View File

@@ -258,7 +258,6 @@ export async function handleHeadlessCommand(
continue: { type: "boolean", short: "c" }, continue: { type: "boolean", short: "c" },
resume: { type: "boolean", short: "r" }, resume: { type: "boolean", short: "r" },
conversation: { type: "string" }, conversation: { type: "string" },
default: { type: "boolean" }, // Alias for --conv default
"new-agent": { type: "boolean" }, "new-agent": { type: "boolean" },
new: { type: "boolean" }, // Deprecated - kept for helpful error message new: { type: "boolean" }, // Deprecated - kept for helpful error message
agent: { type: "string", short: "a" }, agent: { type: "string", short: "a" },
@@ -414,20 +413,8 @@ export async function handleHeadlessCommand(
let agent: AgentState | null = null; let agent: AgentState | null = null;
let specifiedAgentId = values.agent as string | undefined; let specifiedAgentId = values.agent as string | undefined;
let specifiedConversationId = values.conversation 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 shouldContinue = values.continue as boolean | undefined;
const forceNew = values["new-agent"] 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 systemPromptPreset = values.system as string | undefined;
const systemCustom = values["system-custom"] as string | undefined; const systemCustom = values["system-custom"] as string | undefined;
const systemAppend = values["system-append"] as string | undefined; const systemAppend = values["system-append"] as string | undefined;
@@ -541,8 +528,8 @@ export async function handleHeadlessCommand(
specifiedConversationId = "default"; specifiedConversationId = "default";
} }
// Validate --conv default requires --agent // Validate --conv default requires --agent (unless --new-agent will create one)
if (specifiedConversationId === "default" && !specifiedAgentId) { if (specifiedConversationId === "default" && !specifiedAgentId && !forceNew) {
console.error("Error: --conv default requires --agent <agent-id>"); console.error("Error: --conv default requires --agent <agent-id>");
console.error("Usage: letta --agent agent-xyz --conv default"); console.error("Usage: letta --agent agent-xyz --conv default");
console.error(" or: letta --conv agent-xyz (shorthand)"); console.error(" or: letta --conv agent-xyz (shorthand)");
@@ -1091,7 +1078,7 @@ export async function handleHeadlessCommand(
} else { } else {
// Default for headless: always create a new conversation to avoid // Default for headless: always create a new conversation to avoid
// 409 "conversation busy" races (e.g., parent agent calling letta -p). // 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. // primary conversation.
const conversation = await client.conversations.create({ const conversation = await client.conversations.create({
agent_id: agent.id, agent_id: agent.id,

View File

@@ -416,7 +416,6 @@ async function main(): Promise<void> {
continue: { type: "boolean" }, // Deprecated - kept for error message continue: { type: "boolean" }, // Deprecated - kept for error message
resume: { type: "boolean", short: "r" }, // Resume last session (or specific conversation with --conversation) 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) 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-agent": { type: "boolean" }, // Force create a new agent
new: { type: "boolean" }, // Deprecated - kept for helpful error message new: { type: "boolean" }, // Deprecated - kept for helpful error message
"init-blocks": { type: "string" }, "init-blocks": { type: "string" },
@@ -525,20 +524,8 @@ async function main(): Promise<void> {
const shouldResume = (values.resume as boolean | undefined) ?? false; const shouldResume = (values.resume as boolean | undefined) ?? false;
let specifiedConversationId = let specifiedConversationId =
(values.conversation as string | undefined) ?? null; // Specific conversation to resume (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; 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) // --new: Create a new conversation (for concurrent sessions)
const forceNewConversation = (values.new as boolean | undefined) ?? false; const forceNewConversation = (values.new as boolean | undefined) ?? false;
@@ -558,8 +545,8 @@ async function main(): Promise<void> {
specifiedConversationId = "default"; specifiedConversationId = "default";
} }
// Validate --conv default requires --agent // Validate --conv default requires --agent (unless --new-agent will create one)
if (specifiedConversationId === "default" && !specifiedAgentId) { if (specifiedConversationId === "default" && !specifiedAgentId && !forceNew) {
console.error("Error: --conv default requires --agent <agent-id>"); console.error("Error: --conv default requires --agent <agent-id>");
console.error("Usage: letta --agent agent-xyz --conv default"); console.error("Usage: letta --agent agent-xyz --conv default");
console.error(" or: letta --conv agent-xyz (shorthand)"); console.error(" or: letta --conv agent-xyz (shorthand)");