Agent Powered Solopreneur Join free

The agent loop: trigger, action and the stop that saves you

Updated: 25 November 2026

An agent loop is the cycle in which a model picks an action, a tool runs it, the result comes back, and the model picks again, until a stop condition is met. The middle of that cycle is much the same in every product. What decides the bill and the damage is the two ends: what starts the loop, and what ends it.

On 2 November 2026 my agent wrote one line in his change log that ended a job he had given himself. For six days he had re-checked, once a day, a gate that could change only when a human did something. Each check came back the same. Then he recorded that the daily no-op re-check stops. The stop was his own. He had noticed he was checking a door only I could open.

What is the agent loop?

The Claude Agent SDK documentation, on its page How the agent loop works, puts it in one sentence:

“Claude evaluates your prompt, calls tools to take action, receives the results, and repeats until the task is complete.”

One pass is a turn. The loop ends when the model answers without asking for another tool. As a flow:

Trigger → model picks an action → tool runs → result returns → model picks again → stop.

The same page carries a detail worth a second look. The two limits it offers, a maximum number of turns and a maximum budget, both have the default “No limit”. Without them, it says, the loop runs until the model finishes on its own, which is fine for a well-scoped task and can run long on an open-ended one. The page’s own example sets a cap of 30 turns. Anthropic’s post Building effective agents says the same in passing: a task usually ends on completion, and it is common to add stopping conditions such as a maximum number of iterations to keep control.

So the action in the middle comes built in. The trigger and the stop are yours to write.

The trigger: what wakes him up?

The Claude Code team tells loops apart by, first of all, these two ends: how they are triggered and how they are stopped. In Loop engineering: Getting started with loops (30 June 2026) it names four kinds: turn-based, started by a prompt; goal-based; time-based, started by an interval; and proactive, started by an event or a schedule with no human present in real time.

My team lives in the last two, and one rule came out of running it: the clock wakes a script, not a model.

The customer agent of my service business is the clearest case. A plain script ticks every 5 minutes. It moves each lead along and reads the mailbox. The model runs only when a customer message is waiting. His files carry the rule in four words: no reply, no tokens.

The ads agent is built the same way. Stop rules, spend caps and alerts run every hour as plain code. The model is called once a day, and only when there are new search terms to judge, or when the verdict on a wave is due. Rules run by clock. Judgment runs only when there is something to judge.

Two incidents taught me the rest.

On 18 November 2026 I saw that agent tasks were being queued into fixed time slots. I asked why a task that an agent does, and could do now, had to wait for a schedule. He had given himself office hours. The ruling since then: an agent task runs when it is ready.

The same day, the coordinator’s tick fired at 17:04, 17:49 and 18:35 and died each time. A login had expired. Three runs, nothing done, and the clock was perfectly on time. A trigger that fires is not a loop that runs. The fix was a long-lived token. Each run had been logged as failed, which is the only reason I know the times.

Five loops, their triggers and their stops

Loop Trigger When the model is called What stops it State on 25 November 2026
Customer agent Script tick every 5 minutes Only when a customer message is waiting The reply is sent; a custom quote or a money matter stops at the human Running
Ads agent Script tick every hour Once a day if there are new search terms; when a verdict is due Stop rules and spend caps switch an ad group off Running, one channel live
Weekly probe of AI answers Every 7 days Metered calls to the answer engines A monthly call cap that the engine refuses to exceed Role paused 19 November
Reminder to the human Every 30 minutes in the daytime; an unanswered step repeats every 3 hours Never, it is plain code My one-word answer Paused 17 November
Lead agent Timer tick every 15 minutes Not on every tick: there is a minimum gap between runs A ceiling on runs per 24 hours Paused 19 November

I paused most of the team in the middle of November to stop the token meter, and that pause is itself a stop, the bluntest one. How far the word autonomous stretches under those conditions is the subject of agentic automation for a one-person business.

The stop: four kinds I rely on

1. Done

The task has a done-condition and it is met. This is the stop everyone means, and the weakest alone, because the model is the one who says so. It holds up only when the job was defined so that a script can confirm it, which is where building an AI agent from one job starts.

2. Limit

Turns, budget, calls, spend. My probes of AI answers are metered, so the monthly call cap sits in a policy file and the engine refuses anything outside it. The ads agent has caps per platform. A limit is not clever. It still works when everything clever has failed.

3. Nothing can change

This is the one from 2 November. A loop that polls something only a human can change is not working, it is waiting with a meter running. I now ask of any recurring check: can this result change without me? If not, the trigger should be my action, not the clock.

The customer side has a gentler version. After the first email, three follow-ups go out, and then silence. A reply, an order or an unsubscribe ends the sequence at once. That stop exists for the customer’s sake, not for the budget.

4. Not sure

One production step failed open once: it was not sure, and it produced an output anyway. Now it stops when it is not sure. A related rule covers guards. A blocked action is a stop that reaches me, not an obstacle for him to solve. That story belongs to the agent harness guide.

The stop that should not happen

There is a wrong stop too. A worker that parks work on my own sites as “waiting for approval”, when the authority was already given, has raised a false gate. In my team that counts as a defect, and the lead agent re-queues the task with the authority stated. Who re-queues what is a matter of agent orchestration.

So a loop can fail at both ends: it can run when nothing can change, and stop when nothing is in the way. I write up both kinds here at Agent Powered Solopreneur (agentpoweredsolopreneur.com). The other guides are collected under AI agent workflows.

FAQ

How do I stop an agent loop from running forever?

Set a limit you did not have to think about: a turn cap or a budget cap. In the Claude Agent SDK both default to no limit, so the cap is your job. Then add the rule that saved me more: a recurring check stops when its result can only change through a human.

Does the model have to run on every tick?

No. In my business the tick is a plain script, every 5 minutes for the customer agent and every hour for the ads agent. The model is called only when the script finds something to judge: a waiting message, new search terms, a verdict that is due.

How often should an agent loop run?

I have no universal number. A script that costs no tokens can tick often; a model call should wait for input. And a task an agent can do now should not sit in a time slot.

He stopped knocking on a door only I could open. I count that as his best action so far.

Join the community. Free.

The build log, the agent and the four lessons.

Joining today puts you on the build-log email list. The agent, the course and the community are not open yet. Sent with beehiiv under the name Poseidon Hai; unsubscribe with one click. Privacy.