this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(bot): sync tools at startup, not lazily

Call getOrCreateAgent() during startup to ensure tools are synced
with correct webhook URLs before any messages arrive.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

alice f9ae636c 0df52506

+9 -2
+1 -1
src/bot.ts
··· 76 76 * 77 77 * @returns Agent ID 78 78 */ 79 - async function getOrCreateAgent(): Promise<string> { 79 + export async function getOrCreateAgent(): Promise<string> { 80 80 if (agentId !== null) { 81 81 return agentId; 82 82 }
+8 -1
src/index.ts
··· 12 12 import { config, isWebhookMode } from './config'; 13 13 import { healthCheck, simpleHealthCheck } from './health'; 14 14 import { initializeLetta } from './letta'; 15 - import { handleUpdate, startPolling, registerWebhook, registerCommands } from './bot'; 15 + import { handleUpdate, startPolling, registerWebhook, registerCommands, getOrCreateAgent } from './bot'; 16 16 import { dispatchTool } from './tools'; 17 17 import type { Update } from 'telegraf/types'; 18 18 ··· 28 28 } catch (error) { 29 29 console.error('Failed to initialize Letta:', error); 30 30 console.error('Server will start, but bot functionality may be limited.'); 31 + } 32 + 33 + // Initialize agent (syncs tools with correct webhook URLs) 34 + try { 35 + await getOrCreateAgent(); 36 + } catch (error) { 37 + console.error('Failed to initialize agent:', error); 31 38 } 32 39 33 40 // Register bot commands with Telegram (sets the command menu)