Claim Run
Atomically take the oldest queued run this runner can execute. Skips agents that are dormant or already running something, marks the run running under the caller's runner_id and returns its full context. Answers 204 when there is nothing to do. Runners must start runs through this, never by PATCHing status=running, so two runners can't execute the same run.
Atomically take the oldest queued run this runner can execute.
Skips agents that are dormant or already running something, marks the run running under the caller's runner_id and returns its full context. Answers 204 when there is nothing to do. Runners must start runs through this, never by PATCHing status=running, so two runners can't execute the same run.
HTTPBearerAuthorizationBearer <token>company_id*Company Iduuidapplication/json- body
Claim the oldest queued run this runner can execute.
adapters?array<string>|nullagent_ids?array<>|nullrunner_id*Runner Id1 <= length <= 100Successful Response
application/json- response
Everything a runner needs to execute a claimed run.
agent*comments?array<>[]company*goals?array<>[]lease_seconds*Lease Secondsmanager?|nullproject?|nullrun*task?|nullcurl -X POST "https://example.com/api/companies/497f6eca-6276-4993-bfeb-53cbbbba6f08/runs/claim" \ -H "Content-Type: application/json" \ -d '{ "runner_id": "string" }'{ "agent": { "adapter": "string", "avatar_seed": 0, "capabilities": [ null ], "company_id": "b2e6a1c3-1a5e-44ae-a8fd-81f76fd715cf", "created_at": "2019-08-24T14:15:22Z", "heartbeat_cron": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "instructions": "string", "last_activity": "2019-08-24T14:15:22Z", "monthly_budget_cents": 0, "name": "string", "open_tasks": 0, "reports_to_id": "9a08cb01-6bdc-412f-ad45-35a6f5d74f8e", "role": "string", "spend_mtd_cents": 0, "status": "string", "title": "string" }, "comments": [], "company": { "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "mission": "string", "name": "string", "task_prefix": "string" }, "goals": [], "lease_seconds": 0, "manager": { "adapter": "string", "avatar_seed": 0, "capabilities": [ null ], "company_id": "b2e6a1c3-1a5e-44ae-a8fd-81f76fd715cf", "created_at": "2019-08-24T14:15:22Z", "heartbeat_cron": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "instructions": "string", "last_activity": "2019-08-24T14:15:22Z", "monthly_budget_cents": 0, "name": "string", "open_tasks": 0, "reports_to_id": "9a08cb01-6bdc-412f-ad45-35a6f5d74f8e", "role": "string", "spend_mtd_cents": 0, "status": "string", "title": "string" }, "project": { "created_at": "2019-08-24T14:15:22Z", "description": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "monthly_budget_cents": 0, "name": "string", "repository": "string", "spend_mtd_cents": 0, "status": "string", "tasks_done": 0, "tasks_total": 0 }, "run": { "agent_id": "2b1e3b65-2c04-4fa2-a2d7-467901e98978", "cost_cents": 0, "created_at": "2019-08-24T14:15:22Z", "ended_at": "2019-08-24T14:15:22Z", "error": "string", "heartbeat_at": "2019-08-24T14:15:22Z", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "routine_id": "f53c5ff7-cfb7-4f43-8b79-3421a01d8e2a", "runner_id": "string", "started_at": "2019-08-24T14:15:22Z", "status": "string", "summary": "string", "task_id": "736fde4d-9029-4915-8189-01353d6982cb", "tokens_in": 0, "tokens_out": 0, "transcript": [ {} ], "trigger": "string" }, "task": { "assignee_agent_id": "8ff43445-51ff-4235-b9d4-d8007d4d5dc3", "completed_at": "2019-08-24T14:15:22Z", "created_at": "2019-08-24T14:15:22Z", "created_by_agent_id": "acd3b99b-57bd-46a1-809a-5d915f3c2609", "created_by_user_id": "209f54c4-4c33-43bc-9c6a-ef4c65ad7473", "description": "string", "due_date": "2019-08-24T14:15:22Z", "goal_id": "3854d9ad-4bca-4a70-a63e-7c6bc2f12aee", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "key": "string", "number": 0, "parent_id": "1c6ca187-e61f-4301-8dcb-0e9749e89eef", "priority": "string", "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", "sort_order": 0, "started_at": "2019-08-24T14:15:22Z", "status": "string", "title": "string", "updated_at": "2019-08-24T14:15:22Z" }}List Runs GET
List the company's runs, newest first, capped at `limit` (default 100, max 500). Filter by `agent_id`, `task_id` and `status` (repeatable: `queued`, `running`, `succeeded`, `failed`, `cancelled`). Transcripts are omitted; fetch a single run for its transcript.
Expire Stale Runs POST
Fail running runs whose runner stopped reporting. A run expires when its last heartbeat (or start time) is older than the lease, `RUN_LEASE_SECONDS` (default 300). Expired runs become `failed`, their running agents move to `error`, and budgets are enforced as for any finished run. Returns the expired run ids as `{"expired": [...]}`. `POST /runs/claim` does this automatically before claiming.