Skip to content

Quickstart

Markdown

You will build an agent that watches expenses dropped into a folder, and proposes a warning when the month’s spending passes a budget. The warning waits for your approval.

Create a folder with an inbox/ inside it, and save this as budget.yaml:

budget.yaml
name: budget-watch
schema_version: v1
goal:
objectives:
under_budget: "m.spent < 500"
evaluate_every: 10m
measures:
spent:
aggregation: sum
field: fields.amount
filter: "type == 'expense'"
window: 30d
default: 0
behavior:
directive: "Watch monthly spending and warn before the budget runs out."
adapters:
- name: expenses
transport: native
auth: { type: none }
trigger: { mode: poll }
normalize:
mode: declarative
identity: { strategy: natural_key, key: ["$.data.id"] }
timestamp_from: "$.data.date"
type: expense
fields:
amount: { path: "$.data.amount" }
note: { path: "$.data.note" }
catalog:
expense: { amount: number, note: string }
options:
path: inbox
pattern: "*.json"
format: json
capabilities:
- method: send_warning
risk: dangerous
approval: human
params_schema:
type: object
properties:
message: { type: string }
required: [message]
additionalProperties: false
handler: "budget_actions:send_warning"
workspace: true
inference:
provider: claude-cli
model: haiku

Each block has one job:

  • goal: what “on target” means, as a condition over measures. Checked every 10 minutes.
  • measures: numbers computed from observations, here the sum of the last 30 days.
  • adapters: where data comes from. This one reads every JSON file in inbox/.
  • capabilities: the only actions the model may propose. This one always needs a person.
  • inference: the model. Any provider works.

Then the code behind send_warning, beside it. Loom calls it with the validated params, plus a folder it made for this capability:

budget_actions.py
from pathlib import Path
def send_warning(*, message: str, workspace: Path) -> dict:
"""Write the warning to a file in the folder Loom gives this capability."""
target = workspace / "warning.txt"
target.write_text(message)
return {"path": str(target)}

Check the bundle loads:

Terminal window
uv run --project /path/to/loom python -m loom.config budget.yaml

A typo or an unknown field is refused here, with the reason.

Drop two expenses into inbox/. Use today’s date: the measure only counts the last 30 days.

inbox/e1.json
{ "id": "e1", "date": "2026-12-02T09:00:00Z", "amount": 320, "note": "rent share" }
inbox/e2.json
{ "id": "e2", "date": "2026-12-02T10:00:00Z", "amount": 240, "note": "flights" }
Terminal window
uv run --project /path/to/loom python -m loom.core budget.yaml

Loom reads both files, computes spent = 560, and finds under_budget failed. Only now does it call the model, which answers with a proposal to call send_warning. Because the capability needs a human, the proposal is parked: nothing has been sent.

Everything is stored in .loom/data/budget-watch.sqlite3, next to where you ran the command.

Issue yourself a token and serve the agent’s API:

Terminal window
uv run --project /path/to/loom python -m loom.api.tokens issue budget.yaml me --kind human
uv run --project /path/to/loom python -m loom.api budget.yaml

The first command prints your token: export it as TOKEN. List what is waiting, then approve it:

Terminal window
curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8000/proposals

Copy the proposal_id it returns, then approve it:

Terminal window
ID=prop-... # the proposal_id from the list
curl -X POST -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8000/proposals/$ID/approve

The response says "outcome": "success" and gives the path of warning.txt.

Approval re-runs validation and the gate, then calls send_warning: the model’s message lands in warning.txt. The ledger records who approved it.