Skip to content

Loops

A loop runs a task again in the same session: every few minutes, at set times of day, once at a time you name, or whenever the agent decides the next check is due. Ask for one in plain words, or type /loop in the chat. Each run picks the task up with everything the session already knows, and a bar above the chat shows the loop and when it runs next.

Loops are off by default. An instance administrator turns them on for an organization with PATCH /api/v1/admin/organizations/{id} and {"features": {"session_loops": true}}. They work in sessions where an agent works; a session that only plans has none.

Starting a loop

Ask the agent

Say what to repeat and when, in your own words:

  • "Check the deploy every 10 minutes and tell me when it's live."
  • "At 5pm, summarize today's open pull requests."
  • "Every weekday at 9:00, post the overnight error count."
  • "Keep an eye on the import until it finishes."

The agent starts the loop and tells you its schedule. Its first repeat comes one interval later, since the agent usually does the first check in the same reply. With no schedule ("keep an eye on …"), the agent picks the time of each next run itself.

Only a person can start a loop: the agent starts one only in a run that a person's message or action began, never in a run that a workflow, another agent or a loop's own run began.

Type /loop

In the web chat, a line that starts with /loop is a command:

You type What happens
/loop 5m <task> The task now, then every 5 minutes. Also 1h, 1 hour 30 minutes, every 5m or hourly.
/loop at 17:00 <task> Once, at the next 17:00. Also 5pm or 5:30 pm.
/loop daily 9am <task> Every day at 9:00.
/loop <task> Now, then at times the agent picks. The task needs three words or more.
/loop stop Stops the loop.
/loop Shows the loop.

While you type a /loop line, a hint above the message box lists the main forms. The answer to a command appears in the same place rather than in the chat, until you Dismiss it or send your next message. If no loop could be started, the answer says why and your line goes back into the message box to fix. When a task itself starts with a command word ("/loop list the open pull requests"), no loop starts, and the answer offers the line that runs it as a loop, with Use this line.

A line with a date, a weekday or another time zone ("/loop every Monday at 8:00 …") goes to the agent as you wrote it, and the agent sets the loop up from your words.

The typed command works in the web chat. In Slack and Telegram, a /loop line reaches the agent as ordinary words; ask in plain words there.

Times and time zones

Clock times are read in your time zone, set under Time zone in your settings. Crios fills it from your browser while it's empty. Loops you start without naming a zone follow yours. After you change it, the run already scheduled keeps its time, and the runs after it use your new zone. A one-time loop keeps its time. For a time in another zone, say so: "at 5pm Tokyo time". With no zone known, times are read in UTC.

The loop bar

While a loop is live, between runs too, a bar above the chat shows:

  • Loop, with its task; open the bar for the full task and its details, such as Ends … at the latest;
  • its schedule, such as Every 5 minutes, Once: … or Self-paced, with the time zone;
  • its runs: Up to 100 runs before the first one, then Run 3 of 100;
  • when the next run starts: Next run in 4 minutes, Running now, Due: starts when the agent finishes, Due: starts in a moment, or Held: waiting for your answer.

Stop loop ends the loop and nothing else: the session, its workspace and its app carry on. People who can only view the project see the bar without it.

Each run in the chat

The chat marks the loop's start (Loop started, or Run scheduled for a single run), puts a divider before each run (Run 3 of 100), and ends with a line that says why the loop stopped, such as Loop stopped by a person or Loop stopped: max runs reached.

Runs in which the agent found nothing new fold into one line, such as 5 quiet runs, nothing new; Show these runs opens them. The latest run never folds, and neither does a run in which the agent asked you something.

When a run waits

A run that comes due never interrupts:

  • While the agent works, it waits until the agent finishes: Due: starts when the agent finishes.
  • Right after you write in the chat, it waits until the chat has been quiet for 30 seconds.
  • While the agent waits for you, with a plan to approve or a question it asked, the run is held until you answer in the session's chat: Held: waiting for your answer.

If the session stays busy past several run times, those runs are skipped rather than run back to back, and the bar counts them. Between runs the session rests in waiting_input, not completed, and a run still starts after the session went idle or paused itself, on a fresh sandbox if its sandbox was released.

Stopping a loop

  • Stop loop in the bar, /loop stop, or asking the agent to stop it.
  • Stop in the session's top bar ends the agent run, shuts the app down and stops the loop as well. While a loop is live, Crios asks first.
  • Pausing the session yourself also stops its loop, whether you ask the agent in the chat, use Slack or go through the API. So does asking the agent to stop or cancel the session, or deleting it.
  • A session has one loop at a time: starting another replaces it.

A loop also ends by itself:

  • when its runs are used up: 100 by default, or the number you asked for, up to 1,000;
  • when its time is up: 7 days after it started by default, or sooner if you asked ("for the next two hours");
  • when what you asked to wait for has happened ("until the deploy is live"): the agent stops it;
  • a loop for one time, after its run; a loop whose times the agent picks, when the agent doesn't schedule another run;
  • when its runs fail 3 times in a row, or keep failing to start;
  • when the session has used 90% of its token budget, the organization 95% of its monthly token budget or cost limit, or the session reaches its spending limit; see Costs & budgets;
  • when the person who started it no longer has access, or loops are turned off for the organization.

Limits

  • By default, an interval is 1 minute to 24 hours, and when the agent picks the times, each run comes 1 minute to 1 hour after the last. A deployment can set a longer minimum.
  • A one-time run can be up to 7 days ahead by default.
  • An organization has at most 10 live loops at a time, unless your deployment sets another number, and a deployment can also limit the live loops of all its organizations together. A start past a limit is refused: No loop was started: the limit on running loops is reached.
  • Starting a loop is refused once the token budget is nearly spent, at the same levels that stop one.