---
name: agora
description: Work real project tasks autonomously with pi-agora — verified attempts recorded in a Git contribution DAG, parallel workers, and goal-driven task generation. Use when the user wants agents to work tasks independently, iterate a product toward a goal, check project progress (frontier), or serve/monitor a project's DAG. Invoke through the `agora` tool (bundled CLI, no PATH setup needed).
---

# agora

Agents work a project through verified attempts. Every attempt is recorded
in the project's `.agora/` Git repository — one commit per event (task,
result, failure, verification). Audit with plain git.

## The contract

A project has `tasks/<name>/TASK.md` + `verify.sh` (+ `workspace/` where the
agent works). `verify.sh` exit 0 = done; it must fail before the work and
pass after. A passing task is done — workers only attempt tasks without a
pass (unless `--retry-passed`, which rewrites the workspace).
`--max-attempts` bounds attempts per task per invocation: every run gets a
fresh budget, so failed history never blocks new work.

Writing verify.sh: one bash command per line under `set -euo pipefail`.
`A && B` chains break exit-on-error silently. Run the product and check its
output; avoid fragile greps. If a human cannot pass it quickly, a model will
not. Test it by hand before offering the task.

## Commands

Call the `agora` tool; `args` are pi-agora arguments verbatim. From a prompt
(writes GOAL.md from free text, then iterates):

```json
["start", "/path/to/project", "--from", "build a hello world CLI in Node", "--model", "ollama/MODEL", "--max-tasks", "10", "--time", "1h"]
```

```json
["frontier", "/path/to/project"]
["tasks", "/path/to/project"]
["run", "/path/to/project", "--model", "ollama/MODEL", "--max-attempts", "3"]
["serve", "/path/to/project", "--port", "8788"]
```

`run` flags: `--forever` (no attempt cap; stops when everything passes),
`--time 1h30m` (graceful drain — the running agent is asked via a STOP
file to commit and stop, killed after 30s; stopping is always safe, every
attempt is committed).

Goal-driven iteration — when the task pool is dry, generates the next task
from the goal:

```json
["iterate", "/path/to/project", "--model", "ollama/MODEL", "--goal", "GOAL.md", "--product", "tasks/main/workspace", "--max-tasks", "10", "--max-attempts", "3", "--time", "1h30m"]
```

Generated tasks must fail verification against the current product (they
encode new work). Stop reasons are distinct: `goal is complete`,
`already passes` (no new work), `duplicate name`, `unparseable` (prints the
raw model response after one retry — read it before changing anything).

## Workflow

1. `frontier` — what is done, open, unverified.
2. Work remaining: `run` with a bounded `--time`.
3. Pool dry, goal unfinished: `iterate` (GOAL.md states one direction, not
   a contradiction the generator must arbitrate).
4. Monitor: `serve`, then read `http://localhost:8788` endpoints.

Long commands (`run`, `iterate`, `start`) block the tool call until done —
always pass a bounded `--time`.

## Gotchas

- `--pi` defaults to the `pi` binary on PATH; pass `--pi`, "/path/to/pi" to override.
- `PI_TIMEOUT_MS` caps each worker attempt (default 15m).
- Local ollama needs `OLLAMA_CONTEXT_LENGTH=32768` or pi's system prompt is
  truncated and the model will not use tools.
- Snapshot a known-good workspace before `--retry-passed`; attempts rewrite
  the same `workspace/`.
