SabaKore

Home / Articles / AI guides

What to Think About When Running an AI Agent 24 Hours a Day

Design for keeping something running when you can't fully predict what it will do next. It covers how to narrow its permissions, how to put a brake on runaway costs, and why you should decide how to stop it before you start it.

Ren, a junior infrastructure engineer

Ren

I want to keep an agent running on a server, where the AI decides things and does the work by itself!
Procura, a cloud AI robot who explains

Procura

That's an interesting use. Things like collecting and summarizing information regularly, or sending a notification when a condition is met, are actually built quite often.
Procura, a cloud AI robot who explains

Procura

But there's one decisive difference from an ordinary program: you can't fully predict what it will do next until you run it. If you don't design with that assumption, it's dangerous.

What to prepare

  • Set limits on the number of runs and the run time, and stop when they're exceeded
  • Narrow what it can do. Don't easily allow things like "delete files" or "send email"
  • Limit where it can connect to outside to what's necessary
  • Put human approval before important operations
  • Always log what it did. If you can't trace it afterward, you can't find the cause
Ren, a junior infrastructure engineer

Ren

If I narrow the permissions too much, it won't be useful anymore...
Procura, a cloud AI robot who explains

Procura

Right, it's a balance. I recommend "broad permission to read, narrow permission to write". Let it freely gather information and make judgments, and have a person step in at the stage where something is actually changed. That makes it easier to balance convenience and safety.

Watch out for runaway costs too

Procura, a cloud AI robot who explains

Procura

Running autonomously also means calling APIs on its own, over and over. It really does happen that it keeps retrying a process that isn't working and only the cost piles up.
Wilson, the security guard

Wilson

...And don't forget that I can plant instructions where the agent goes to read. The more autonomous something is, the more it tends to execute text it picked up from outside without suspicion.
Procura, a cloud AI robot who explains

Procura

That's why narrowing permissions is itself the countermeasure. Even if it's fooled by something it reads, if there's little it can do, the damage is small. Start small and widen it while you watch how it goes.

Decide how to stop it first

Something that runs autonomously also keeps going autonomously when it does something unexpected. You need a means to stop it right away when you notice something wrong. Killing the process, disabling the API key, cutting the network. Decide which you'll use before you start running it. If you look for it after it starts moving, you won't make it in time.

Procura, a cloud AI robot who explains

Procura

If you run it 24 hours a day, prepare how to stop it before how to run it. If you think about it only after things go wrong, it keeps running that whole time.
  • A mechanism to stop it immediately by hand (a state where one setting stops it)
  • Set a time limit on a single run. Cut it off when exceeded
  • A cap on runs per day. If exceeded, don't run it until the next day
  • Make it stop automatically after consecutive failures
  • A notification so you can tell that it stopped

The VPS as the place to run it

Procura, a cloud AI robot who explains

Procura

Since an agent is meant to run permanently, a fixed monthly price is easier to read than hourly billing. As for specs, if you leave judgment and heavy generation to an API, even a small plan works.
  • Use a process manager to restart it automatically if it goes down
  • But set a limit on the number of restarts so it doesn't restart forever
  • Keep the log of what it did outside the server as well
  • Narrow the permissions of the user it runs as. Don't run it as root
Ren, a junior infrastructure engineer

Ren

Broad to read, narrow to write. Prepare how to stop it first. I'll start small.

This article is translated from the Japanese original. If the two differ, the Japanese version is the one we keep up to date.