Skip to main content
The Python AgentRailClient provides async methods for every stage of the AgentRail task lifecycle. All method names use snake_case and all response data is returned as validated Pydantic v2 models. You construct the client once and use it across your harness, typically as an async context manager.

Construct the client

Python models expose snake_case attributes. The available_actions list tells you what operations are currently permitted on each task.

Submit, observe, and ship

The following example shows the complete lifecycle: submitting work, reading CI and review status, then shipping when all conditions are met.
Always gate shipping on all four conditions: "ship" in available_actions, overall_status.value == "passed", outcome.value == "approved", and a resolved head_sha. Sending a stale SHA returns a 409.

Method reference

list_my_tasks

Pass a TaskStatus enum value to filter by status. Available values include TaskStatus.TODO, TaskStatus.IN_PROGRESS, and others.

get_task

Returns a TaskDetailResponse with the full task object including available_actions, branch, head SHA, and current state.

submit_task

Use TaskSubmitMode.ADAPTER_MANAGED for real provider automation. AgentRail creates or reuses the provider PR and returns the PR metadata in submission.data.pr_url.

get_task_ci_status

get_task_review_feedback

ship_task

expected_head_sha acts as an optimistic lock. The ship is rejected if the branch has advanced since you read the SHA.

Idempotency keys

submit_task and ship_task both require an idempotency_key keyword argument. See authentication for key naming conventions.