From 9212dfb52baf907546da080359b3f89d3b6dbb53 Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Sun, 16 Nov 2025 23:44:06 -0800 Subject: [PATCH] feat: add --sleeptime CLI flag (#94) Co-authored-by: Letta --- src/agent/create.ts | 3 +-- src/headless.ts | 6 ++++-- src/index.ts | 7 +++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/agent/create.ts b/src/agent/create.ts index f3f43bb..7663a59 100644 --- a/src/agent/create.ts +++ b/src/agent/create.ts @@ -239,10 +239,9 @@ export async function createAgent( // Update persona block for sleeptime agents (only if persona was newly created, not shared) if (enableSleeptime && newGlobalBlockIds.persona) { - await client.agents.blocks.modify("persona", { + await client.agents.blocks.modify("memory_persona", { agent_id: agent.id, value: SLEEPTIME_MEMORY_PERSONA, - label: "memory_persona", description: "Instructions for the sleep-time memory management agent", }); } diff --git a/src/headless.ts b/src/headless.ts index 5d4ae55..4e2c914 100644 --- a/src/headless.ts +++ b/src/headless.ts @@ -49,6 +49,7 @@ export async function handleHeadlessCommand( skills: { type: "string" }, link: { type: "boolean" }, unlink: { type: "boolean" }, + sleeptime: { type: "boolean" }, }, strict: false, allowPositionals: true, @@ -81,6 +82,7 @@ export async function handleHeadlessCommand( const specifiedAgentId = values.agent as string | undefined; const shouldContinue = values.continue as boolean | undefined; const forceNew = values.new as boolean | undefined; + const sleeptimeFlag = (values.sleeptime as boolean | undefined) ?? undefined; // Priority 1: Try to use --agent specified ID if (specifiedAgentId) { @@ -102,7 +104,7 @@ export async function handleHeadlessCommand( forceNew, skillsDirectory, settings.parallelToolCalls, - settings.enableSleeptime, + sleeptimeFlag ?? settings.enableSleeptime, ); } @@ -143,7 +145,7 @@ export async function handleHeadlessCommand( false, skillsDirectory, settings.parallelToolCalls, - settings.enableSleeptime, + sleeptimeFlag ?? settings.enableSleeptime, ); } diff --git a/src/index.ts b/src/index.ts index 9cc17c7..c3717a9 100755 --- a/src/index.ts +++ b/src/index.ts @@ -33,6 +33,7 @@ OPTIONS --output-format Output format for headless mode (text, json, stream-json) Default: text --skills Custom path to skills directory (default: .skills in current directory) + --sleeptime Enable sleeptime memory management (only for new agents) BEHAVIOR By default, letta auto-resumes the last agent used in the current directory @@ -95,6 +96,7 @@ async function main() { skills: { type: "string" }, link: { type: "boolean" }, unlink: { type: "boolean" }, + sleeptime: { type: "boolean" }, }, strict: true, allowPositionals: true, @@ -137,6 +139,7 @@ async function main() { const specifiedAgentId = (values.agent as string | undefined) ?? null; const specifiedModel = (values.model as string | undefined) ?? undefined; const skillsDirectory = (values.skills as string | undefined) ?? undefined; + const sleeptimeFlag = (values.sleeptime as boolean | undefined) ?? undefined; const isHeadless = values.prompt || values.run || !process.stdin.isTTY; // Check if API key is configured @@ -364,7 +367,7 @@ async function main() { forceNew, skillsDirectory, settings.parallelToolCalls, - settings.enableSleeptime, + sleeptimeFlag ?? settings.enableSleeptime, ); } @@ -410,7 +413,7 @@ async function main() { false, skillsDirectory, settings.parallelToolCalls, - settings.enableSleeptime, + sleeptimeFlag ?? settings.enableSleeptime, ); }