autonomous-loop-patterns — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited autonomous-loop-patterns (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
An autonomous loop has six primitives: a trigger, a worker agent, a progress signal, a stop condition, durable state, and a safety cap.
An autonomous agent loop is not just an agent being told to continue. It is a control system. The agent is one component; the loop decides when to run it again, what evidence proves progress, what state survives a crash, and when a human must take over.
The smallest safe loop is usually better than the most powerful loop. A one-off task with a clear finish condition does not need a queue supervisor. A multi-session backlog should not rely on a single completion word. A long-running unattended process must not depend on the worker agent remembering its own state.
The quality bar is explicit termination plus recoverable state. If a loop cannot answer "why did this run again?", "what changed since the last iteration?", and "what stops it from running forever?", it is not an autonomous loop. It is an uncapped retry.
| Primitive | Question it answers | Examples |
|---|---|---|
| Trigger | What starts the next iteration? | User request, queue item, scheduler tick, failed verification |
| Worker agent | Who performs one unit of work? | A coding agent, reviewer agent, data extractor, browser runner |
| Progress signal | How do we know anything changed? | Commit, test result, status update, artifact write, metric delta |
| Stop condition | What means the loop is done? | Empty queue, completion marker, passing gate, explicit human stop |
| Durable state | What survives crash or context reset? | Checkpoint file, issue comment, job record, append-only log |
| Safety cap | What forces review when progress fails? | Max iterations, max consecutive errors, elapsed-time cap, budget cap |
Design the primitives first. Tooling choices come second.
| Pattern | Best for | Stop owner | State owner | Main risk |
|---|---|---|---|---|
| Bounded single-run loop | One clear task that should finish in one session | Runtime limit or final verification gate | The current run plus final artifact | Agent tries to continue after the task is already done |
| Sentinel continuation loop | Small repeated task with a precise done marker | Completion marker checked by a wrapper or hook | Transcript plus optional counter | Completion marker appears accidentally or never appears |
| Checkpoint-resume loop | Multi-session work where context may reset | Checkpoint state and remaining-work count | Durable checkpoint | Stale checkpoint causes repeated or skipped work |
| Supervisor respawn loop | Long-running unattended throughput | External supervisor | Status files, queue, and logs | Respawn storm after repeated failure |
| Human-gated loop | Risky work with side effects or unclear requirements | Human approval gate | Review record and approved next action | Loop waits without making the escalation visible |
Use this for a single task with a concrete finish condition. The prompt names the deliverable, the runtime enforces a hard limit, and verification decides whether the run is done.
Use when:
Required safeguards:
Do not use this for long backlogs, stateful migrations, or tasks where partial progress must be resumed.
A sentinel loop repeats until the worker emits a precise completion marker, or until a wrapper decides the marker is absent and starts another turn. Some teams call this the Ralph Wiggum pattern: the runtime keeps going until the agent says the exact stop phrase.
Prompt contract:
Do the task described below.
Completion condition: all requested changes are implemented and verification passes.
When and only when the completion condition is true, output this exact marker:
TASK_COMPLETE_9F3A
If the task is blocked, output BLOCKED with the reason instead.
Do not output the completion marker in code, examples, logs, or explanations.Use when:
Required safeguards:
Do not use this when the task spans many sessions, requires durable queue state, or has high-risk side effects.
A checkpoint loop persists the state needed to resume later. The worker writes a checkpoint at the end of each run. The next run reads it, verifies it against current reality, and continues.
Minimum checkpoint contract:
{
"objective": "short stable goal",
"iteration": 3,
"max_iterations": 10,
"remaining_work": ["item-a", "item-b"],
"completed_work": ["item-0"],
"last_verified_evidence": "test name or artifact reference",
"context_health": "ok | degraded | exhausted",
"next_action": "the first action for the next run",
"stop_reason": null
}Use when:
Required safeguards:
Do not store the only copy of progress in model memory or chat history.
A supervisor loop runs outside the worker agent. It starts a worker, watches status and timeout signals, records the result, and decides whether to spawn another worker.
Use when:
Required safeguards:
Do not let a supervisor respawn a worker after repeated identical failures without changing state, backoff, or escalation.
| Signal | Reliability | Use it for | Failure mode |
|---|---|---|---|
| Authoritative tracker state | High | Queue and backlog loops | Tracker update omitted or duplicated |
| Passing verification gate | High | Coding, data, or document loops | Gate is too shallow or not rerun |
| Explicit sentinel marker | Medium-high | Small repeated tasks | Marker appears accidentally or never appears |
| Durable checkpoint says no work remains | Medium | Checkpoint loops | Checkpoint is stale |
| Process exit code | Medium | Supervisor loops | Exit code lacks semantic detail |
| Absence of new output | Low | Last-resort stall hint only | Quiet work and stalled work look the same |
Prefer authoritative tracker state and verification gates when available. Use sentinel markers for small loops. Use absence of output only as a stall warning, never as proof of completion.
Every autonomous loop needs at least one cap. Unattended loops usually need several.
| Cap | Prevents | Typical default |
|---|---|---|
| Max iterations | Endless continue loops | 5-15 iterations, lower for risky work |
| Consecutive errors | Respawn storms | Stop after 3 repeated failures |
| Elapsed time | Long silent runs | Based on expected phase duration |
| Work item lock age | Zombie ownership | Expire only after evidence of worker death |
| Context health | Low-quality late-session changes | Stop and hand off at exhausted context |
| Budget | Runaway cost | Small initial budget, staged increase |
The cap must be enforced outside the worker when possible. A model instruction that says "do not loop forever" is not a cap.
A loop is stalled when it keeps consuming iterations without improving the durable state.
Common stall signals:
Recovery sequence:
Do not recover from a stall by only increasing the iteration limit.
Use this decision table before implementing loop control.
| Situation | Recommended pattern |
|---|---|
| One task, one artifact, clear verification | Bounded single-run loop |
| One task that may need a few more turns | Sentinel continuation loop |
| Multiple related steps that may exceed context | Checkpoint-resume loop |
| Many independent queue items | Supervisor respawn loop |
| Side effects, approvals, or unclear requirements | Human-gated loop |
| Unknown done condition | Do not loop yet; define the stop condition first |
The rule of thumb: choose the simplest pattern that can stop safely and resume correctly.
Before shipping an autonomous loop, answer these questions in writing:
If any answer is "the agent will remember", the design is not ready.
| Anti-pattern | Why it fails | Safer replacement |
|---|---|---|
| Unbounded continue prompt | The model can retry forever without new evidence | External iteration cap plus blocked state |
| Prompt-only reliability | The model is both worker and watchdog | Runtime or supervisor enforces caps |
| Hidden progress in chat history | Restart loses the work state | Durable checkpoint or tracker update |
| Completion by silence | Quiet output is indistinguishable from a hang | Explicit done, blocked, failed, or timed-out state |
| Respawn without state change | Repeats the same failure | Backoff, classify, and escalate |
| One giant worker context | Context rot degrades decisions | Fresh worker per item or checkpoint handoff |
| Human gate buried in logs | Review never happens | Explicit approval state and visible stop reason |
After applying this skill, verify:
| Use instead | When |
|---|---|
agent-engineering | Designing the full production agent system, including model routing, multi-agent coordination, and rollout policy |
prompt-craft | Writing the exact instruction for one agent run or one worker prompt |
tool-call-strategy | Optimizing how many tools one agent calls inside a single iteration |
context-management | Deciding what information belongs in one worker's context |
observability-modeling | Designing event names, spans, metrics, and trace attributes for the loop |
| Product-specific docs | Choosing a slash command, IDE feature, or hosted-agent setting in a particular tool |
<!-- skill-graph-context:start (generated — do not edit by hand) -->
Classification
agent-opstrueagent/loop-designWhen to use
autonomous-loop-skill, loop-patterns-skill, agent-loop-designRelated skills
observability-modeling, agent-engineeringprompt-craft, tool-call-strategy, context-management, agent-engineering, observability-modelingConcept
Keywords
autonomous agent loop, agent loop pattern, completion signal, checkpoint resume loop, supervisor respawn, stall detection, safety cap, agent watchdog, human handoff<!-- skill-graph-context:end -->
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.