Loops
A loop runs an agent or a whole factory on its own. Use one for work you repeat, such as a nightly code review or a check on new issues. A loop stays quiet unless something needs you. This page shows you how to set one up, control when it runs, and keep its cost down.
Repeat something you ran
Liked what a thread or factory did? Make it a loop:
- In the thread or run, click Repeat… (in More actions on a thread, next to Phone on a factory run), or
- on the Loops page, choose it under Or repeat something you ran.
The loop form opens already filled in with exactly what that thread or run had: every message you sent, in order (with the agent's replies between them, so later corrections make sense), the files you attached, the agent, model, effort, mode and context, its skills & MCP, the factory's stages and guardrails, and the project. A note at the top lists anything that couldn't be carried over. Choose when it runs, then Create loop. Each run does the work afresh; it doesn't reuse the old result.
Create a loop
Open Loops and press + New loop, or start from a template: Nightly code review, Webhook triage, Weekly dependency check or Continuous watcher. The form has six parts:
- What should it do? Describe the job in plain words. Keep it to one job. Pick the project, or none.
- Who does it. One agent, or the factory from New factory. Saved templates work too.
- When. See When a loop runs.
- Only run when… A check that can skip the run. See The check.
- Spend limits. See Spend limits.
- Credentials. See Keys for a loop.
Then press Create loop. Loops on a server keep running while your computer is off. See Your server.
When a loop runs
| Trigger | What happens |
|---|---|
| On a schedule | Runs on a cron schedule in a time zone. The time zone starts as your computer's. Presets include Every night at 02:00 and Weekdays at 09:00. |
| Every N minutes | Runs at a fixed interval. |
| On a webhook | Runs when a request arrives at the loop's secret URL. |
| Continuously | Runs again a set number of minutes after each run ends. |
| Only when I run it | Runs only when you press Run now. |
A loop never runs twice at once. Pause stops scheduled and webhook runs until you press Resume.
Webhooks
The form shows the URL with a Copy button. Send any POST to it, for example a GitHub webhook. Threadrun redacts secrets from the body, keeps its first 16,000 characters, and gives it to the agents as the trigger payload. Keep the URL secret: the server stores only a hash of its key.
Continuous loops
A continuous loop waits its cooldown after each run. In a continuous loop, the agent can call schedule_next to choose when the next run happens, from 5 minutes to 7 days later. Use a short wait while work is in progress and a long one when all is quiet.
The check
A check runs first, in the same sandbox, with no AI. A run that has nothing to do costs nothing.
- Always. Every trigger starts the agents.
- The repo changed. Skips the run when nothing was pushed since the last run.
- A check script says so. Your script runs in the repo checkout. Empty output, or a last line of
{"wakeAgent": false}, skips the run. Its output is otherwise given to the agents as Check output. Tick Also skip when the output is the same as last time to skip repeats too.
Skipped runs show as Skipped with the note "free". A check that runs longer than five minutes fails the run. Run now ignores the check, but not the spend limits.
Spend limits
Limits are enforced by Threadrun, not by the agents.
- Per run (USD), default $1. When it is reached, every agent in that run stops.
- Per day (USD), default $5. Counts the last 24 hours. A new run does not start once the day's spend has reached it.
- Runs per day, default 24. Counts the last 24 hours. 0 means no cap.
Skipped runs do not count toward the day's spend or runs. The limits apply to every run, including Run now.
What the outcome means
| Badge | Meaning |
|---|---|
| ✓ All good | The run finished, and nothing needs you. |
| Needs you | An agent flagged something, or ended without reporting. The run appears in the Needs your attention banner until you open it or press Dismiss. |
| Failed | The run stopped with an error, such as the per-run budget being reached. |
| Skipped | The check or a cap held the run back. It cost nothing. |
Agents are asked to keep their report to one or two lines, so you can scan the history quickly.
Keys for a loop
Only the keys you tick go to this loop's sandboxes. Other saved keys stay out of its sandboxes. Keys are encrypted on the server, so the loop can run while your computer is off. The app does not show stored key values again when you edit a loop.
Manage a loop
Each loop card shows its next run, runs and skips this week, its cost this week, which agents it uses, and a cost vs earlier runs badge. Recent runs are listed below. Open one to see its review.
- Run now starts a run immediately.
- Pause or Resume turns scheduled runs off or on.
- Edit changes the loop.
- Delete removes the loop, all its runs, their sandboxes and their history. It asks you to confirm. Viewers cannot delete.
Review each run and make it cheaper
Every run ends with a Run review, as factory runs do. See Review the run. Tick the proposals you want, then press Apply to the loop's next run. The next run uses the new setup, and its review compares cost and outcome with the run before. If the result got worse, the review offers a Revert for each change. Every approval is logged with who made it.