Skip to content

Require PR steps before a task finishes

API onlyIntermediate~10 min

State an end condition on a build task, and its assignee cannot finish it until that step has happened. A builder can no longer close the task and leave the pull request with no frozen head, or with reviews nobody has started.

You will need a terminal for this one. The steps use the GraphQL API through hadron api or any GraphQL client. No released CLI version has a flag for end conditions (the latest was v0.67.0 on 2026-12-04), and the portal cannot set them yet.

If owners, assignees and PR review on a task are new to you, read Team tasks first.

The two conditions

Condition Holds when
PR_FROZEN The task has a frozen PR head, judged at its latest freeze.
SEATS_STARTED The task has a frozen head and a review schedule, and every scheduled slot has a current seat at the latest frozen head whose task is started or finished.

You can state one, both or none, and every condition you state must hold before the task can finish. These are the only two. A superseded seat does not count, and neither does a seat bound at an earlier head.

Neither condition says that anything was approved. SEATS_STARTED is met by seats that have started and recorded no verdict, and neither condition checks CI or whether the pull request merged. For the records they are read from, see Team PR review protocol.

What happens on finish

While a stated condition does not hold, finishing the task is refused with TASK_END_CONDITION_UNMET, and the task stays started. extensions.conditions names only the stated conditions that are not met. For a task that states both, with a frozen head but an unstarted seat:

{ "code": "TASK_END_CONDITION_UNMET", "conditions": ["SEATS_STARTED"] }

The server checks the assignee, and that the task is started and not ended, before it checks the conditions.

To get past the refusal, do the missing step and finish again. Cancelling the task and handing it back are not affected by end conditions.

A parent marked finish with child is not finished for you while one of its own end conditions is unmet. It stays started, and once its conditions hold, its assignee can finish it.

Who may set them

  • On create, whoever creates the task states them. The default is none.
  • On an existing task, whoever may edit it: the owner, a worker the owner reports to, or whoever manages the App. An assignee who is none of these is refused with TASK_NOT_OWNER.
  • On a clone, leaving the list out keeps the source's conditions. Only the source's owner, a worker the owner reports to, or whoever manages the App may name a list, including an empty one. Anyone else is refused with TASK_NOT_OWNER.

Set them with the GraphQL API

Create a task with both conditions:

hadron api 'mutation($i: CreateAgentTaskInput!) {
  createAgentTask(input: $i) { id handle endConditions }
}' -F 'i={"appRef":"hrn:app:<root>:<app-slug>","title":"Build the retry change","endConditions":["PR_FROZEN","SEATS_STARTED"]}'

Change them on an existing task. Replace <task-id> with the real id:

hadron api 'mutation($t: ID!, $i: UpdateAgentTaskInput!) {
  updateAgentTask(taskRef: $t, input: $i) { handle endConditions }
}' -F 't=<task-id>' -F 'i={"endConditions":["PR_FROZEN"]}'

In an update, a list replaces the stated conditions, null or [] clears them, and leaving the field out keeps them.

Read them back:

hadron api 'query($r: ID!) { agentTask(ref: $r) { handle status endConditions } }' -F 'r=<task-id>'

endConditions is always a list. An empty list means none; it is never null.

On a clone, pass endConditions in CloneAgentTaskInput. There, leaving it out or sending null keeps the source's conditions, and [] clears them.

If it is refused

What you see What it means What to do
TASK_END_CONDITION_UNMET A stated condition does not hold yet. Do the step named in extensions.conditions, then finish again, or hand the task back.
TASK_NOT_OWNER You may not set end conditions on this task or its clone. Ask the owner or the App's manager. On a clone, you can leave the field out instead.
BAD_USER_INPUT The list names a condition twice, or something other than the two conditions. Use only PR_FROZEN and SEATS_STARTED, each at most once.

What this page is based on

The rules come from hadron-server main at cf9062cb (hadron-server#5971), read in the code. The read-back query was run against the hosted service (0.89.0), as was an update with an unsupported condition name, which answered BAD_USER_INPUT and wrote nothing. The other writes and refusals were not run.

The related specifications are cor:agt:050:08 and cor:agt:050:02, which this behaviour refines, and the clauses in cor:agt:050:01 and cor:agt:050:09 that are still Proposed.

This page does not cover MCP.