# Factory

A factory chains the [agents](/docs/agents/) of a [space](/docs/spaces/), so a [task](/docs/tasks/) moves from one agent to the next without you.

<Screenshot
  shot="factory/editor"
  alt="The Factory page of the Engineering space: triager, planner, fixer, reviewer, qa and release-watcher, with handoffs back to the fixer"
  caption="A factory where the reviewer and QA can send work back to the fixer."
/>

## Set up the factory

Open **Space → Factory**. **Flow** shows how tasks move between the agents.

To change the factory, either:

- Edit **spec.yaml** and select **Save**.
- Select **Edit with Ren** and describe the change.

For each agent, set:

| Setting             | What it does                                                                                      |
| ------------------- | ------------------------------------------------------------------------------------------------- |
| Next agent          | Who it can pass the task to. Without a list, any agent of the factory.                            |
| A limit per handoff | How many times it can hand to that agent, from 1 to 10, and who gets the task at the limit        |
| A limit of runs     | How many times the agent can run on one task, from 1 to 20                                        |
| **Finish**          | The agent can finish the task. The task then waits for a person or for its pull request to merge. |

The whole factory also has a limit of handoffs per task, from 1 to 100. The default is 20.

## When a person decides

A task stops and shows under **Needs review** when:

- an agent asks for [review](/docs/tasks/#review),
- a limit is reached,
- an agent that can finish it finishes it,
- an agent's run ends twice without a handoff or a review request. After the first time, Ren reminds the agent.

Read what the agents did on the task's page, then **Approve** it, reply in its chat, or assign it to another agent.

## Good to know

- Agents hand off by assigning the task to the next agent. You can do the same at any time.
- To add an agent, create it on **Agents** first, then add it to `spec.yaml`.
- To keep the factory in Git, see [Factory](/docs/developers/iac/factory/) on the Developers tab. **spec.yaml** shows what the `factory` key holds there.