This repository has no description
0

Configure Feed

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

Reuse island-analyzer agent across runs

Store agent ID in SQLite config table. First run creates the agent,
subsequent runs reuse it — no more creating a new agent each time.

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

Co-Authored-By: Letta Code <noreply@letta.com>

author
nandi
co-author
Letta Code
date (May 15, 2026, 6:32 AM UTC) commit 583b5964 parent ccebf5c6
+30 -14
+30 -14
src/island-analyze.ts
··· 64 64 new_connections TEXT, 65 65 analyzed_at TEXT NOT NULL 66 66 ); 67 + CREATE TABLE IF NOT EXISTS config ( 68 + key TEXT PRIMARY KEY, 69 + value TEXT NOT NULL 70 + ); 67 71 `); 68 72 return db; 69 73 } ··· 278 282 279 283 console.error(`Analyzing ${targets.length} island(s)...`); 280 284 281 - // Create agent 282 - const agentId = await createAgent({ 283 - model, 284 - persona: `You are a research analyst that synthesizes connected components (islands) from a knowledge graph into structured analysis records. 285 + // Reuse existing agent or create one 286 + const sessionOpts: Record<string, unknown> = { 287 + tools: [islandSaveTool], 288 + permissionMode: 'bypassPermissions' as const, 289 + }; 290 + if (model) sessionOpts.model = model; 291 + 292 + let agentId: string; 293 + const savedAgentId = (db.query('SELECT value FROM config WHERE key = ?').get('island_analyzer_agent_id') as { value: string } | null)?.value; 294 + 295 + if (savedAgentId) { 296 + agentId = savedAgentId; 297 + console.error(`Reusing agent: ${agentId}`); 298 + } else { 299 + agentId = await createAgent({ 300 + persona: `You are a research analyst that synthesizes connected components (islands) from a knowledge graph into structured analysis records. 285 301 286 302 Given an island — a cluster of URLs connected by semantic edges — you MUST call the island_save tool with your analysis. Do NOT just write text — you MUST use the island_save tool call. 287 303 ··· 295 311 - newConnections: suggested new edges between vertices 296 312 297 313 CRITICAL: You MUST call island_save. Do not just describe your analysis in text. Call the tool.`, 298 - human: 'island-analyzer', 299 - tools: [islandSaveTool], 300 - permissionMode: 'bypassPermissions', 301 - memfs: false, 302 - systemInfoReminder: false, 303 - }); 304 - 305 - console.error(`Created agent: ${agentId}`); 314 + human: 'island-analyzer', 315 + tools: [islandSaveTool], 316 + permissionMode: 'bypassPermissions', 317 + memfs: false, 318 + systemInfoReminder: false, 319 + }); 320 + db.query('INSERT INTO config (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value').run('island_analyzer_agent_id', agentId); 321 + console.error(`Created agent: ${agentId}`); 322 + } 306 323 307 324 const session = createSession(agentId, { 308 325 memfsStartup: 'skip', 309 - tools: [islandSaveTool], 310 - permissionMode: 'bypassPermissions', 326 + ...sessionOpts, 311 327 }); 312 328 313 329 await session.initialize();