Fix: Save baseUrl when storing agent ID for local server support

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 <noreply@letta.com>
This commit is contained in:
Sarah Wooders
2026-01-28 19:52:19 -08:00
parent c6523d640b
commit 685b97c8e3

View File

@@ -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;
}