From 685b97c8e356669f8af44192ce179ee5fa3f4730 Mon Sep 17 00:00:00 2001 From: Sarah Wooders Date: Wed, 28 Jan 2026 19:52:19 -0800 Subject: [PATCH] Fix: Save baseUrl when storing agent ID for local server support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a new agent is created, we now save the server URL (baseUrl) along with the agent ID using store.setAgent(). This ensures proper server mismatch detection when switching between local and cloud Letta servers. 🤖 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta --- src/core/bot.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/bot.ts b/src/core/bot.ts index 67bed3b..5098dc0 100644 --- a/src/core/bot.ts +++ b/src/core/bot.ts @@ -240,8 +240,10 @@ export class LettaBot { // Save agent ID and attach ignore tool (only on first message) if (session.agentId && session.agentId !== this.store.agentId) { const isNewAgent = !this.store.agentId; - this.store.agentId = session.agentId; - console.log('Saved agent ID:', session.agentId); + // Save agent ID along with the current server URL + const currentBaseUrl = process.env.LETTA_BASE_URL || 'https://api.letta.com'; + this.store.setAgent(session.agentId, currentBaseUrl); + console.log('Saved agent ID:', session.agentId, 'on server:', currentBaseUrl); // Setup new agents: set name, install skills if (isNewAgent) { @@ -327,8 +329,9 @@ export class LettaBot { } if (msg.type === 'result') { - if (session.agentId) { - this.store.agentId = session.agentId; + if (session.agentId && session.agentId !== this.store.agentId) { + const currentBaseUrl = process.env.LETTA_BASE_URL || 'https://api.letta.com'; + this.store.setAgent(session.agentId, currentBaseUrl); } break; }