agentport

Guide · Grok Build

Keep Grok Build running after you close your laptop

You start a long Grok Build task, close the lid, and come back to a frozen terminal. This guide explains why that happens, what tmux does and does not fix, and two setups that keep the agent working while you are away.

The short answer

Run Grok Build on a computer that does not sleep: a desktop, a mini PC, a home server or a small VPS. Your laptop then becomes a window into that machine instead of the place where the agent lives. Closing it, losing Wi-Fi or switching to your phone no longer stops the task.

Why closing the lid stops the agent

What tmux fixes, and what it does not

tmux keeps a terminal session alive when your SSH connection drops or you close the terminal window, because a background server owns the session. That is exactly the right tool for a flaky connection. It does not help if tmux is running on the laptop itself: when the laptop sleeps, tmux sleeps with it. tmux only solves the closed-lid problem when it runs on another machine that stays on.

Option 1: SSH and tmux on a server

This is the do-it-yourself setup and needs nothing beyond a Linux server and a terminal.

  1. Install Grok Build on the server with xAI's installer, then sign in without a browser on that machine:
    grok login --device-auth
    It prints a link and a code. Open the link on any device, enter the code, and the server is signed in.
  2. Start Grok Build inside a named tmux session in your project folder:
    tmux new -s grok
    grok
  3. Detach with Ctrl-b then d. Close the laptop. The task keeps running on the server.
  4. Later, from any computer, reattach:
    ssh you@your-server -t tmux attach -t grok

It works, but you live in a terminal: copy and paste through SSH can be fiddly, reviewing diffs means more commands, and using it from a phone means an SSH app and a tiny keyboard. You also keep SSH open to the internet, so use key-only logins.

Option 2: AgentPort, Grok Build in your browser

AgentPort runs Grok Build on your own computer or VPS inside a Docker container and gives you a chat for it in any browser. The agent's session lives on the server, so closing the laptop does nothing to it.

  1. Sign in to AgentPort, click Add machine, and copy the one-line install command.
  2. Paste it on the server (it needs Docker). It opens a secure outbound link, so you do not open any ports.
  3. In the computer's settings, go to AI Model and sign in to Grok with the same short-code flow.
  4. Start a chat, give Grok the task and close the laptop. Open AgentPort later on any device and the chat shows everything the agent did.

Compared with tmux, you get chat history that survives reloads and device switches, approval cards you can tap from a phone, several chats at once grouped by project, and a Changed tab with a diff per file. Step-by-step setup: Run Grok Build on your VPS.

Which machine should run it?

Running unattended safely

FAQ

Does Grok Build keep running if my SSH connection drops?

Only if it runs inside tmux or screen on the server. Without them, the session ends with the connection. With AgentPort, the agent runs in the server's container and does not depend on your browser staying connected.

Can I check on Grok Build from my phone?

Yes. With tmux you need an SSH app. With AgentPort you open the site in your phone's browser; see Use an AI coding agent from your phone.

Does AgentPort see my code?

No. Your browser connects straight to your server. AgentPort's cloud handles sign-in and the list of your computers.

Try it on your own computer

The Free plan covers 1 computer. Pro is $27/month for up to 3. You bring the AI login and pay that provider directly.