fix: save agent ID after first interaction

Agent ID is only available after initialization (first message sent),
so move the save logic to after the interaction completes.

🤖 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta <noreply@letta.com>
This commit is contained in:
Cameron Pfiffer
2026-01-27 16:19:20 -08:00
parent aa6149c191
commit 7ea9c03137
4 changed files with 29 additions and 21 deletions

View File

@@ -66,17 +66,17 @@ async function main() {
// Get or create the agent
const agent = await getOrCreateAgent(state);
// Save agent ID if new
await generateReleaseNotes(agent, state, fromRef, toRef, values.output);
// Save agent ID after first interaction (when it becomes available)
if (!state.agentId && agent.agentId) {
state.agentId = agent.agentId;
await saveState(state);
console.log(`\x1b[90m[Agent: ${agent.agentId}]\x1b[0m`);
console.log(`\x1b[90m[Agent saved: ${agent.agentId}]\x1b[0m`);
console.log(`\x1b[90m[→ https://app.letta.com/agents/${agent.agentId}]\x1b[0m\n`);
}
await generateReleaseNotes(agent, state, fromRef, toRef, values.output);
agent.close();
}