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