How to run and schedule an AI agent that works unattended in production
To run an AI agent unattended you need four things a chat window gives you for free. A trigger that fires when nobody is typing. A record of what each run did. A way to find out that a run failed. A number for what the run cost. The model is the smallest item on that list. This page takes the four in order and shows how each one works on OBTO, including the parts OBTO leaves to you.
1. The trigger: a scheduled job
Three places can hold the schedule.
- Your own machine or server. A cron entry or a task scheduler starts a script that calls the model and the tools. Simple, and it stops when the laptop closes.
- The AI client. Claude and Claude Code both run scheduled tasks, so the agent you use by hand can run at 6 a.m. with the same MCP connections. This is the fastest way to start.
- The platform the agent works in. The job runs next to the data, with no laptop and no client session involved.
On OBTO the third option is a scheduled job record. It holds a cron expression or an interval such as every 5 minutes, a timezone, and the script to run. The platform scheduler runs it on worker pods, so the job runs whether or not anyone is signed in. A new job is created switched off and is turned on in a separate step, after someone has read it. Today the OBTO team sets up and activates these jobs on request; the self-serve tool for them is limited to platform operators. Most teams begin with the second option, a scheduled task in their client that calls OBTO's MCP tools or API routes, and move the schedule onto the platform once the job has settled.
2. What the job is allowed to do
Unattended runs repeat, overlap and fail halfway. Anything that is unsafe to do twice becomes a hazard, so split the work by how hard it is to undo. Drafting, tagging, moving rows into a holding table and opening a proposal can run at night with nobody around. Refunds, deletes, customer emails and payments go on a queue a person clears in the morning. The agent gets most of its work done, and the few actions that are expensive to get wrong still wait for a human.
Give the job one default for doubt. When a precondition fails or confidence is low, it writes up what it found and what it would have done, then stops. A report you read over coffee costs less than a wrong action you reverse at noon.
Writes should be safe to repeat. On OBTO an agent can name each write with an idempotency key. A retry that carries the same key gets the stored receipt back instead of writing again, so a timed-out call that did land is never applied twice. An edit can also carry the hash of the text the agent last read; if the stored text has changed since, the edit is refused and nothing is written. Both checks run on the server, when the agent supplies the key or the hash. The write that knows it already ran covers the design.
3. The receipt: where each run lands
An unattended run is only as good as the record it leaves. On OBTO three records exist by default.
- A job-run row. Each run of a scheduled job writes a row with its start, finish and outcome. The job itself carries the time of its last run, its next run, and a failure count with the last failure reason.
- Usage rows. Every API route call and every MCP tool call rolls into a daily row per app and per tool: how many calls, how many milliseconds the handlers took, how many errors. The
obto_usagetool reads them for a day or a date range. - Write receipts. Each save returns the hash of what is now stored and the hash of what was there before, so the morning review can tell exactly what changed.
Output printed inside a job script is not kept. If you want a line in the record, write a row or throw an error.
4. How you find out it failed
An error thrown inside an OBTO scheduled job is logged under the job's name, and the job's failure count goes up with the reason attached. Read the app logs with the jobs flag set and you get the scheduler's view of every job in the app: last run, last finish, next run, failures. OBTO does not send you a page or an email when a job fails today. The reading is on you, or on an agent you point at it. Two habits make that workable. Pick a cadence you will look at, since a daily job you read beats an hourly one you ignore. And make the job loud on failure: throw rather than swallow, so the count moves.
A run that hangs is the worst case, because it neither finishes nor throws. Keep each run short, make its steps independent, and let the scheduler's own completion fallback close a run that forgot to.
5. What a run costs
OBTO bills a flat price per deployed application and does not meter tokens or requests. The model spend stays on your own API key or your AI client's subscription. So the cost of an unattended run on OBTO is the model provider's charge for that run, plus nothing from OBTO per run. The usage rows give you the volume side, calls per day and handler time per tool, which is what you need to notice a job that started calling ten times more often than it should. Turning that into a per-run number is the subject of know your AI cost per run.
If the agent has to run inside your network
"Self-hosted AI agents" means one of three things: the agent and its data stay in your network, you control the upgrades, or you can leave with your work. OBTO is a managed cloud by default and offers the first two on the Enterprise plan: bring your own models, and self-hosting by separate agreement. There is no binary to download and run on the standard plans. The third promise holds on every plan, because an OBTO app is a set of records you can query and export. The self-hosted agent platforms guide compares the open-source frameworks, the batteries-included platforms and the managed options on those three promises.
A checklist before the first unattended night
- The schedule lives somewhere that stays up without you.
- The job can only reach the tools it needs, and the irreversible ones are off its list.
- Every write is idempotent or guarded by the hash of what the agent read.
- You know which row to open in the morning, and what a healthy one looks like.
- A failure raises a count you check, and the job throws rather than prints.
- You know the run's model cost and its call volume for one normal day.