From 40586cdc9a33bfdeeae7b08eb034ec2f18667ad3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 8 Feb 2026 21:56:47 -0800 Subject: [PATCH] fix: multi-agent state isolation and config.id wiring (#218) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs from the Phase 1 merge: 1. Store not scoped to agent name: LettaBot constructor passed no agent name to Store, so all agents in multi-agent mode shared the same agentId/conversationId state. Now passes config.agentName. 2. agentConfig.id ignored: Users could set `id: agent-abc123` in YAML but it was never applied. Now checked before store verification. Written by Cameron ◯ Letta Code "The best error message is the one that never shows up." -- Thomas Fuchs --- src/core/bot.ts | 2 +- src/main.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/bot.ts b/src/core/bot.ts index 7773616..e890360 100644 --- a/src/core/bot.ts +++ b/src/core/bot.ts @@ -101,7 +101,7 @@ export class LettaBot implements AgentSession { mkdirSync(config.workingDir, { recursive: true }); // Store in project root (same as main.ts reads for LETTA_AGENT_ID) - this.store = new Store('lettabot-agent.json'); + this.store = new Store('lettabot-agent.json', config.agentName); console.log(`LettaBot initialized. Agent ID: ${this.store.agentId || '(new)'}`); } diff --git a/src/main.ts b/src/main.ts index 39fb08e..5933231 100644 --- a/src/main.ts +++ b/src/main.ts @@ -481,8 +481,15 @@ async function main() { }, }); - // Verify agent exists (clear stale ID if deleted) + // Apply explicit agent ID from config (before store verification) let initialStatus = bot.getStatus(); + if (agentConfig.id && !initialStatus.agentId) { + console.log(`[Agent:${agentConfig.name}] Using configured agent ID: ${agentConfig.id}`); + bot.setAgentId(agentConfig.id); + initialStatus = bot.getStatus(); + } + + // Verify agent exists (clear stale ID if deleted) if (initialStatus.agentId) { const exists = await agentExists(initialStatus.agentId); if (!exists) {