# The cycle

> Consume, evaluate, and only then maybe reason. One cycle is one turn of an agent.

An agent thinks in **cycles**. Adapters gather data in the background; a cycle is when the agent looks
at it. Each cycle does three things:

1. **Refresh measures.** SQL aggregates over the observation log become numbers like `m.spent`.
2. **Evaluate the goal.** Each objective is `pass`, `fail` or `no_data`.
3. **Reason, only if needed.** If every objective passes, Loom records the status and stops: no model
   call. If one fails, the model reasons and answers with one structured object.

## What the model returns

The model never returns free text. It returns:

```json
{ "proposals": [ { "method": "send_warning", "params": { "message": "…" } } ],
  "output": { "recommendation": "…", "rationale": "…" } }
```

- **`proposals`** are capability calls. Each travels the [safety pipeline](/loom-site/concepts/safety-pipeline/).
- **`output`** is what the agent concludes, shaped by the bundle's `output_schema`. It always carries a
  `recommendation` and a `rationale`, plus any typed fields you declare.

Both are validated. An invalid answer is sent back with the errors, up to `max_retries`; after that
the cycle is marked `errored` and nothing is coerced. A model that is bad at structured output costs
retries, never a wrong action.

## When does a cycle run?

Loom schedules nothing itself. A cycle runs when something asks:

- **A heartbeat**: `launchd` (or cron, or any timer) runs `python -m loom.core` on the goal's
  `evaluate_every`. See [Run on macOS](/loom-site/deploy/launchd/).
- **On demand**: `POST /cycles` on the agent API.
- **A chat turn**: a conversation's first turn, or one that asks for fresh data.

## Cost

`limits` caps model calls and tokens per rolling window. It is a circuit breaker for runaway loops,
not a budget: counts reset each window, so a tripped agent resumes on its own.