// End successfully with defaultawait lai.endSession();// End successfully with reasonawait lai.endSession(true, "All tasks completed");// End with failureawait lai.endSession(false, "API rate limit exceeded");
When autoEnd is enabled (default), sessions automatically end on:
Process exit
Uncaught exceptions
SIGINT/SIGTERM signals
Copy
Ask AI
// Auto-end enabled by defaultawait lai.init({ sessionName: "My session" });// Session will auto-end on exit - no need to call endSession()process.exit(0);
// ✅ Good - specific and actionableawait lai.endSession(false, "Database connection failed after 3 retries: timeout");// ❌ Less helpfulawait lai.endSession(false, "Error occurred");
// Partial success is still successconst processed = 95;const total = 100;await lai.endSession( true, // Still successful `Processed ${processed}/${total} items, ${total - processed} skipped due to validation`);