fix: prevent subagents from polluting LRU settings (#565)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-01-16 13:04:07 -08:00
committed by GitHub
parent 83b3ddebce
commit 414affedd0
2 changed files with 25 additions and 17 deletions

View File

@@ -529,15 +529,19 @@ export async function handleHeadlessCommand(
}
// Save session (agent + conversation) to both project and global settings
await settingsManager.loadLocalProjectSettings();
settingsManager.setLocalLastSession(
{ agentId: agent.id, conversationId },
process.cwd(),
);
settingsManager.setGlobalLastSession({
agentId: agent.id,
conversationId,
});
// Skip for subagents - they shouldn't pollute the LRU settings
const isSubagent = process.env.LETTA_CODE_AGENT_ROLE === "subagent";
if (!isSubagent) {
await settingsManager.loadLocalProjectSettings();
settingsManager.setLocalLastSession(
{ agentId: agent.id, conversationId },
process.cwd(),
);
settingsManager.setGlobalLastSession({
agentId: agent.id,
conversationId,
});
}
// Ensure the agent has the required skills blocks (for backwards compatibility)
const createdBlocks = await ensureSkillsBlocks(agent.id);

View File

@@ -1458,14 +1458,18 @@ async function main(): Promise<void> {
}
// Save the session (agent + conversation) to settings
settingsManager.setLocalLastSession(
{ agentId: agent.id, conversationId: conversationIdToUse },
process.cwd(),
);
settingsManager.setGlobalLastSession({
agentId: agent.id,
conversationId: conversationIdToUse,
});
// 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 },
process.cwd(),
);
settingsManager.setGlobalLastSession({
agentId: agent.id,
conversationId: conversationIdToUse,
});
}
setAgentId(agent.id);
setAgentState(agent);