feat: enable memfs by default for newly created agents (#748)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-01-29 17:17:06 -08:00
committed by GitHub
parent 9fd87240f9
commit b36bb8beef
2 changed files with 15 additions and 3 deletions

View File

@@ -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)

View File

@@ -1427,6 +1427,7 @@ async function main(): Promise<void> {
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<void> {
stripMessages: true,
});
agent = result.agent;
isNewlyCreatedAgent = true;
setAgentProvenance({
isNew: true,
blocks: [],
@@ -1531,6 +1533,7 @@ async function main(): Promise<void> {
baseTools,
);
agent = result.agent;
isNewlyCreatedAgent = true;
setAgentProvenance(result.provenance);
}
@@ -1596,11 +1599,15 @@ async function main(): Promise<void> {
// 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<void> {
// 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 },