HomeGuides › What is a loop?

Guides · Setting up

What is a “loop”? Recurring agent tasks


A classic agent works toward a goal, then stops. A loop is the floor above: the same task re-run at a regular interval — monitor, check, alert — without you. I'm deploying some at Cobra right now; here's the concept, and the guardrails.

By Hugo Lahutte· ·~4 min read
  • 1 In 30 seconds
  • 2 The body, visual
  • 3 Going further

1. The loop: the floor above the agent

In What is an AI agent, I explained the assistant/agent difference: an assistant answers, an agent acts in a loop until the result is delivered — then stops. The loop adds the time dimension: the whole task is re-run at a regular interval. The agent no longer works once toward a goal; it comes back to check — again and again.

It's the natural pattern for anything monitoring: you never "finish" watching a deployment or an order flow; you look, compare against the expected state, alert if it drifts, and come back later.

The loop: a time-bounded monitoring cycle — not an infinite loop.

2. How it works in Claude Code

Claude Code (the tool I use for all dev work — see Chat, Cowork or Code) ships a /loop command: you give it a prompt and an interval (in seconds, minutes, hours or days), and it re-runs that prompt at every tick, inside your session.

The detail that won me over: the guardrail is built in. A loop automatically expires 3 days after creation — it runs one last time, then deletes itself. A forgotten loop can't run forever or silently burn a budget. It's exactly the kind of framing I called for in the agent guide (goal, budget, frequency, success criterion) — except here, the boundary is set by the tool itself.

3. Loop or scheduled task?

Both re-run a task at a regular interval; everything else differs.

Need under 3 days → loop. Permanent need → scheduled task.

My daily AI watch, for instance, is a scheduled task (it has to run every morning, forever). Watching that an Odoo deployment goes well this afternoon is a loop: useful for three hours, forgettable afterwards.

4. What it's good for in retail

Anything you check at regular intervals over a day or two:

  • Orders: check every 30 minutes that morning orders move to fulfillment; alert if a status gets stuck.
  • Production deploys: after a release, check every 10 minutes that key pages respond and nothing breaks.
  • Supplier flows: make sure an expected stock import arrived and integrated cleanly.
  • Critical restock: track an out-of-stock reference and ping as soon as stock comes back.

That's the workstream I'm opening at Cobra right now: moving checks I used to do by hand (or not at all) into loops. The detailed journal entry will land once the first ones run in production — as always, everything gets documented.

Let's talk

Got a chore worth monitoring?

If there's a check you do by hand three times a day, it's probably a loop in disguise. Let's talk — I document everything in public.