From b36bb8beef1e44f00fc62c1ee224ed51f7dc13db Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Thu, 29 Jan 2026 17:17:06 -0800 Subject: [PATCH] feat: enable memfs by default for newly created agents (#748) Co-authored-by: Letta --- src/headless.ts | 8 +++++++- src/index.ts | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/headless.ts b/src/headless.ts index 27d7ce6..196a9fd 100644 --- a/src/headless.ts +++ b/src/headless.ts @@ -213,6 +213,7 @@ export async function handleHeadlessCommand( // Resolve agent (same logic as interactive mode) let agent: AgentState | null = null; + let isNewlyCreatedAgent = false; let specifiedAgentId = values.agent as string | undefined; let specifiedConversationId = values.conversation as string | undefined; const useDefaultConv = values.default as boolean | undefined; @@ -450,6 +451,7 @@ export async function handleHeadlessCommand( stripMessages: true, }); agent = result.agent; + isNewlyCreatedAgent = true; } // Priority 2: Try to use --agent specified ID @@ -481,6 +483,7 @@ export async function handleHeadlessCommand( }; const result = await createAgent(createOptions); agent = result.agent; + isNewlyCreatedAgent = true; } // Priority 4: Try to resume from project settings (.letta/settings.local.json) @@ -589,11 +592,14 @@ export async function handleHeadlessCommand( } } - // Apply memfs flag if specified + // Apply memfs flag if specified, or enable by default for new agents if (memfsFlag) { settingsManager.setMemfsEnabled(agent.id, true); } else if (noMemfsFlag) { settingsManager.setMemfsEnabled(agent.id, false); + } else if (isNewlyCreatedAgent && !isSubagent) { + // Enable memfs by default for newly created agents (but not subagents) + settingsManager.setMemfsEnabled(agent.id, true); } // Sync filesystem-backed memory before creating conversations (only if memfs is enabled) diff --git a/src/index.ts b/src/index.ts index dde1093..720644e 100755 --- a/src/index.ts +++ b/src/index.ts @@ -1427,6 +1427,7 @@ async function main(): Promise { const { getModelUpdateArgs } = await import("./agent/model"); let agent: AgentState | null = null; + let isNewlyCreatedAgent = false; // Priority 1: Import from AgentFile template if (fromAfFile) { @@ -1438,6 +1439,7 @@ async function main(): Promise { stripMessages: true, }); agent = result.agent; + isNewlyCreatedAgent = true; setAgentProvenance({ isNew: true, blocks: [], @@ -1531,6 +1533,7 @@ async function main(): Promise { baseTools, ); agent = result.agent; + isNewlyCreatedAgent = true; setAgentProvenance(result.provenance); } @@ -1596,11 +1599,15 @@ async function main(): Promise { // Set agent context for tools that need it (e.g., Skill tool) setAgentContext(agent.id, skillsDirectory); - // Apply memfs flag if specified + // Apply memfs flag if specified, or enable by default for new agents + const isSubagent = process.env.LETTA_CODE_AGENT_ROLE === "subagent"; if (memfsFlag) { settingsManager.setMemfsEnabled(agent.id, true); } else if (noMemfsFlag) { settingsManager.setMemfsEnabled(agent.id, false); + } else if (isNewlyCreatedAgent && !isSubagent) { + // Enable memfs by default for newly created agents (but not subagents) + settingsManager.setMemfsEnabled(agent.id, true); } // Fire-and-forget: Initialize loaded skills flag (LET-7101) @@ -1826,7 +1833,6 @@ async function main(): Promise { // Save the session (agent + conversation) to settings // Skip for subagents - they shouldn't pollute the LRU settings - const isSubagent = process.env.LETTA_CODE_AGENT_ROLE === "subagent"; if (!isSubagent) { settingsManager.setLocalLastSession( { agentId: agent.id, conversationId: conversationIdToUse },