# Bundles

> One YAML file declares an agent. The engine has no domain logic of its own.

A **bundle** is an agent. The same engine runs every bundle; swap the file and you have a different
agent, with no code in Loom changing.

Loom validates a bundle when it loads. An unknown field, a typo in a condition, or an option Loom does
not run is refused there, with the reason, never discovered halfway through a cycle.

## The blocks

| Block | What it declares |
|---|---|
| `name`, `schema_version` | The agent's identity, and the schema version the file targets (`v1`). |
| `kind` | `goal` (the default) reasons toward a goal; `chat` serves conversations. |
| `goal` | Objectives: conditions over measures that say what "on target" means, and how often to check. |
| `measures` | Numbers computed from observations over a window: `count`, `sum`, `avg`, `min`, `max`, `ratio`, `latest`, `earliest`. |
| `behavior` | The agent's directive, principles and tone, given to the model. |
| `adapters` | Where data comes from, and how each record is normalized. |
| `capabilities` | The only actions the model may propose, each with a schema, a risk tier and an approval policy. |
| `inference` | The model and how Loom reaches it. |
| `output_schema` | Typed fields the model must fill in each time it reasons. |
| `limits` | A circuit breaker on model calls and tokens per window. |
| `notifications` | Rules that alert a person when a condition holds. |
| `memory`, `storage` | What the agent remembers, and where its data lives. |
| `agents` | Child agents this one may spawn. |

Every field, with its type and default, is in the [Bundle schema](/loom-site/reference/bundle-schema/).

## Conditions are CEL

Objectives, filters, notification rules and capability conditions are written in
[CEL](https://cel.dev), a small, safe expression language. Measures are read as `m.<name>`:

```yaml
goal:
  objectives:
    under_budget: "m.spent < 500"
    inbox_clear: "m.unread == 0"
```

## Objectives that finish

An objective is **invariant** by default: it is maintained forever. Mark one `terminal` to make it a
goal that is reached once. When it holds steadily it is marked `met` and no longer given to the model.
A terminal objective may carry a `deadline`; past it, unmet, it is reported `expired`.

When every objective is terminal and resolved, the agent parks as `served`: it costs nothing and stays
visible on the API. Editing the goal re-arms it.

## Examples

The Loom repository ships worked bundles in
[`tests/bundles/`](https://github.com/benja0rtzzz/loom/tree/main/tests/bundles): a finance monitor, a
fleet monitor, an inbox triager, an incident responder, a supervisor with children, and the coding
workers.