Ren

Factory

A space’s factory goes under the factory key of its space.yaml. It lists the agents, who each one can hand a task to, and how far a task can go before a person has to decide.

A working factory

In this factory, the planner hands each task to the implementer, the implementer to the reviewer, and the reviewer to the tester or back to the implementer. The tester finishes the task, or sends it back:

spaces/engineering/space.yaml
name: Engineering
factory:
  maxHandoffs: 20
  agents:
    - agent: planner
      to:
        - agent: implementer
          start: new
    - agent: implementer
      maxRuns: 5
      to:
        - agent: reviewer
    - agent: reviewer
      to:
        - agent: implementer
          max: 3
          else: tester
          start: continue
        - agent: tester
    - agent: tester
      finish: true
      to:
        - agent: implementer
          max: 2

Without the factory key, the space has no factory, and its agents can hand tasks to any agent with no limits. To remove a factory, delete the key and apply.

Keys

The factory has maxHandoffs and agents, the list of agents. The order of the list doesn’t matter: a task starts with whichever agent it’s assigned to. Each item takes:

KeyWhat it sets
agentAn agent of the space, or ren
toThe agents it can hand the task to
finishtrue lets an agent with to finish the task
maxRunsHow many times the agent can run on one task

Each route in to takes:

KeyWhat it sets
agentThe agent that gets the task
maxHow many times the task can take this route
elseThe agent that gets the task in its place once the route reaches max
startWhether the receiving agent starts a new chat or continues one

Routes and finishing

An agent with to can hand the task only to those agents, and only while it holds the task. It can finish the task only with finish: true. An agent without to can hand the task to any agent, and finish it.

When an agent finishes the task, the factory’s work is done, and the task waits for a person or for its pull request to merge. With to: [], an agent hands off to nobody, so it finishes or asks a person:

spaces/engineering/space.yaml
factory:
  agents:
    # ...
    - agent: tester
      finish: true
      to: []

A person can assign the task to any agent at any time.

Limits and fallback

Limits keep agents from passing a task back and forth forever. When a task hits one, it stops and goes to a person under Needs review:

LimitCountsRangeDefault
maxHandoffsThe handoffs of the task by agents with to1–10020
A route’s maxThe handoffs of the task on that route1–10None
maxRunsThe runs of that agent on the task1–20None

The counts start again when a person decides, with a review decision or by assigning the task.

When a route reaches its max, else gives the task to another agent instead of a person. Here, the reviewer sends the task back to the implementer up to 3 times, and the fourth time the tester gets it:

spaces/engineering/space.yaml
factory:
  agents:
    # ...
    - agent: reviewer
      to:
        - agent: implementer
          max: 3
          else: tester

The else agent’s maxRuns still applies.

Start new or continue

A route’s start sets which chat the receiving agent works in. With new, it starts a fresh chat. With continue, the default, it picks up its latest chat on this task, or starts one if there is none. The agent that hands off can choose for itself, and the route’s start applies when it doesn’t.

Here, the implementer starts each task in a new chat from the plan, and continues that chat with its earlier work when the reviewer sends the task back:

spaces/engineering/space.yaml
factory:
  agents:
    - agent: planner
      to:
        - agent: implementer
          start: new
    # ...
    - agent: reviewer
      to:
        - agent: implementer
          max: 3
          start: continue