fix: remove redundant --default flag and allow --conv default with --new-agent (#1127)
This commit is contained in:
@@ -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 <agent-id>");
|
||||
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,
|
||||
|
||||
17
src/index.ts
17
src/index.ts
@@ -416,7 +416,6 @@ async function main(): Promise<void> {
|
||||
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<void> {
|
||||
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<void> {
|
||||
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 <agent-id>");
|
||||
console.error("Usage: letta --agent agent-xyz --conv default");
|
||||
console.error(" or: letta --conv agent-xyz (shorthand)");
|
||||
|
||||
Reference in New Issue
Block a user