← All guides

Agents that run code, not a prompt

Not every recurring job needs judgment. Checking a feed, skipping the items already handled, tidying up threads that have gone quiet for a week — that work is the same every time, and asking a model to reason it out again on every check-in is slower, costlier and less predictable than simply writing down what you want done.

So an Agent can be set to run a script instead of a prompt. It runs a small piece of JavaScript once per interval, and that run is the whole tick — no model is spawned behind it. It fires even in a workspace with no threads at all, which makes it the natural home for the "go and look" half of a loop.

A script reaches the rest of Frontier, and anything else it is given, through the tools you grant it and nothing else — see What a script is allowed to touch. Whatever it prints becomes that run's log, kept line by line as it goes, so a run that is cut off still shows what it had already done. When it hits something it genuinely can't work out in code — is this in our lane, is this worth writing up — it can ask a model that one question and carry on with the answer, which keeps the thinking to the one place that actually needs it.

Two things turn a script from a chore into a loop worth keeping: it can remember what it already handled between runs, and it can hold a lock on anything only one agent should touch at a time. Build an agent that runs on a script builds one end to end.