> For the complete documentation index, see [llms.txt](https://docs.warp.dev/llms.txt).
> Markdown versions of each page are available by appending .md to any URL.

# Adding human gates to a Blueprint

Add plan approval and conditional questions to a Warp Factories Blueprint, with routes that distinguish approval from requested changes.

Add a gate when a person must answer before a stage can finish. For example, require a plan review before implementation or ask a service owner about a migration discovered during the work.

## Require plan approval

In `factory.yaml`, add a named gate under the planning stage’s `gates`. The question belongs beside the work that produces the plan, not only in a general foreman prompt.

This `plan` stage assumes the Blueprint also declares an `implement` stage:

```yaml title="Stage under blueprint.stages"
plan:
  worker: foreman
  inputs: The request and repository context.
  prompt: Propose a short plan with scope and checks. Do not edit code.
  outputs: The plan and the plan-review answer.
  gates:
    plan-review:
      prompt: Review the plan. Approve it or describe the changes you want.
      outputs: Approval of this plan, or requested changes to it.
  to:
    - stage: plan
      when: The plan-review answer requests changes.
    - stage: implement
      when: The plan-review answer approves the current plan.
```

Choose a stable gate name, such as `plan-review`, so the routes can refer to its answer. `prompt` states what to ask; `outputs` describes the answers needed to continue. Without `when`, the gate opens after the stage’s work is done.

The stage stays open while the question is unanswered. “Changes requested” satisfies the gate but selects the revision route. An unrelated reply or a question back does not approve the plan. A revised plan is a new review matter and needs its own answer.

## Ask when a condition arises

For questions that depend on the work, add `when`. This gate can open during implementation when the worker discovers a migration:

```yaml title="Gate under an implementation stage's gates"
migration-review:
  when: The proposed change adds or alters a database migration.
  prompt: Ask the service owner to review the migration and its rollout plan.
  outputs: Approval, requested changes, or a decision not to proceed.
```

Write a condition the worker can assess from the task and its results. Include the material and context a person needs to answer. If several gates open together, the worker asks them together; every open question must be answered before the stage finishes.

For a leaf stage, the worker doing the work checks its gates and relays questions through the foreman. A gate on a delegated group is checked by the worker that dispatched the group, after the group’s result returns.

## Apply and verify the pause

1.  [Validate and apply](https://docs.warp.dev/factories/factory-as-code/#validate-a-definition) the complete definition, then start a new task that requires a plan.
2.  Open the question in the original conversation. Check the plan and leave the question unanswered. Implementation must not begin.
3.  Request a concrete change, such as adding the rollback check. Confirm planning resumes and presents the revised plan for another answer.
4.  Approve that plan. Confirm implementation receives the approved scope and uses the same task rather than creating unrelated work.
5.  Test a non-answer and any conditional gate separately. Check that unresolved questions remain open.

Gates guide the workflow; they do not grant or restrict repository access. Keep human approval and merge requirements in repository permissions and branch protection. Do not treat a gate’s answer as proof that a PR was merged.

## Related pages

-   [Routing work between Blueprint stages](https://docs.warp.dev/factories/blueprints/routes/) - Choose what each answer does next
-   [Defining Blueprint stages](https://docs.warp.dev/factories/blueprints/stages/) - Put a question beside the work it pauses
-   [About factory agents](https://docs.warp.dev/factories/factory-agents/#human-decision-points-and-permissions) - Separate workflow decisions from permissions
