Sometimes you need to run a lengthy process on a server using AI. For example, I need to reindex memory of my AI assistant and it will take about 2-3 hours. The indexing process is written by AI too, and the process outputs progress data. Since the server does not have the most modern processor, indexing takes a lot of time. All this time, AI will monitor it and wait for completion. This burns a lot of tokens and eats a lot of limits.
What can you do?
The process can run in the background. You can give your AI instructions like this:
- Estimate how much time it will take for the process to complete. Keep in mind that AI is bad at evaluating time, so use your common sense too.
- AI will run the process in
tmuxand disconnect. This will leave the process running on the server, but the AI will stop monitoring it. - You will manually trigger AI to check the process progress around the estimated time end. If the process is not ended, quickly calculate when it can finish and trigger again around that time.
This saves a lot of tokens. AIs approve this idea, by the way. It is also good for them because it makes less load on models.
What is tmux?
tmux is a terminal multiplexer that lets you run multiple terminal sessions inside a single window, keep programs running in the background when disconnected, and split your screen into separate panes. It is ideal for remote SSH work and managing complex developer workflows. It usually comes as a package for all modern Linux and macOS systems. If it is not installed on your server, you can install it following typical steps like apt-get install tmux (this is for Debian-based systems).
If there is no tmux and you cannot install it, there is an older similar software called screen. It is usually installed by default and AIs can use it as well.