a tool to help your Letta AI agents navigate bluesky

Adjust task intervals and retry delays

+6 -6
main.ts
··· 8 8 import { checkBluesky } from "./tasks/checkBluesky.ts"; 9 9 import { checkNotifications } from "./tasks/checkNotifications.ts"; 10 10 11 - setTimeout(logStats, msRandomOffset(msFrom.minutes(1), msFrom.minutes(5))); 11 + setTimeout(logStats, msFrom.minutes(30)); 12 12 13 13 setTimeout( 14 14 logTasks, 15 - msRandomOffset(msFrom.minutes(30), msFrom.minutes(60)), 15 + msFrom.minutes(100), 16 16 ); 17 17 setTimeout( 18 18 sendSleepMessage, 19 - msUntilDailyWindow(agentContext.sleepTime, 0, msFrom.minutes(20)), 19 + msUntilDailyWindow(agentContext.sleepTime, 0, msFrom.minutes(30)), 20 20 ); 21 21 setTimeout( 22 22 sendWakeMessage, 23 - msUntilDailyWindow(agentContext.wakeTime, 0, msFrom.minutes(80)), 23 + msUntilDailyWindow(agentContext.wakeTime, 0, msFrom.minutes(30)), 24 24 ); 25 25 setTimeout( 26 26 runReflection, 27 - msRandomOffset(msFrom.minutes(180), msFrom.minutes(240)), 27 + msRandomOffset(msFrom.minutes(120), msFrom.minutes(240)), 28 28 ); 29 29 setTimeout( 30 30 checkBluesky, 31 - msRandomOffset(msFrom.minutes(10), msFrom.minutes(90)), 31 + msRandomOffset(msFrom.minutes(45), msFrom.minutes(90)), 32 32 ); 33 33 await checkNotifications();
+2 -2
tasks/checkBluesky.ts
··· 13 13 14 14 export const checkBluesky = async () => { 15 15 if (!claimTaskThread()) { 16 - const newDelay = msRandomOffset(msFrom.minutes(5), msFrom.minutes(10)); 16 + const newDelay = msFrom.minutes(2); 17 17 18 18 console.log( 19 19 `🔹 ${agentContext.agentBskyName} is busy, will try checking bluesky again in ${ 20 20 newDelay * 60 * 1000 21 21 } minutes…`, 22 22 ); 23 - // agentContext is busy, try to check notifications in 5~10 minutes. 23 + // agentContext is busy, try to check notifications in 2 minutes. 24 24 setTimeout(checkBluesky, newDelay); 25 25 return; 26 26 }
+4 -4
tasks/checkNotifications.ts
··· 13 13 14 14 export const checkNotifications = async () => { 15 15 if (!claimTaskThread()) { 16 - const newDelay = msRandomOffset(msFrom.minutes(5), msFrom.minutes(10)); 16 + const newDelay = msFrom.minutes(2); 17 17 console.log( 18 18 `🔹 ${agentContext.agentBskyName} is busy, checking for notifications again in ${ 19 19 (newDelay * 1000) * 60 20 20 } minutes…`, 21 21 ); 22 - // agentContext is busy, try to check notifications in 5~10 minutes. 22 + // agentContext is busy, try to check notifications in 2 minutes. 23 23 setTimeout(checkNotifications, newDelay); 24 24 return; 25 25 } 26 26 27 27 const delay = msUntilNextWakeWindow( 28 - 0, 29 - msFrom.minutes(90), 28 + msFrom.minutes(30), 29 + msFrom.minutes(45), 30 30 ); 31 31 32 32 if (delay !== 0) {
+1 -4
tasks/logStats.ts
··· 46 46 agentContext.replyCount + 47 47 agentContext.followCount; 48 48 49 - const nextCheckDelay = msRandomOffset( 50 - msFrom.minutes(5), 51 - msFrom.minutes(15), 52 - ); 49 + const nextCheckDelay = msFrom.minutes(5); 53 50 const nextCheckMinutes = ((nextCheckDelay / 1000) / 60).toFixed(1); 54 51 55 52 if (totalNotifications <= 0) {
+1 -4
tasks/logTasks.ts
··· 50 50 const uptime = Date.now() - serverStartTime; 51 51 const uptimeFormatted = formatUptime(uptime); 52 52 53 - const nextCheckDelay = msRandomOffset( 54 - msFrom.minutes(30), 55 - msFrom.hours(1), 56 - ); 53 + const nextCheckDelay = msFrom.minutes(30); 57 54 const nextCheckMinutes = ((nextCheckDelay / 1000) / 60).toFixed(1); 58 55 59 56 if (totalActivity <= 0) {
+4 -4
tasks/runReflection.ts
··· 14 14 15 15 export const runReflection = async () => { 16 16 if (!claimTaskThread()) { 17 - const newDelay = msRandomOffset(msFrom.minutes(5), msFrom.minutes(10)); 17 + const newDelay = msFrom.minutes(2); 18 18 19 19 console.log( 20 20 `🔹 ${agentContext.agentBskyName} is busy, will try reflecting again in ${ 21 21 (newDelay / 1000) / 60 22 22 } minutes…`, 23 23 ); 24 - // session is busy, try to start reflection in 5~10 minutes. 24 + // session is busy, try to start reflection in 2 minutes. 25 25 setTimeout(runReflection, newDelay); 26 26 return; 27 27 } ··· 34 34 return; 35 35 } 36 36 37 - // adds 1-2 hours to wake time 37 + // adds 2-4 hours to wake time 38 38 // only applies if sleep is enabled 39 39 const delay = msUntilNextWakeWindow( 40 - msFrom.hours(1), 41 40 msFrom.hours(2), 41 + msFrom.hours(4), 42 42 ); 43 43 44 44 if (delay !== 0) {
+4 -4
tasks/sendSleepMessage.ts
··· 14 14 15 15 export const sendSleepMessage = async () => { 16 16 if (!claimTaskThread()) { 17 - const newDelay = msRandomOffset(msFrom.minutes(5), msFrom.minutes(10)); 17 + const newDelay = msFrom.minutes(2); 18 18 console.log( 19 19 `🔹 ${agentContext.agentBskyName} is busy, sending sleep message again in ${ 20 20 (newDelay / 1000) / 60 21 21 } minutes…`, 22 22 ); 23 - // session is busy, try to check notifications in 5~10 minutes. 23 + // session is busy, try to check notifications in 2 minutes. 24 24 setTimeout(sendSleepMessage, newDelay); 25 25 return; 26 26 } ··· 41 41 const delay = msUntilDailyWindow( 42 42 agentContext.sleepTime, 43 43 0, 44 - msFrom.minutes(20), 44 + msFrom.minutes(30), 45 45 ); 46 46 setTimeout(sendSleepMessage, delay); 47 47 console.log( ··· 61 61 console.log("🔹 wind down attempt processed, scheduling next wind down…"); 62 62 setTimeout( 63 63 sendSleepMessage, 64 - msUntilDailyWindow(agentContext.sleepTime, 0, msFrom.minutes(20)), 64 + msUntilDailyWindow(agentContext.sleepTime, 0, msFrom.minutes(30)), 65 65 ); 66 66 console.log("exiting wind down process"); 67 67 releaseTaskThread();
+4 -4
tasks/sendWakeMessage.ts
··· 10 10 11 11 export const sendWakeMessage = async () => { 12 12 if (!claimTaskThread()) { 13 - const newDelay = msRandomOffset(msFrom.minutes(5), msFrom.minutes(10)); 13 + const newDelay = msFrom.minutes(2); 14 14 console.log( 15 15 `🔹 ${agentContext.agentBskyName} is busy, sending wake message again in ${ 16 16 (newDelay / 1000) / 60 17 17 } minutes…`, 18 18 ); 19 - // session is busy, try to check notifications in 5~10 minutes. 19 + // session is busy, try to check notifications in 2 minutes. 20 20 setTimeout(sendWakeMessage, newDelay); 21 21 return; 22 22 } ··· 37 37 const delay = msUntilDailyWindow( 38 38 agentContext.wakeTime, 39 39 0, 40 - msFrom.minutes(80), 40 + msFrom.minutes(30), 41 41 ); 42 42 setTimeout(sendWakeMessage, delay); 43 43 console.log( ··· 57 57 console.log("🔹 wake attempt processed, scheduling next wake prompt…"); 58 58 setTimeout( 59 59 sendWakeMessage, 60 - msUntilDailyWindow(agentContext.wakeTime, 0, msFrom.minutes(80)), 60 + msUntilDailyWindow(agentContext.wakeTime, 0, msFrom.minutes(30)), 61 61 ); 62 62 console.log("🔹 exiting wake process"); 63 63 releaseTaskThread();