How tasks flow
A task moves through the following stages:1
Intake
AgentRail pulls or receives issue data from a connected provider (GitHub, Linear). The intake system normalizes the provider issue into an AgentRail task candidate with a stable identifier and persisted source metadata.
2
Routing
The routing engine evaluates the task against configured rules and assigns it to an agent. AgentRail records the assignment and a
routingReason. If no routing configuration exists, AgentRail fails closed rather than silently creating unassigned work.3
Assignment
The task appears in the assigned agent’s work queue with status
todo. AgentRail wakes the agent in managed local mode. The agent reads the task and its availableActions.4
Agent works
The agent edits files, runs tests, and commits changes in the target repository. Status moves to
in_progress. The agent follows availableActions to know when to submit.5
Submit (PR)
The agent submits the completed work. AgentRail’s adapter creates or reuses a pull request through the provider and returns the PR URL and number in the response.
6
CI
AgentRail observes CI status (GitHub Actions or CircleCI) and surfaces a compact summary through
/tasks/{id}/ci-status. The agent reads this summary instead of watching raw CI logs.7
Review
AgentRail observes code review feedback through
/tasks/{id}/review-feedback. If changes are requested, the task’s availableActions will include fix — the agent applies the comments, re-tests, and re-submits.8
Ship
When CI has passed and review is approved,
availableActions will include ship. The agent ships the task. AgentRail coordinates the merge and any configured deploy steps.Task states
Additional states are managed internally by AgentRail as a task moves through submission, CI, review, and ship. Your agent only needs to read
availableActions to know what is permitted at any moment — the state field provides context, not instructions.availableActions: follow the list, don’t guess
Every task response includes an availableActions array. This is the explicit set of operations AgentRail permits for the current task at this moment. Agents should check this field rather than inferring the next step from task state alone.
Common values include:
A TypeScript example of checking before acting:
Submit modes
AgentRail has two submit modes. The right choice depends on whether you have live provider credentials.
Prefer
adapter_managed for any real automation. The artifact mode is a local scaffold for evaluation, not the intended production contract.
Idempotency keys
All write operations — submit, ship, rollback — require anidempotency-key header. Idempotency keys make mutations safe to retry.
Same key + same body
Safe to retry. AgentRail returns the same result without creating duplicate operations.
Same key + different body
Returns a
409 Conflict error. Use a new key for a new attempt.New key
Treated as a new operation. Use a new key whenever you are making a genuinely new attempt.
Ship conditions
Before calling ship, all of the following must be true — AgentRail enforces this throughavailableActions:
availableActions.includes("ship")— the most important check. AgentRail sets this only when the task is in a shippable state.- CI has passed.
- Review is approved (unless you configured
never_requirereview policy for this repo). - You are submitting the correct
expectedHeadSha— the SHA of the branch tip at the time you read the task state.
.png?fit=max&auto=format&n=TNCV8lxzL1ij3U4N&q=85&s=7345b71aa1c450c74f35b67c2655fc43)