Taskbase — Runners and Runs¶
Kind: reference
Reference for the runner API: how machines running agent-runner register,
take work and report back, and how the control room steers them. The design and
its reasoning are in ADR-0006
(token usage and subscription limits: ADR-0008);
the wider picture is in Agent Architecture. See Usage Trends
for aggregated usage queries and the Usage page.
Code: api/internal/runner/ (runners, runs, claims, lease sweeper, session turns in
session_turns.go) and api/internal/authz/runscope.go and turnscope.go (agent confinement). Tables: runners,
runner_organizations, runner_settings, task_runs, session_turns, incident_reports, runner_claude_api — see Database Schema.
Besides tasks, a runner can answer the chat turns of agent sessions, through a separate long-poll claim and its own session slots — see Session turns.
On the machine itself, an operator can run a desktop app — in the macOS menu bar or the Windows
notification area — instead of watching
agent-runner status — it controls the runner only through its CLI and never talks to Taskbase
directly (see ADR-0006, Desktop app).
A person without a machine can have a runner as a pod on hetzner-mgmt instead: it reports
update_mode: "image" and is updated through its container image. Setting one up is in
Run a runner in the cluster.
Concepts¶
| Term | Meaning |
|---|---|
| Runner | A machine running agent-runner, logged in as an ordinary Keycloak user (its principal). Created in the control room, then registered by the machine. |
| Scope | instance — claims from every organization; organization — only from the organizations listed on it. |
| Labels | What the machine offers (gpu, os=linux, …), from its own config. A task's required_labels must all be present. Any task for the operator agent gets role=ops and at least large when created or updated, so the ops-agent runner can claim it; see Handing work to agents. |
| Dedicated label | Optional; one of the runner's labels. The runner then takes only tasks that require it — e.g. a runner kept to reviews. Usually a runner just adds role=reviewer to its labels and takes reviews alongside its other work (ADR-0007). |
| Adapter | An agent program the runner can launch (e.g. Claude Code), with a provider and the models it offers, and an optional hold while it is temporarily unavailable. Reported by the runner; names only, never credentials. |
| Tier | small, medium or large — a provider-neutral model size each runner maps to one of its models. |
| Slots | How many runs a runner works on at once, 1–64. Set per runner in Taskbase, else the runner's own config; see Runner slots. |
| Run | One attempt at one task by one runner, always in a fresh agent session. Active while it has no outcome. |
| Lease | How long an active run stays alive without news. Heartbeats renew it; when it runs out the run is lost. |
| Target version | The agent-runner release a self-updating runner should run: its own override, else the instance-wide default. Image runners use their container image instead; see Runner target version. |
| Owner | A Keycloak user who may change and operate a runner, besides global administrators. The creator is the first; see Runner owners. |
| Cap | An owner's or administrator's limit on how much of a subscription's session or week a runner may use; at the cap, claims hold the subscription's adapters. See Usage caps. |
Task dispatch states¶
tasks.dispatch_state is set only for agent work:
| State | Meaning | Enters when |
|---|---|---|
queued |
Available to any runner that can serve it — not assigned to a particular runner | An open task is assigned to an agent (assignee_type = 2); a run is lost; a run finishes with a reason that requeues it, or succeeds without a pull request to review and with a start_after still to come; a human requeues a needs_attention task, or a dispatched task with no active run; the queue sweep's auto-recovery requeues a task it parked, once a runner that could claim it is viable again; or the stuck-review sweep queues the review of a task left dispatched outside Review |
dispatched |
A runner has it | A runner claims it |
needs_attention |
Parked for a human | Its run failed or was cancelled, without a reason that requeues it (or after three such runs in a row — ten for hand-backs, which do not count toward the three); an implementation run succeeds with an unlinked PR, or without a PR in a project with agent review on, or with a reviewable PR whose review rounds are used up — unless the task was marked done during the run; an implementation run succeeds with a reviewable PR its run marked investigation only, in a project with a review persona — unless the task was marked done during the run; or a claim parked an implementation/revision task still assigned to the project's review persona (guard); the queue sweep found a queued task no runner recently seen and running could ever claim, or a queued review in Review that no claim can match; or the stuck-review sweep moved a task left dispatched with a pull request to Review and no reviewer can take it |
| (null) | Not agent work | The task is unassigned, reassigned to a person or marked done — unless it is dispatched with an active run |
A succeeded implementation run with an unlinked PR parks the task as needs_attention even when
agent review is off. With review off and no PR, it stays dispatched. With review
on, a reviewable pull request queues a review run — or parks the task in Review when its review
rounds are already used up (below); no reviewable pull request
parks the task.
A task the agent already marked done during the run stays done and leaves dispatch regardless.
A merge of the recorded implementation
pull request in a linked repository of the same organization completes the task through
Gitea sync.
A task left dispatched with no active run — after such a run, or for any other reason —
is not stuck: a person can requeue it like a needs_attention task, or release it by
unassigning or reassigning it, both described under
control-room endpoints. One case is repaired automatically: a task
whose last run opened a pull request but that sits outside Review is picked up by the
stuck-review sweep.
The task's board column follows the run, matched by name in its project:
| Event | Column | Only if the task is in |
|---|---|---|
| Claimed | In Progress | (always) |
| Implementation run succeeded with a reviewable PR | Review — queued for review, or needs_attention when its review rounds are used up |
(any column; Done wins — a task marked done during the run moves to Done instead) |
| Implementation run succeeded without a PR and with agent review off | Review | In Progress or Review |
| Implementation run succeeded with an unlinked PR, or without a PR and with agent review on | Blocked | In Progress or Review |
Implementation run succeeded with a reviewable PR marked investigation_only, in a project with a review persona |
Blocked | In Progress or Review (Done wins, as above) |
| Run failed or cancelled | Blocked | In Progress or Review |
| Run lost and requeued | Backlog | In Progress |
Run finished with a reason that requeues it (usage_limit, adapter_unavailable, runner_restart) |
Backlog; a review run's task stays in Review | In Progress or Review |
| Requeued by a person | Backlog | Blocked |
| Recorded implementation PR merged in a linked repository of the same organization | Done | (Gitea sync) |
| Review requested changes | In Progress, or Blocked after the last round | Review |
| Review found the branch out of date | In Progress, or Blocked after the third out_of_date in a row |
Review |
The "only if" keeps a card someone moved by hand during a run where they put it; a project without the
column keeps the task where it is. A reviewable pull request is the exception: it always waits in
Review, because a full-body PUT /api/tasks/{id} during the run (for example a follow-up update that
resends the task's Backlog group_id) used to leave the task dispatched in Backlog with no run
(Taskbase #922, fixed in #1007). The moves happen in the same statement as the run's change.
A task counts as done when done is set or it sits in a column named Done;
done tasks are never queued or claimed.
Lifecycle¶
sequenceDiagram
participant CR as Control room
participant TB as Taskbase
participant R as agent-runner
CR->>TB: create runner with name, principal, scope
R->>TB: register with version, update_mode, labels, slots, adapters
loop every 2 minutes
R->>TB: heartbeat with update_mode, state and active runs
TB-->>R: desired state, slots, runs to cancel, target version, lease expiry
end
R->>TB: claim
TB-->>R: run, task, repo, adapter and model
Note over R: fresh workspace and agent session
R->>TB: finish with outcome, summary, PR link
Timings¶
| What | Value | Where |
|---|---|---|
| Heartbeat interval | 2 min | runner (HeartbeatInterval in agent-runner) |
| Heartbeat retry | 15 s after a failed heartbeat, doubling (30 s, 1 min) up to the 2-min interval; a success restores the interval | runner (HeartbeatRetry in agent-runner, v0.5.11+) |
| Lease | 10 min from each claim or heartbeat | runner.LeaseDuration |
| Lease sweep | every 15 s, in every API replica | runner.SweepInterval |
| Shown online | last_seen_at under 3 min old |
runner.OnlineWindow |
| Queue sweep | every 15 s, on the lease sweep's ticker | runner.SweepInterval |
| Queue sweep liveness | last_seen_at under 24 h old |
runner.RecentlySeenWindow |
| Stuck-review sweep | every 15 s, on the lease sweep's ticker; repairs runs finished over 10 min ago | runner.SweepInterval, runner.StuckReviewAfter |
| Unplanned-decision sweep | every 15 s, on the lease sweep's ticker; flags decisions answered 24 h to 30 days ago (Decided, but nothing planned) | runner.SweepInterval, attention.UnplannedAfter, attention.UnplannedWithin |
| Routine sweep | every 15 s, on the lease sweep's ticker; runs routine.Scheduler, which creates the task of each active routine whose next slot has passed (Routines) |
runner.SweepInterval |
| Session-turn claim hold | at most 20 s, then 204 |
runner.MaxTurnClaimWait |
| Session-turn lease | 60 s from the claim and each progress post | session.TurnLease |
| Session-turn run limit | 3 min, then failed as timeout |
session.MaxTurnRunning |
| Unclaimed session turn | expires after 10 min | session.PendingTurnTTL |
Runner and run timestamps (last_seen_at, started_at, finished_at, leases) all come from the API's
clock, never the database's now(), so clock drift between the two cannot make a runner look offline
or a lease expire early.
A runner that goes silent loses its runs within about 10 min 15 s; their tasks return to the queue. The online window leaves room for one missed two-minute heartbeat; the lease survives about four missed heartbeats in a row, and a runner retries a failed heartbeat after 15 s rather than waiting out the interval. The lease was 5 minutes until 2026-10-06, when three runs were lost to two missed heartbeats in a row while their runner kept working, and were restarted from scratch (Taskbase #473). A runner that really died is noticed later, and its restart recovers its runs (see ADR-0011 decision 3).
Unclaimable-queue sweep¶
After each lease sweep, the same ticker runs Sweeper.SweepQueue, which parks every queued task
that no runner could ever claim as things stand (#289). Only viable runners count: recently seen
(runner.RecentlySeenWindow, 24h) with desired_state = running — a paused or draining runner claims
nothing until someone resumes it, even if it is the only one that could serve the task. RecentlySeenWindow
is far looser than OnlineWindow (3 min, above), which only gates whether a runner may claim
work right this moment: a runner missing a heartbeat, restarting, or draining for a self-update is routine
and no longer parks its queued tasks on its own; only a runner silent for a full day does (#315).
A task is left in the queue if some viable runner could claim it apart from what clears by itself:
the claim's scope, required-label, dedicated-label and model checks are applied, but a full set of
slots and a held subscription or adapter — a limit, a
usage cap or an adapter hold — are ignored — the model only has to be
offered by one of the runner's adapters, held or not. The candidates are the tasks the claim query
would consider (queued, not done, no active run, not waiting on a
depends_on target, the run that created it or
its start time, review rounds and pull request as under
Requeue and exhausted rounds), each with the labels and model its
run would use: the project's review labels and model for a review, otherwise the task's own, shifted
by its escalation.
A task no viable runner can claim gets dispatch_state = needs_attention and a dispatch_reason
naming the first check every viable runner fails (unchanged since #289/#301, reused as-is below):
| Cause | dispatch_reason |
|---|---|
| No viable runner at all | No runner is currently online to claim this task. |
| None is scoped to the task's organization | No online runner is scoped to this task's organization. |
| None has every required label | No online runner offers every label this task requires. |
| Each one that has the labels is dedicated to a label the task does not require | No online runner reserved for this task's dedicated label is online. |
| None offers the task's model or tier | No online runner offers the required model "<model>". — or, when the task names no model, No online runner has a usable model configured. |
These messages still read "online" for historical reasons; the check behind them is the looser
recently-seen-and-running test above, not OnlineWindow.
Reviews no claim can match (Taskbase #1634): before the runner check, the sweep parks every
queued direct review in Review (a review persona is set, not a legacy review_of_id review, not
done, no active run) that fails the eligibility under
Requeue and exhausted rounds, whichever path queued it — for
example a review at the last round lost or requeued for the fourth time without a verdict. It sets
dispatch_state = needs_attention, dispatch_reason to the requeue's message, and raises a
task.needs_attention event with that message as detail:
| Cause | Event reason | dispatch_reason |
|---|---|---|
| Rounds used up | review_rounds_exhausted |
"All <max_rounds> review rounds are used. Raise the project's review rounds, or move the task to In Progress for another implementation run." |
| No implementation run with a reviewable pull request | no_pull_request |
"This task has no implementation run with a pull request to review. Move it to In Progress for an implementation run first." |
So the whole queue is only parked once every runner that could ever serve it has been silent for a
full day, or paused or draining throughout. The task's board column is not changed, and no run is
created. Rows a concurrent claim or sweep holds are skipped (FOR UPDATE SKIP LOCKED), so the sweep
can run in every API replica.
This is not the same check as the one under Requeue and exhausted rounds. That check looks at the task itself (rounds used, no pull request), refuses the requeue and leaves the task where it is. The sweep's runner check looks only at the runners: the task itself is eligible, but no viable runner can take it. Only its safety net for reviews no claim can match, above, applies the task check.
Auto-recovery (#315): the same sweep also looks at needs_attention tasks it parked itself —
identified by matching dispatch_reason against the reasons above (sweepParkedReason in
match.go), never a task parked for an unrelated cause such as a failed run, a blocked review, or
the review-persona guard — and requeues (clearing
dispatch_reason) any task a viable runner can now claim. It also requeues a review parked in
Review with the rounds-used-up message above, from any path that parked it, once the project's
max_rounds has been raised so the claim's eligibility matches again and a viable runner can claim
it (Taskbase #1634). A review parked with the no-pull-request message is not recovered this way.
Requeueing leaves needs_attention, which resolves the task's attention events. A person can still
requeue a parked task by hand at any time; the sweep just means a runner
coming back no longer needs one.
Stuck-review sweep¶
On the same ticker, Sweeper.SweepStuckReviews is a safety net for a task that a succeeded
implementation run with a pull request left dispatched outside Review (#1007). Since #1007 the
run finish moves such a task to Review from any column, so the sweep only
catches what slips past it. It picks every task that is
dispatched, not done, not a legacyreview_of_idreview, and in neither the Review nor the Done column;- without an active run; and
- whose newest run is a succeeded implementation run with a linked
pr_url(pr_unlinked = false) that finished more than 10 minutes ago (runner.StuckReviewAfter).
Each one is moved to the project's Review column (a project without one keeps the column) and:
| Project | Result |
|---|---|
| Has a review persona and the task has review rounds left | queued for its review run |
| Has a review persona, no rounds left | needs_attention, task.needs_attention event with reason review_rounds_exhausted, and dispatch_reason set to the requeue's rounds message |
| Has no review persona | needs_attention, task.needs_attention event with reason pull_request_unreviewed ("Pull request left without a reviewer") |
The event links the pull request and its detail names the run and says what happened — the task
was left dispatched outside Review — and what to do: review and merge the pull request, or review it
yourself when the rounds are used up. dispatch_reason is cleared, except for a task parked
because its rounds are used up: it gets the requeue's rounds message, so the
queue sweep requeues it once the project's rounds are raised (Taskbase #1634). Every repair is logged as a
warning, runner: task left dispatched after its run opened a pull request, moved to Review and
review queued (or … and parked, with the reason), with the task, run and PR URL. Rows a concurrent
claim, finish or sweep holds are skipped (FOR UPDATE SKIP LOCKED), so it can run in every API replica.
Runner endpoints¶
Called by agent-runner as its own Keycloak user. That user needs no
organization grants: each endpoint checks the caller is the runner's
principal. Service API keys are refused. Bodies reject unknown fields at any depth, so
nothing secret can be slipped into what Taskbase stores.
POST /api/runners/register¶
Registers a runner that was created in the control room.
{
"name": "home-1",
"version": "v0.1.0", "update_mode": "self", "os": "linux", "arch": "amd64",
"labels": ["gpu", "os=linux", "arch=amd64"],
"slots": 1,
"adapters": [
{ "name": "claude", "provider": "anthropic", "models": [
{ "id": "claude-haiku-4-5", "tiers": ["small"] },
{ "id": "claude-sonnet-5", "tiers": ["medium"] },
{ "id": "claude-opus-5-5", "tiers": ["large"] } ] }
],
"default_model": "small",
"dedicated_label": "",
"limits": [
{ "subscription": "claude", "provider": "anthropic", "status": "allowed_warning",
"as_of": "2026-09-26T10:41:13Z", "limited_until": null,
"windows": [
{ "name": "session", "length_seconds": 18000, "used": 0.55, "resets_at": "2026-09-26T14:30:00Z" },
{ "name": "week", "length_seconds": 604800, "used": 0.95, "resets_at": "2026-09-28T20:00:00Z" } ] },
{ "subscription": "claude-api", "provider": "anthropic", "status": "allowed",
"as_of": "2026-09-26T10:41:13Z", "limited_until": null, "use_first": true,
"windows": [
{ "name": "credit", "used": 0.25, "resets_at": "2027-01-01T00:00:00+01:00",
"spent_usd": 2.0, "credit_usd": 8.0 } ] }
]
}
An adapter may also carry hold: {reason, detail, until?} (amended 2026-10-04,
ADR-0006, Adapter availability holds):
reason is auth_failure (a failed provider login — no until, since it lifts on recovery rather
than at a time) or fast_failures (the circuit breaker; until ten minutes out), detail is capped
at 256 bytes. The adapter's models stay listed, so Taskbase can still give a task to another adapter
serving the same tier; a held adapter is excluded from claim resolution exactly as a held subscription
is, and the hold shows on the runner's card.
limits are the runner's subscriptions' limits as the provider last reported them
(ADR-0008): used is a fraction of each
window, as_of when the provider said so — a run's own report, or a
probe between runs
— status one of allowed,
allowed_warning or rejected, and limited_until set while the runner holds the subscription back
after hitting a limit or with too little of its session left
(proactive session hold). Each report replaces the stored limits; a report without them clears them. The
Runners view shows a bar per window with its reset time.
Three fields are optional and left out of the JSON when unset (Taskbase PR #588, task #1640;
Limit and Window in api/internal/runner/limits.go, read 2026-10-25):
| Field | On | Meaning |
|---|---|---|
spent_usd |
a window | Dollars spent in the window, ≥ 0. |
credit_usd |
a window | The window's credit in dollars, > 0. |
use_first |
a limit | true when the runner sends its provider's runs to this subscription before the others; left out when false. |
A Claude API key subscription such as claude-api in the example above has one
window, credit: used is spent divided by credit (0 without a credit amount), resets_at is the
credit's expiry, and there is no length_seconds. Usage caps do not apply to it.
An adapter may also carry models_source: "taskbase" when its models are an
override set in Taskbase, "config" when they come from the runner's own
agent-runner.yaml. Runners that predate overrides leave it out. Claims always match on the models
the runner reports, never on the stored override.
update_mode is optional in registration and heartbeat reports: "self" (also the
default when omitted) means the runner updates itself; "image" means its version comes
from its container image tag. Any other value is a 400 invalid report.
An optional session_turns: true says the runner answers session turns; runners
that predate it, or cannot answer turns, leave it out and are never handed one.
An optional features lists abilities only some runner versions have, as tokens: at most 32, and
a repeated one is kept once (task #1666, report.go, read 2026-10-26). Each report replaces the
stored list, runners.features. The only feature Taskbase reads is claude_api_remote: the runner
takes its Claude API key from Taskbase.
slots is the number of runs the runner takes at once as it stands, and the optional
slots_source says where that number came from: "taskbase" when it applies the
slots set in Taskbase, "config" when it uses its own agent-runner.yaml.
Runners that predate it leave it out.
An optional update_error reports the runner's last failed self-update:
"update_error": { "version": "v0.2.0", "error": "checksums.txt signature does not match the public key",
"retry_at": "2026-10-05T14:05:00Z" }
An optional machine reports the load of the runner's machine:
"machine": { "load": [3.1, 2.9, 2.7], "cpus": 10, "memory_free_pct": 85,
"disk_free_bytes": 79456894976, "disk_total_bytes": 244813135872,
"as_of": "2026-10-06T09:30:00Z" }
200 with the runner, plus target_version — its effective target,
omitted when there is none or update_mode is "image" — so a freshly started self-updating
runner learns it before its first heartbeat — and
models, its model overrides per adapter, omitted when there are none ·
404 no runner with that name · 403 created for
another user · 400 invalid report (slots outside 1–64, unknown tier, duplicate
adapter, default_model that no adapter offers, a dedicated_label that is not one of
the labels, more than 8 subscriptions or 8 windows, used outside 0–1.5, a spent_usd below 0 or a
credit_usd of 0 or less (either above 1e9), an unknown status, a
models_source or slots_source other than taskbase or config, an update_error without version or error, a machine outside the limits, …).
POST /api/runners/{id}/heartbeat¶
The report fields above plus state (idle | busy | draining |
updating) and active_runs. Renews the leases of the reported runs
that are still this runner's active runs. Each entry of active_runs is a run id, as runners
that predate ADR-0011 send it, or {"id": 412, "subscription": "claude"},
naming the subscription the run uses; a reported subscription replaces the run's
task_runs.subscription (Runner slots).
The optional claude_api_state reports the Claude API key and settings the runner has applied,
whether delivered by Taskbase or changed on the machine (desktop Claude API key…,
agent-runner secrets set anthropic, or a config edit). It never contains the key. See
Reported Claude API state for its fields and the runner view.
{ "desired_state": "running", "cancel_runs": [412], "target_version": "v0.6.0", "slots": 2,
"models": { "claude": [ { "id": "claude-opus-5-5", "tiers": ["medium", "large"] } ] },
"lease_expires_at": "2026-09-24T12:02:00Z" }
slots is the number of slots set in Taskbase, omitted when none is set; the
runner then uses its own config. A runner that reports session_turns also gets session_slots,
its effective number of session slots (the one set in Taskbase, else 1). models carries the runner's model overrides, as in the register answer, and is
omitted when there are none. The runner uses its own config for any adapter not listed.
caps carries the runner's usage caps, in the same shape as runners.caps, for
example "caps": {"claude": {"session_max": 80, "week_max": null}}, and is omitted when the runner
has none (Taskbase PR #665, task #1910).
cancel_runs lists runs to stop: those the control room asked to cancel, and
reported runs that are no longer this runner's active runs (e.g. already lost).
target_version is a self-updating runner's effective target — its
override, else the instance-wide default — and is omitted when neither is set or update_mode
is "image". When it differs from the runner's own version, the runner updates itself to it,
older releases included
(ADR-0006, Self-update).
Claude API key in the heartbeat¶
The fields that carry a Claude API key set in Taskbase to the
runner (task #1666, api/internal/runner/claude_api.go and agent_api.go, read 2026-10-26;
agent-runner task #1667 implements the runner's side).
The answer carries claude_api while a change waits for the runner, either to apply:
"claude_api": { "generation": 7, "key": "sk-ant-…", "credit_usd": 8, "expires": "2026-12-31", "use_first": true }
or to remove the key and the settings:
| Field | Meaning |
|---|---|
generation |
Identifies the change. Generations only grow and never repeat, also across removals. |
key |
The new key. Left out when no new key waits: the runner keeps the key it has. |
credit_usd, expires |
The settings for the runner's claude_api config block; each left out when not set. expires is the last day the credit may be used, YYYY-MM-DD. |
use_first |
Always sent with an apply. |
remove |
true: delete the key and the claude_api settings. Only generation comes with it. |
claude_api is sent on every heartbeat until the runner acknowledges that generation, and only
to a runner whose report includes features: ["claude_api_remote"]. It is left out when no change
waits, and also when a waiting key cannot be decrypted (no TASKBASE_SECRET_KEY, or a failed
decryption); the API then logs an error without the key, and the key expires after 7 days.
The runner answers in a later heartbeat request with claude_api_ack, for example
{ "generation": 7, "status": "applied" } or:
status is applied or rejected; any other value, a missing generation or a rejection without
reason is a 400. A reason longer than 512 bytes is cut there; an applied answer's reason is
dropped. An acknowledgement of an older generation changes nothing.
POST /api/runners/{id}/incidents¶
Files a DR run report as an incident task (task #1463, ADR 0020 §6).
While Taskbase is down, a local DR session writes its run report on the ops runner. Once Taskbase is
back, agent-runner sends the report here. It calls outside any run, with the runner's own login and
no organization grant. Like heartbeat, the caller must be the runner's principal.
{ "title": "DR session: restored taskbase-db",
"key": "2026-10-24T03:15:00Z.md",
"report": "## Run report\n\nRestored the cluster from the 03:00 backup.\n" }
| Field | Rule |
|---|---|
title |
Required, at most 200 bytes after trimming spaces |
report |
Required, not blank; Markdown |
key |
Required, at most 200 bytes after trimming, no control characters. The report's file name |
The new task:
- kind
incident, in the Backlog of the project linked toSkatzi/platform; - assigned to
operatoronlarge, efforthigh,required_labels: ["role=ops"]— the same route as breaking dependency updates (opsRouteinapi/internal/task/dependency.go). Every task foroperatorgets this model and label, not only the ones Taskbase routes itself (Skatzi/taskbase#581); - priority high;
- the report as its description, followed by the line
Reported by runner
<name>from its DR run report<key>.; - no row in
incidentsand no Gitea issue.
Taskbase keeps one task per runner and key in incident_reports.
A repeated call with the same key creates nothing and returns the first task unchanged, even when
its title or report differ. Two calls at the same moment also end with one task.
| Status | When |
|---|---|
201 |
The new task |
200 |
The task an earlier call with this key created |
400 |
Invalid body: a field missing or too long, an unknown field, or over 1 MiB. Checked before the runner |
403 |
The caller is not the runner's user, is an API key, or the runner does not report the label role=ops. A repeat with a known key is refused too |
404 |
No such runner |
422 |
No project is linked to Skatzi/platform, or it is not in one of the runner's organizations (an instance runner serves them all) |
503 |
Incident reports are not configured; the API server always configures them (api/cmd/server/main.go) |
Sources, read on 2026-10-24 on Skatzi/taskbase main 08537ab: api/internal/runner/incident_reports.go,
api/internal/task/incident_pg.go (CreateReportIncident), the OpenAPI operation reportRunnerIncident.
POST /api/runners/{id}/claim¶
Takes one task. 204 when there is nothing to do — the runner is paused or
draining, its slots are full (the number set in Taskbase, else the one it reports), it offers no available models, or nothing matches. Otherwise
200:
{
"run": { "id": 412, "task_id": 7, "role": "implementation", "adapter": "claude", "model": "claude-haiku-4-5",
"preferred_models": [], "model_choice": "tier", "effort": "high", "lease_expires_at": "…" },
"task": { "id": 7, "title": "…", "description": "…", "model": "small", "effort": "high",
"required_labels": [] },
"project_name": "Taskbase",
"organization_id": 1,
"persona_slug": "developer",
"repo": { "owner": "Skatzi", "name": "taskbase" },
"persona": "# Developer\n\nYou implement tasks…",
"review": null,
"revision": null,
"digest_candidates": [],
"decision_candidates": [],
"open_decisions": [],
"attachments": [
{ "id": 31, "task_id": 7, "comment_id": null, "in_description": true, "name": "screen.png",
"mime": "image/png", "size": 48213, "sha256": "…", "created_by": "…", "created_at": "…",
"url": "/api/runs/412/attachments/31" }
],
"epic": { "id": 12, "title": "Agents know why a task exists", "description": "…" },
"milestone": { "id": 4, "title": "Q4 agent context", "description": "…", "due_date": "2026-12-31T00:00:00Z" },
"organization": { "id": 1, "summary": "Skatzi builds and runs…" }
}
With agent review, a role: "review" run stays attached to the original task;
review is { "of_task": { …the task under review… }, "pr_url": "…", "round": 1 }. revision
is set on an implementation run whose pull request came back from review —
{ "pr_url": "…", "feedback": "…the reviewer's summary…", "round": 1, "verdict": "changes_requested" }:
push fixes to the same branch instead of opening a new pull request. verdict is always set:
changes_requested, or out_of_date for a merge-only run — merge the base branch into the pull
request, resolve the conflicts keeping both sides' changes, and change nothing else.
Both review and revision also carry "pr": { "owner": "Skatzi", "name": "platform",
"number": 42, "clone_url": "…" } for a Gitea pull request. This identifies the repository
to check out, which may differ from the task's repository in repo. pr is null when pr_url
is not a Gitea pull request link.
run.model is the model the claim chose, run.preferred_models the task's preferred models at
claim time (empty for a review), and run.model_choice how the model was chosen: preferred,
fallback or tier (see Preferred models).
Attachments in a claim¶
The claim's top-level attachments[] contains saved images from the task description and its
comments, excluding deleted comments. Each attachment has a url of the form
GET /api/runs/{id}/attachments/{aid}. Only the runner that owns the run may fetch it, and only
before the run has an outcome; afterward the endpoint returns 409. Older runners ignore the
claim field. The task image routes describe upload and binding.
Source: api/internal/runner/task_attachments.go and api/internal/runner/agent_api.go in
Skatzi/taskbase main at 047a302a46f8ea4f05ad8e55c4206247f0bc6a46, reported in task
1861 (read 2026-10-28).¶
project_name, organization_id and persona_slug are display metadata for the runner's
status displays, such as the desktop app's status window. The two project fields are set whether or
not the project is linked to a repository (repo is null when it is not); organization_id is what
a Taskbase task deep link needs alongside the task's project_id and id. persona_slug names the
persona the run acts as: the task's active agent assignee for an implementation or revision run, or
the project's configured review persona for a review run. It is null whenever no active persona
resolved, as persona is then. It is separate from persona, the prompt body below, so a
status display can name the persona without handling the prompt.
Images in the claim¶
Every claim carries attachments, the task's saved images: those of its description and those of
its comments that are not deleted, ordered by id (Taskbase #1828,
PR #659,
api/internal/runner/task_attachments.go). It is [] when the task has none, never null, and
never holds an unsent upload. Each entry:
| Field | Shape |
|---|---|
id |
attachment id |
task_id |
the task |
comment_id |
the comment the image is on; null for a description image |
in_description |
true for a description image |
name |
file name, at most 200 characters |
mime |
image/png, image/jpeg, image/webp or image/gif, sniffed from the bytes |
size |
bytes, at most 5 MB |
sha256 |
hex SHA-256 of the bytes |
created_by, created_at |
uploader and upload time |
url |
/api/runs/{run}/attachments/{id}; set only in a run claim |
Taskbase allows at most 4 images per description or comment, 12 unsent uploads per person per task and 100 uploads per person per day.
GET /api/runs/{id}/attachments/{aid} is each attachment's url ({id} the run, {aid} the
attachment), and serves the image's bytes. Only the runner the run is on may read it (403 for
another runner), only while the run is active (409 before it is claimed and once it has an
outcome), and only a saved image of the run's task (404 otherwise; also 404 for an unknown run).
A malformed id is 400. The 200 answer has the same headers as a session-turn image:
Content-Type, Content-Length, Content-Disposition: inline,
Content-Security-Policy: default-src 'none', X-Content-Type-Options: nosniff,
Cache-Control: private, max-age=3600 and ETag: "<sha256>".
agent-runner sends the images to the agent from task #1831 on
(agent-runner PR #293,
internal/adapter/runimages.go):
- Selection. Description images first, then comment images, newest comment (highest
comment_id) first; at most 8 images and 20 MB in all, which keeps Claude's base64 request under the API's 32 MB limit. An image that does not fit is skipped and smaller ones may still be taken. The chosen images go in the claim's order; the runner logs how many it left out and the prompt says so. - Review runs get none. A review claim's images belong to the review task, not to the task under review. An adapter command that cannot take images gets none either.
- Download. Each image is fetched from its
urlinto the workspace'simages/directory and checked againstsha256. A failed download or a mismatch fails the run withimages: …. - Delivery. Claude (
claude-stream-jsonoutput) gets one stream-json user message on stdin, the images as base64imageblocks before the prompt text, with{prompt}replaced by--input-format stream-json. Codex (codex-jsonoutput) gets--image=<file>per image before the argument holding{prompt}; the=form keeps Codex from reading the prompt as another image.
Older runners ignore attachments. Session turns have their own images and route
(Session turns).
Epic, milestone and organization in the claim¶
Every claim, whatever the run's role (implementation, revision or review), says why the task exists
(Taskbase #1738, api/internal/runner/claim_context.go, read 2026-10-26):
| Field | Shape | null when |
|---|---|---|
epic |
{id, title, description}, the task's epic |
the task has no epic |
milestone |
{id, title, description, due_date}, the task's milestone; due_date is the milestone's end_date, an RFC 3339 timestamp or null |
the task has no milestone |
organization |
{id, summary}; summary is the organization's description |
the organization has no description |
- Capped text. Each
descriptionandsummaryis capped at 2,000 characters (runes). A longer one is cut there and ends with\n\n…truncated(MaxClaimContextChars,TruncatedMarker). - Same organization only. An epic or milestone of another organization than the one of the
task's project (
organization_id) is never sent: the field isnull. - Best effort. A failed lookup, say of an epic deleted meanwhile, is logged and leaves the field
null; the claim still succeeds.
Runners that do not know the fields ignore them. agent-runner task #1739 puts them into the agent's prompt; it was not merged when this was written.
The team in the project manager's claim¶
A claim whose persona_slug is project-manager also carries roster, the organization's
team as
[{persona, title, reports_to, may_assign, active}], so the project manager routes work from data
(task #1766). It is null for every other persona. Unlike the context above it is not best effort:
a roster that cannot be read fails the claim with 500.
Run context reuse¶
Taskbase stores an optional, immutable handoff digest on a finished run in task_runs.digest
(migration 031). Its neutral fields are changed file paths, PR URL and head commit, decisions with
reasons, verification results, open questions or blockers, options for the person (up to 16
strings of at most 512 bytes, recommended first; the run's
attention events keep the first 4), needs_person (why only a
person can act, one of five reasons; any other value answers 400, see
Only a person can act), investigation_only (true when the
run's pull request holds only an investigation, see Investigation-only runs),
and source run id and time. A digest may
accompany an unsuccessful run when the runner has useful handoff information. A second finish or
later edit cannot replace it; a digest over the field or total size limits is rejected. People can
read digests in run history; they are not writable through MCP.
Claims expose same-task candidates in digest_candidates with provenance: implementation and
revision runs receive the latest implementation and review digests; review runs receive the latest
implementation digest. Taskbase verifies that the source run belongs to the task and is readable by
the caller. It returns structured data rather than building prompt text.
The runner's intended rendering is a clearly labelled prior-run note after the persona and repository instructions and before the current task details. Its total imported-context budget is 2,000 model-input tokens per claim, including up to 900 for same-task context, 700 for one explicit predecessor when links are available, and 400 for provenance and freshness; unused space can be reassigned. Transcripts, full summaries, diffs and linked task descriptions are not imported, and truncation is marked. The runner checks the current PR, recorded head and touched files against the fresh clone: stale digests retain only file pointers and open questions; unverified digests are reduced to provenance and file pointers. Digests from another branch are not reused. Current repository state, task text, PR facts and review comments take precedence.
Digest storage, typed task links (migration 036, Taskbase PR #109)
and the runner's digest production, rendering and freshness checks
(agent-runner PR #69) are all merged.
Besides the same-task digests, a claim adds at most one linked-predecessor candidate: the latest
digest of a finished run on a task the claimed task links to as follow_up_of or depends_on, in
the same organization, carrying that link_type. relates_to and duplicates links import no
context. relates_to and duplicates are symmetric, while depends_on and follow_up_of are
directional (follow_up_of points from the new task to its predecessor). depends_on also holds
the task back in claims (Dependencies); the other kinds do not schedule work. People
and the project-manager persona can edit links when they can read both tasks. Other agents can create
a follow_up_of or depends_on link only from a follow-up task their run created
(tasks.created_by_run_id), so a follow-up that must wait for the current change can be queued at
once; the run can also pass them when creating the task
(Links on create), which is preferred. Cross-project links require access to both tasks. depends_on and relates_to may also join
two organizations when the caller reaches both, but agent runs, project-manager included, may not
create such links (Task links). The imports above stay within one
organization: a cross-organization predecessor contributes no digest or decision.
Decisions in the claim¶
A decision task a person answered has no run and so no digest. The
claim carries its decision as structured data instead, and never changes task.description:
- The claimed task's own decision is in
task.decision({question, summary, options, choices, answer, owner_only}, ornull;choicesonly for a decision with structured options,owner_onlyonly when set), for example when a person answers a decision and hands the task to an agent. The claim'staskis the task as the API returns it (ClaimResponseinapi/internal/runner/agent_api.go, read 2026-11-18). decision_candidatesholds at most one answered decision of a predecessor the claimed task links to asdepends_onorfollow_up_of, in the same organization (the one with the highest task id when several qualify):{task_id, link_type, question, answer, truncated}. The question is cut to 800 and the answer to 1,600 characters (runes), each ending in[…truncated]when cut, andtruncatedis thentrue. Together about 600 tokens, it fits inside the 700-token predecessor allowance, which it shares with a predecessor digest.open_decisionslists people's open decisions that wait on the claimed task's results: decision tasks assigned to a person, not done and not answered, thatdepends_onthe claimed task, in the same organization. Each is{task_id, title, question, options}, at most 5; a decision with structured choices lists each as "label — description" (Decision.OptionTexts). It is empty for review runs. The run's agent fills in their options before it finishes:get_task, thenupdate_taskwith the question kept,decision.summaryanddecision.choicesset from its findings (2–4, the recommended one first and marked) and the key findings added to the decision task's description (Planning decisions).
Both lists are [] when empty. agent-runner renders them in the prompt (agent-runner #463 and
465, on main after v0.5.10): the task's own answered decision as a Decision section with the¶
task details, a predecessor's answer in the prior-run note ahead of any predecessor digest, and open decisions as Open decisions waiting on this task, with the current options to refine.
A task is claimable by a runner when it is queued and not done, has no depends_on target that is
not done (Dependencies), is not held by the run that created it, is in the
runner's scope, carries only labels the runner has, requires the runner's
dedicated label if it has one, and names a model the runner offers (or none). The highest priority wins, then the lowest id.
Dependencies¶
A task with a depends_on link to a task whose done is not set is not claimable
(ADR-0011 decision 5, which replaced the earlier rule that depends_on is only
descriptive). It waits in the queue, in any slot count and on every runner, until its target is
done; then the next claim can take it. Only depends_on holds a task back: follow_up_of,
relates_to and duplicates do not. The unclaimable-queue sweep does not
count such a task as one no runner can claim, so it is not parked; a sweep-parked task that has since
become blocked is still requeued, to wait like any other.
When the target is a person's open task, Taskbase raises it on Needs attention as
blocking_agent_work — or decision_needed for an unanswered decision task — and moves it to the
project's Blocked column, so the wait is visible
(Person tasks).
Blocking does not depend on organization: a depends_on target in another organization
(Task links) holds the task back the same way, and its
blocking_agent_work event belongs to the blocker's organization, with only the waiting task ids in
its payload.
Held by the run that created it¶
A task an agent creates inside a run (tasks.created_by_run_id) is not claimable while that run has
no outcome (Taskbase PR #488, task
1137). So the depends_on and follow_up_of links the run adds after creating the task exist¶
before any runner takes it. Any outcome releases the hold — succeeded, failed, cancelled or
lost — and the next claim can take the task, unless a depends_on target still holds it.
- Claim and sweep. The claim query passes over a held task, and the
unclaimable-queue sweep does not count it as unclaimable, the same as a
task waiting on a
depends_ontarget (heldByCreatingRunSQLandwaitingSQLinapi/internal/runner/store_pg.go, read 2026-10-18). held_by_run. While the hold lasts, an open agent task (assignee_type = 2, not done) carries the read-onlyheld_by_run: the id of the run that created it. It is omitted otherwise.- Board. A
queuedtask withheld_by_runshows the dispatch badge "Waiting for the run that created it" instead of "Queued"; hovering names the run. - Organization queue. The Queue tab has no hint for the hold:
waiting_onlists onlydepends_ontargets.
Passing the links when creating the task (Links on create) stores them with it, so the hold is a safety net for links added afterwards.
Start after¶
A queued task whose start_after (schema) is still to come is not
claimable (task #2405, taskbase#689,
merged 2026-11-04). Once the time passes it is an ordinary queued task, and the next claim can take
it. There is no scheduler: nothing wakes the task, the claim just stops passing over it. The other
holds still apply on top, so a task past its time that still waits for a depends_on target, the
run that created it or a pause is not claimed yet. A NULL start_after, or one in the past, holds
nothing.
- Claim and sweep. The wait is part of
waitingSQLinapi/internal/runner/store_pg.go, besidedepends_on, the creating run and pauses, so the unclaimable-queue sweep does not count a waiting task as one no runner can claim and never parks it. - Setting it. On task create and
PUT /api/tasks/{id}, and on requeue (Start after); the MCP tools carry the same (MCP server). A task alreadyqueuedcannot be requeued (409), so to start a waiting task at once, clear its time withPUT /api/tasks/{id}("start_after": null) orupdate_task(clear_start_after). - From a run. A succeeded implementation run without a pull request to review, whose handoff
digest sets
start_afterto a time still to come, queues its task again to start then, and raises no Needs attention item (finish). agent-runner forwards the handoff'sstart_after(agent-runner task #2457, agent-runner#329), so a run that must wait ends instead of waiting inside its timeout. - Board. While
start_afteris still to come, the task's card and dialog show "Starts 7 Nov 04:00", in the viewer's time zone. The dialog has a Start after field and Requeue after…, the board a Waiting to start list of the waiting tasks, and a parked agent task's Needs attention item a Requeue after… action (Requeue after a time).
Sources: the MCP tool descriptions of create_task, update_task and requeue_task, and the
start_after field get_task returns, read 2026-11-05; the claim, sweep and board behaviour from
the task #2405 description and taskbase#689, whose code was outside this writer's read scope.
Open questions:
- Whether the organization queue shows the wait: its
waiting_onlistsdepends_ontargets, and this writer could not read whether it, or the Queue tab, namesstart_after.
Paused roles and organizations¶
The claim also passes over a task whose organization's agent work is paused, or whose assignee's
role in the organization's team is not active (task.PausedSQL, part of waitingSQL; task #1765).
The task stays queued, the sweep does not park it, and the next claim after resuming takes it. The
task carries paused and the board names the pause. See Pause.
When the task names a tier, the claim first shifts it up by the task's model_escalation
(0–2, capped at large) and resolves the adapter and model against the shifted tier
(ADR-0007); an explicit model id
never shifts, since there is no tier to move. The shifted tier or id is recorded as the run's
requested_model, as below; escalated_from names the task's own tier when the claim shifted it,
so the run history can read "medium (escalated from small)", and stays null otherwise.
The run also carries effort — low, medium or high — the task's reasoning effort when it was
claimed, and omits it when the task has none, leaving the runner's default
(Taskbase PR #231). Effort is
provider-neutral, beside model (the size), and not a claim requirement: any runner may take the
task. The runner maps it to its adapter's effort_args; an adapter without them runs at its
program's default (ADR-0006). It applies to
implementation and review runs alike: a review run carries the task's effort too.
The adapter and model are resolved from the task's model (shifted, above), or the assigned persona's
default_model (same organization) when the task names none, or the runner's
default_model when the persona has no default: the first adapter, in reported order,
offering that model id or tier whose subscription is not held. The subscription
is the adapter's optional subscription name, falling back to its adapter name
when omitted. A subscription is held when its reported limit has limited_until
strictly after the API's current time, or when an administrator's usage cap on its
session or week window is reached before that window's reported reset — the session counting
5 percentage points for each run already in progress on the subscription; status or utilization
alone does not hold it. All adapters sharing that subscription are skipped. An adapter carrying its
own unexpired hold is skipped too, on its own.
A subscription is also held on one runner after that runner finishes a run on it as failed
with reason usage_limit: its adapters on the run's subscription are skipped for claims and
session turns until the runner's next heartbeat, whatever limits it last reported. The
heartbeat carries the runner's current limits and replaces this hold
(Taskbase #929). Without it, a runner
whose report still showed room could claim again straight after handing a run back, and hand that
one back too (agent-runner #928). The runner's UsageLimited lists these subscriptions — runs on
the runner finished failed/usage_limit after its last_seen_at.
For example, if Claude and Codex both offer small and Claude is held, a small
task runs on Codex. Reported order remains the preference whenever both are
available. An explicit model id is never replaced with a different model: if only
held adapters offer it, the task stays queued. The same applies to an explicit persona
default_model or runner default_model. A runner without a default uses its first available model.
When the task's organization has a minimum_model (task #2901), the claim first raises a tier
below it to that minimum, whether the tier comes from the task, its persona's default_model or,
for a review run, the project's review model, and records the tier it raised in the run's
model_raised_from. Model escalation then shifts up from the raised tier. A
model id is never raised. Task writes are raised by the database as well
(database schema), so the claim mostly catches tasks stored before the
minimum was set and persona or review defaults.
The same resolved model is used for the run, the unclaimable sweep's model check, the run's
requested_model and escalated_from fields, and model_escalation calculations. Review runs
use the project's review_model instead, with the same tier-shift logic.
If all matching subscriptions are held, no run is created and the task stays
queued for another runner or until a hold expires. Holds expire by time alone,
even before the next heartbeat — except the hold after a usage_limit run, which the next
heartbeat ends. Memory and PostgreSQL claims use the same
availability filter, including the project's model for review runs. Adapters, limits and
caps are all stored on the runner's row.
Concurrent claims never hand out the same task (FOR UPDATE SKIP LOCKED, with
a partial unique index on active runs as the backstop), and a runner's slots
hold under concurrent claims (its row is locked). The claim records the run's subscription in
task_runs.subscription — the adapter's subscription, else its name.
Review-persona assignment guard¶
Before resolving the claim itself, it parks every other queued, not-done
implementation or revision task that is still assigned to its project's
review_persona (assignee_type = 2, assignee the persona) and that this
runner could otherwise claim — same organization scope, required and
dedicated labels, and model, with no active run on it. This can only happen
to a task assigned to the review persona before review was turned on for the
project, or reassigned there by mistake: creating or updating a task this way
is refused outright (see MCP Server).
Parking sets dispatch_state = needs_attention, a dispatch_reason such as
"The project review persona cannot implement this task. Reassign it to an
implementation persona; move the task to Review to start a review.", and
moves the task into the project's Blocked column if it has one — no run is
created for it. Rows a concurrent claim already holds are skipped (FOR
UPDATE SKIP LOCKED) and left for a later claim to catch.
A task sitting in a Review column (a direct review run) and legacy review
tasks (review_of_id set) are exempt and keep using the review persona as
designed. Editing the parked task clears dispatch_reason, but
dispatch_state only leaves needs_attention through
requeue: reassign it away from the review persona,
then requeue it to send the task back to the queue.
persona is the body of the persona the task is assigned to — assignee as a
slug of the task's organization in agent_types — or null when the task names
no active persona.
POST /api/runs/{id}/finish¶
{ "outcome": "succeeded", "summary": "Added rate limiting", "pr_url": "https://gitea.prod.skatzi.com/…/pulls/42" }
outcome is succeeded, failed or cancelled (lost is only set by lease
expiry). A run may add usage — what it used, as far as its runner can tell
(ADR-0008):
{ "usage": { "input_tokens": 1200, "output_tokens": 300, "cache_read_tokens": 50000,
"cache_write_tokens": 4000, "turns": 7, "cost_usd": 0.12,
"models": [ { "model": "claude-haiku-4-5", "input_tokens": 1200, "output_tokens": 300,
"cache_read_tokens": 50000, "cache_write_tokens": 4000, "cost_usd": 0.12 } ] } }
Every field is optional; one left out is unknown, and a run without usage keeps usage: null — never
zeros. cost_usd is as the provider reports it (for a subscription an API-equivalent figure). Numbers
must be non-negative and within sane bounds, with at most 16 models.
A failed run stopped by a subscription's usage limit adds "reason": "usage_limit". Its task goes
back to the queue (In Progress → Backlog) instead of Blocked — unless its last three runs all
stopped at a limit, when it is parked for a person after all (attention reason
usage_limit_exhausted).
A hand-back is a usage_limit run the runner returned before starting its agent: it has no
usage (every token, turn and cost field and the model list absent), no context_reuse, and
finished less than one minute after it started (runner.HandBackWindow). A hand-back requeues its
task like any usage_limit run, but it does not count toward the three in a row
(MaxUsageLimitRuns) and does not break a row of real limit hits. Ten hand-backs in a row
(MaxHandBackRuns) still park the task with usage_limit_exhausted, so a runner that keeps handing
work back cannot loop forever. A run that hit a limit mid-run counts as before
(Taskbase #929; agent-runner #928, where
18 runs handed back within 3 s parked six tasks).
A failed run stopped by a login failure or the fast-failure circuit breaker (amended 2026-10-04,
ADR-0006, Adapter availability holds)
adds "reason": "adapter_unavailable" instead. Its task is requeued the same way, but without
model escalation (Model escalation) — the adapter, not the task, was at fault —
and without usage_limit's three-strikes cap, since the hold on the adapter already stops the loop.
Migration 032 widens the task_runs.reason check constraint to allow it.
A failed or cancelled run cut short by its runner shutting down or crashing adds
"reason": "runner_restart" (ADR-0011 decision 3, migration 045): a run the
runner stopped because a shutdown drain ran out of time, or one it finished on its next start after
a crash or restart. Its task is requeued without model escalation and without needs_attention,
and, like usage_limit, it is parked after all — with the attention reason
runner_restarts_exhausted (Attention) — when the task's last three finished runs
all ended with runner_restart. A requeued review run's task stays in Review for the next review
run. Any other reason, or usage_limit or adapter_unavailable on a run that did not fail, is a
400. A self-update drain and a cancel from the control room never send it: an update waits for its
runs, and a cancelled run is parked as before. agent-runner sends it from v0.5.10;
older runners finish such runs without a reason, so they still park the task.
A review run adds "review_verdict": "approved", "changes_requested", "blocked" or
"out_of_date" to a
succeeded finish; other runs may not send one, and a review that succeeds without one is
recorded as failed, its summary saying so. blocked means the pull request's code is fine but
something outside it stops it merging — branch protection, a required approval the agent cannot
give, broken CI infrastructure — and no code change can fix it; use changes_requested for
problems in the pull request itself. out_of_date means the content is approved but the branch
cannot be brought up to date with its base without resolving conflicts; a branch that updates
cleanly the reviewer updates itself and approves. Gitea refusing an APPROVED or REQUEST_CHANGES review on
the reviewer's own pull request is not by itself a blocker: the review is posted as a comment
instead and the verdict still reflects the content. failed and cancelled park the task as
needs_attention, except with one of the reasons above that requeue it.
A succeeded implementation run with no pr_url parks the task as needs_attention when
the project has agent review on — there is nothing to review — unless the task was already
marked done during the run, which leaves it done and clears dispatch instead. When its digest sets
"start_after" to a time still to come, a succeeded implementation run without a pull request to
review queues its task again to wait until then, with no Needs attention item
(Start after). A succeeded
implementation run with a reviewable pr_url whose review rounds are already used up parks the
task in Review (Agent review). A succeeded implementation run whose digest sets
"investigation_only": true starts no review in a project with a review persona: the task goes to
Blocked (needs_attention) with reason investigation_only
(Investigation-only runs). A Gitea PR in
another organization or an unlinked repository is recorded with pr_unlinked = true and its
URL is kept, but it does not qualify for review. Regardless of agent review settings, the task
goes to Blocked (needs_attention) with reason pull_request_unlinked. A project without a linked
repository keeps the previous rule that any PR counts; a URL that is not a Gitea PR link also
keeps its previous treatment. 409 when
the run already finished — the message names the recorded outcome, e.g. after
an expired lease "run already finished as lost". 403 if the caller is not the
run's runner, or the runner was deleted. pr_url must be an absolute http(s)
URL; summary is capped at 64 KB.
Control-room endpoints¶
| Endpoint | Who | Does |
|---|---|---|
GET /api/runners |
anyone signed in; of agent runs only operator runs, read-only (Runner owners) |
Instance runners, plus organization runners listing an organization the caller reaches (admins see all). Each carries online and last_seen_seconds_ago, computed on the server so a viewer's clock cannot misreport them, and its update_mode, target_version override, effective_target_version, target_version_source, caps, model_overrides, update_error, machine (Machine load), and slots, slots_setting, slots_source and runs_in_progress (Runner slots), session_turns_running (Session turns), owners and can_manage (Runner owners), and features (register) and claude_api (Claude API key from Taskbase) |
POST /api/runners |
see below | Create: name, principal, scope, organization_ids, optional owners. The principal and owners are checked against Keycloak; the caller becomes the first owner |
GET /api/runners/{id} |
as list | One runner; 404 if not visible |
PUT /api/runners/{id} |
owners and administrators; see below | Change scope and organization_ids |
DELETE /api/runners/{id} |
owners and administrators | Delete; run history is kept with runner_id null |
PUT /api/runners/{id}/desired-state |
owners and administrators | running, paused or draining; delivered in the next heartbeat |
PUT /api/runners/{id}/target-version |
owners and administrators | The self-updating runner's target version override, or null to follow the default; 409 for an image runner, including when setting null (below) |
PUT /api/runners/{id}/slots |
owners and administrators | Set or clear the number of slots set in Taskbase (below) |
PUT /api/runners/{id}/caps |
owners and administrators | One subscription's session and week caps (below) |
PUT /api/runners/{id}/models |
owners and administrators | Set or clear per-adapter model overrides (below) |
PUT /api/runners/{id}/claude-api |
owners and administrators, signed in as themselves | Set the runner's Claude API key and its settings (below) |
DELETE /api/runners/{id}/claude-api |
owners and administrators, signed in as themselves | Remove the key and the settings (below) |
GET /api/runners/{id}/owners |
as list | The runner's owners (below) |
PUT /api/runners/{id}/owners/{username} |
owners and administrators | Add an owner; returns the owners |
DELETE /api/runners/{id}/owners/{username} |
owners and administrators | Remove an owner (204); only an administrator may remove the last |
GET /api/runner-settings |
anyone signed in | The instance-wide default target version |
PUT /api/runner-settings |
administrators | Set or clear the default target version |
GET /api/runner-releases |
anyone signed in | agent-runner releases a target may name |
POST /api/runs/{id}/cancel |
the run's organization | Ask the runner to stop the run (202); repeated until it finishes it as cancelled |
POST /api/tasks/{id}/requeue |
the task's organization | needs_attention → queued; dispatched with no active run → queued; an idle, open agent task with no dispatch state that has an open attention item or whose newest run is a merge_handoff review → queued (Stranded tasks); 409 for dispatched with an active run, any other state, or a needs_attention task in Review whose rounds or pull request a claim could never match (below). Optional body {"start_after": "<RFC 3339>"}: the task waits in the queue until then (Start after); without it a stored start_after is cleared and the task can be claimed at once |
PUT /api/projects/{id}/review |
the project's organization; not agents | Agent review settings (below) |
PUT /api/projects/{id}/escalation |
the project's organization; not agents | Model escalation setting (below) |
Listing runs¶
| Endpoint | Who | Lists |
|---|---|---|
GET /api/tasks/{id}/runs |
the task's organization | the task's run history |
GET /api/tasks/{id}/usage |
the task's organization | the task's usage totals, split as {task, reviews, total} |
GET /api/projects/{id}/usage |
the project's organization | usage totals per task id, each {task, reviews, total} |
GET /api/organizations/{orgId}/runs |
that organization; not agents | its runs across all runners, with totals in headers (below) |
GET /api/organizations/{orgId}/queue |
that organization; not agents | its open agent work (Organization queue) |
GET /api/runners/{id}/runs |
as the runner is visible | the runner's runs, only in organizations the caller reaches — an instance runner's list would otherwise show other organizations' task titles |
All run-listing calls return a JSON array, newest first (by run id). Filters, combined with AND:
| Parameter | Matches |
|---|---|
active=true |
runs still going |
outcome=<outcome> |
that outcome: succeeded, failed, cancelled or lost |
model=<id> |
the model the run used |
adapter=<name> |
the adapter the runner launched |
runner_id=<id> |
that runner's runs |
project_id=<id> |
runs of that project's tasks |
from=YYYY-MM-DD, to=YYYY-MM-DD |
started_at on or after the start of from and before the end of to, as UTC days; both inclusive. from after to is a 400 |
Paging is by keyset: ?limit=1..200 (default 50), then ?before=<oldest id seen> with the same
filters for the next page. Each run carries its runner (runner_id, runner_name, null once the
runner is deleted), task_title, organization_id, project_id, project_name, adapter, model,
persona (below), started_at, queued_at (when the task last entered the queue before this run claimed it),
wait_seconds (started_at − queued_at, never negative), finished_at, duration_seconds (so far, while running), outcome (null while
running), summary, pr_url, cancel_requested_at, review_verdict (review runs only),
requested_model (what the claim asked for), escalated_from (the task's own tier when the claim
escalated it, else null), effort (the task's effort at the claim, omitted when it had none) and
usage (null when unknown). queued_at and wait_seconds are null for
runs from before Taskbase recorded them (migration 050, no backfill) and for runs started without a
claim (schema).
persona is the persona the run worked as, recorded at the claim: the task's agent assignee for an
implementation or revision run, or the project's review persona for a review run — the claim's
persona_slug. It is null for runs from before Taskbase recorded it
(migration 026) and for runs with no persona
(Taskbase PR #404).
GET /api/organizations/{orgId}/runs also sets two headers that describe the whole filtered set,
independent of limit and before
(Taskbase PR #116):
| Header | Value |
|---|---|
X-Total-Count |
Number of runs matching the filters |
X-Total-Cost-USD |
Sum of cost_usd over those runs. Only runs with a reported cost count; runs without one add nothing, so it is a lower bound when some costs are unknown |
Every task in the API and in MCP carries the same totals as usage — {task, reviews}, or null
when it has no runs — computed on read, so a task's consumption can be looked into later from the task
itself.
GET /api/tasks/{id}/usage sums a task's usage: task over its own runs, reviews over its review
tasks' runs, and session over the turns of the agent session a request was built in
(each claimed turn counts as one run, also added to total; a task's inline usage has no
session line), each with runs, runs_with_usage, the token sums, turns and cost_usd. Runs without
usage count in runs only.
The UI shows it on the task dialog (Runs & usage: implementation and review totals plus their sum, and each run's role with its persona under it, model, outcome,
time, tokens, turns and cost) and as a small cost figure on each board card, with the details on hover. Agents acting
for a run cannot list runs. taskbase-mcp exposes the task history as list_task_runs.
The Taskbase UI shows all of this at Runners (header link), refreshed every 10 seconds
(Taskbase PR #250; the code is in
ui/src/runners/). Runners are ordered working → idle → paused/draining → offline, then by name.
Each runner has a compact card:
- Header: a status dot, the name, one state chip —
working,idle,paused,drainingoroffline— and a gear button, Settings for those who can manage the runner and Details for everyone else. "seen … ago" shows only when the runner is offline. - Activity: a slot meter, "n of m busy" against the effective slots, and the
runs in progress — linked task title,
#id, then a persona chip, model, effort and duration, with a cancel × for managers — for examplesenior-developer claude-opus-5-5 · high · 12m 0s. Runs without apersonashow no chip. Each running session turn gets its own line: "Chat turn", the session's persona chip, the model ("default model" when the turn names none) and the duration. Nothing running shows "Idle". - Subscription: one row with thin session and week bars, the agent cap marked and the reset time on hover, and a limited or held badge.
- Attention line, only when there is something to act on: a failed update, a pending update, a held adapter, or a runner offline for more than a day.
- Footer: the runner's version and, for managers, a single Pause or Resume.
Everything else lives in the runner's Settings drawer, opened with the gear button or the deep
link #runner-<id>/settings; Esc or a click outside closes it. Its sections:
- General: scope with Edit scope, owners, Keycloak user, labels, dedicated label, OS/arch and machine.
- Capacity: slots, and the subscription limits with their caps.
- Models: each adapter's models and the default model.
- Updates: version, update mode, the target and its source, the target override, and any update error.
- General chats: the runner's general chat turns, by anyone, by day — for its owners and administrators only (see General chats' usage).
- Danger zone: Drain and Delete.
The page also creates runners (New runner).
Creating a runner: an instance runner takes an administrator; an
organization runner takes a grant on every organization it lists.
Changing or operating one — rescope, slots, desired state, target version,
caps, models, delete and owners — takes one of its owners or an
administrator, and a rescope also needs the create rule for the new scope,
so ownership cannot carry a runner into organizations the owner cannot reach.
Ownership does not widen who can see a runner: an owner who cannot see it gets 404 like
anyone else. So an organization runner whose last organization was deleted is left with none,
claims nothing, and only an administrator can see and rescope it.
Runner owners¶
A runner has owners: Keycloak usernames in runner_owners (migration 052,
Taskbase PR #229). Grants decide which
runners you can see; only a runner's owners and global administrators may change or operate it
(ADR-0006, Runner scope).
- Creating a runner with
POST /api/runnersmakes the caller its first owner.owners, a list of usernames, adds co-owners; each must exist in Keycloak (400otherwise,502when Keycloak cannot be reached), and blanks are refused with400. A service API key has no username, so a runner it creates has only the owners it names, and none if it names none. - Reading.
GET /api/runners/{id}/ownersreturns[{ "username", "added_by", "added_at" }]to anyone who can see the runner;added_byis a username orapi-key. The runner views carry the same list asowners, andcan_manage— whether the caller may change and operate the runner — so clients need not repeat the rule. - Adding.
PUT /api/runners/{id}/owners/{username}adds a Keycloak user and returns the owners. Adding an existing owner changes nothing; an unknown user is400. - Removing.
DELETE /api/runners/{id}/owners/{username}returns204,404when the user is not an owner, and409when it would remove the last owner and the caller is not an administrator. - Refusals. Every change and operation — rescope, slots, desired state, target version, caps,
models, delete, adding and removing owners — answers
403"only the runner's owners and administrators may change it" to anyone else. An owner whose rescope names a scope they could not create gets the scope403instead. Agents acting for a run are refused every one of them, even on an administrator's runner. - Operator runs read the list. A run of the persona
operatormay callGET /api/runners, read-only, so it can wait for active runs to finish before an upgrade takes a shared service offline (Drain). It sees the instance runners and the runners of every organization its runner serves, withruns_in_progress, andcan_manageis alwaysfalsefor it. Every other runner route stays closed to agents, and every other agent run is refused the list too (task #2422, taskbase#688, merged 2026-11-03; read from the task and the MCP tool description, not the code). - Runners from before owners. Migration 052 gives existing runners no owners: guessing them from the principal would hand a runner to its machine account. Until an administrator adds owners, only administrators can manage such a runner.
- Owners decide whose chats a runner answers. A person may choose only a runner they own to
answer their agent sessions; an administrator may
choose any runner in scope. A runner without owners therefore answers chats only for
administrators who choose it, and no one else's
(ADR-0016 §2). It
keeps claiming tasks as before. agent-runner reads its owners at registration and every 10
minutes, and warns when there are none:
agent-runner statusprintsrunner owners none: …, the desktop app shows an Owners row, and the log a warning, so its operator knows to add an owner here.
list_runners and get_runner in taskbase-mcp return owners and can_manage too.
On the Runners page (Taskbase PR #230):
- Owners in the drawer. The Settings drawer's General section lists the runner's owners, with who added each on hover, or "No owners: an administrator must add one" when it has none.
- Editing owners. Where
can_manageis true, the drawer's Owners row has a Remove button per owner and a Keycloak username field with Add owner. For an owner who is not an administrator, Remove on the last owner is disabled ("Only an administrator can remove the last owner; add another owner first"). The API's refusals, such as an unknown user, show under the row. - Controls withheld. Where
can_manageis false, the controls are hidden, not disabled: the card has no Pause, Resume or run cancel, and the gear opens the same drawer as Details, read-only, with the hint "Only this runner's owners and admins can change it". It has no Edit scope, owner editing, slots or models Edit, target override or Danger zone, and the cap pins cannot be dragged. The viewer still sees the runner, its owners, slots, models and caps. - Creating a runner. The New runner form says the creator ("You (
username) will be its owner") becomes its first owner, and takes co-owners as Keycloak usernames, comma-separated, in a Co-owners field; they are sent asowners.
Organization queue¶
GET /api/organizations/{orgId}/queue lists an organization's open agent work: tasks assigned to a
persona (assignee_type = 2), not done, not in Done, with dispatch_state queued, dispatched
or needs_attention, highest priority first, then oldest (created_at). It is for people with
access to the organization; agents acting for a run are refused
(Taskbase PR #115).
[ { "task_id": 7, "project_id": 2, "project_name": "Taskbase", "title": "…", "persona": "developer",
"priority": 3, "model": "medium", "persona_default": false, "required_labels": ["os=linux"],
"dispatch_state": "dispatched", "created_at": "2026-10-05T09:12:00Z",
"dispatch_state_changed_at": "2026-10-05T09:40:00Z",
"run_id": 412, "runner_id": 3, "runner_name": "home-1", "no_runner": false, "waiting_on": [] } ]
personais the task's agent assignee, or the project's review persona for a task in Review that a review run will take.modelis the effective model the claim would ask for: the task's own model, else the assigned persona'sdefault_model, raised by the task's model escalation when the project allows it; for review work, the project'sreview_model. It is null when none of these is set, and the claiming runner'sdefault_modelthen applies.persona_defaultis true only whenmodelis the persona's default because the task names none.required_labelsare the task's, or the project's review labels for review work.dispatch_state_changed_atis when the task entered its current state (schema); the wait time is measured from it.run_id,runner_idandrunner_namedescribe the task's latest run, null when it has none.no_runneris computed on the server: true when no runner that is online, has desired staterunningand is in scope for the organization could claim the task right now, by the same matcher a claim uses — every required label, the runner's dedicated label (a dedicated runner only counts for tasks that require its label), and the effective model (after escalation) offered by an adapter that is not held by an adapter hold, the subscription'slimited_until, or a usage cap. A runner whose slots are all busy still counts, since it can take the task when a slot frees. Unlike the unclaimable-queue sweep, holds count against a runner here, so the flag can be set for a while and clear by itself.waiting_onlists the ids of the task'sdepends_ontargets that are not done yet, and is empty ([]) when there are none.
The organization's Queue tab shows this list, refreshed every 10 seconds: task (linked to its
board), priority, project, persona, model ("Runner default" when null, "Persona default (…)" when
persona_default), labels, state with a "No runner can serve this" warning or a "Waiting on #N"
hint, the time waiting in the
current state (counting live, every second; hover for the state and since when), the runner and run for a dispatched task, and a Requeue button on
needs_attention tasks (requeue).
"Waiting on #N" appears under the state of a task whose waiting_on is not empty, with each id
linked to its task, and replaces the "No runner can serve this" warning for that task. Claims skip
the task until every prerequisite is done (Dependencies, ADR-0011 decision 5), so it
waits on purpose — the runners are not broken, and the task starts by itself once the listed tasks
are done. Task cards' dispatch badges do not show the hint.
The organization's Runs tab lists GET /api/organizations/{orgId}/runs with filters for model,
adapter, outcome, runner, project and a UTC date range, the matching count and total known cost from
the response headers, and Load more for the next keyset page. Each row shows the
task and project, runner, adapter and model (with the requested model and escalation), kind (task
or review round), start, Waited (the run's wait_seconds, a dash when unknown; hover for
queued_at), duration, outcome, verdict and pull request, tokens and cost, with
Cancel on a running run and Requeue on a run whose task needs attention.
Runner target version¶
Runners with update_mode: "self" update themselves to the release Taskbase names
(ADR-0006, Self-update).
Two settings decide it: the default, global-administrator only, and a per-runner override, for the
runner's owners and administrators
(Taskbase PR #85,
#97,
#105):
- the instance-wide default,
target_runner_versionin the singletonrunner_settingsrow (migration 027), read withGET /api/runner-settingsand set withPUT /api/runner-settings:{ "target_runner_version": "v0.6.0" }, ornullto clear it; - a per-runner override,
runners.target_version(migration 030), set withPUT /api/runners/{id}/target-version:{ "target_version": "v0.5.9" }, ornullto follow the default again. Returns the runner.
For a self runner, the effective target is the override when set, else the default, else none.
The runner views carry it as effective_target_version with target_version_source (runner,
global or none), and register and
heartbeat answers send it as target_version, omitted when none.
With no target, runners stay as they are; setting an older release rolls back.
For an image runner, its own override and the instance default are ignored:
effective_target_version is null, target_version_source is "image", and register and
heartbeat answers omit target_version. PUT /api/runners/{id}/target-version returns 409
(this runner is updated through its container image), including for null. On the Runners page,
its Settings drawer's Updates section says Updated by image and has no target or
target-override control, and its card shows its reported version without an update-pending line.
Release list and validation¶
GET /api/runner-releases lists the releases of the runner repository (RUNNER_RELEASE_REPO,
default Skatzi/agent-runner), read through Taskbase's Gitea client, newest first:
{ "releases": [ { "tag": "v0.6.0", "published_at": "2026-10-03T09:12:00Z", "usable": true } ],
"stale": false }
A release is usable when it is neither a draft nor a prerelease, its tag is a v<semver> without a
prerelease suffix at v0.2.0 (the first self-updating release) or later, and it carries
checksums.txt.minisig and binaries for all six platforms — darwin, linux and windows on amd64 and
arm64. The list is cached for five minutes. When Gitea cannot be reached the last list is served with
stale: true; with nothing cached yet the request fails.
The settings PUT and a self-updating runner's target-version PUT accept only a tag that is
usable in that list, or null: any other tag is
refused with 400, naming the available releases, and 503 is returned when the release list cannot
be read at all.
The agent-runner release workflow keeps only the newest 10 releases (older versions remain as git tags only), so the list — and how far back a rollback can go — covers those (ADR-0006).
The Runners view shows the default at the top, with a dropdown of usable releases (the newest marked "latest") for administrators; for the runner's owners and administrators, each runner card has its own dropdown with a Use default entry. Each card shows the runner's current version against its effective target and an update pending marker while they differ. A note appears when the release list is stale.
Usage caps¶
A runner's owners and administrators can cap how much of a subscription's session and week windows a runner may
use (Taskbase PR #110), so a shared subscription keeps some headroom for people or other runners. Caps are whole
percentages per subscription name, stored in runners.caps (migration 034):
PUT /api/runners/{id}/caps sets both windows of one subscription in one write and returns the
runner:
Each value is null (no cap on that window) or 1–100; unknown fields are refused. Setting both to
null removes the subscription's entry.
Caps are enforced at claim time only: a subscription is held while the reported used of its
session or week window is at or above that window's cap and the window's resets_at is still in
the future. On the session window, each run already in progress on the subscription adds
5 percentage points to used (RunSessionShare,
ADR-0011 decision 2): with an 80% session cap and one run in progress, a
further run is held from 75%. The week window counts only the reported figure. The 5 points are a
starting estimate; stage 1 gave no reason to change them (ADR-0011 implementation notes). Its adapters are then skipped exactly like a held subscription —
a tier may go to another adapter, an explicit model waits — and the hold ends by itself at the reset,
without waiting for a new report. A run already going is not stopped. The check works on the
runner's last report, which can lag: a Claude subscription's figures may be up to about 30 minutes
old (the runner's limits_refresh probe interval), so a busy runner can overshoot a cap before a
report shows it.
Caps are set and enforced in Taskbase. Taskbase also sends them to the runner in every
heartbeat answer as caps, omitted when there are none (task #1910),
so the runner can offer its Claude API key while its Claude login is at a cap.
They are independent of the runner's own safety floor, hold_session_at in its local config (default 0.95), which holds the session
by setting limited_until
(ADR-0008, Proactive session hold);
whichever is lower bites first. Since agent-runner v0.5.10 the runner also counts its
runs in progress there, 5 points each, and leaves the subscription's adapters out of its report while
that holds; a run Taskbase handed out before hearing so is handed back as usage_limit.
In the Runners view, the runner's owners and administrators set caps with pins on each subscription's usage bars; that control is being redesigned under task #347.
Caps apply only to windows named session and week (SubscriptionCaps.forWindow in
api/internal/runner/limits.go), so the credit window of a
Claude API key subscription is never capped.
Claude API credit¶
A runner can also run Claude on an Anthropic API key, and then reports it as one more
subscription with a single credit window instead of session and week (agent-runner task #1638,
agent-runner PR #252; the runner's
side is in agent-runner's docs/usage-limits.md, "An Anthropic API key as one more Claude
subscription"). The key is stored on the runner's machine, in its secrets file. It is set there,
or by the runner's owners from Taskbase, which hands it to the runner once and then deletes its copy
(Claude API key from Taskbase). The runner never reports the key.
With a key stored, the runner adds a copy of its first Claude adapter named <adapter>-api, with
subscription <subscription>-api and provider anthropic — for an adapter claude, adapter and
subscription claude-api. Its entry in limits:
{ "subscription": "claude-api", "provider": "anthropic", "status": "allowed",
"as_of": "2026-10-25T09:12:00Z",
"windows": [
{ "name": "credit", "used": 0.25, "resets_at": "2027-01-01T00:00:00+01:00" } ] }
| Field | Meaning |
|---|---|
used |
The summed cost of the key's runs and chat turns divided by the credit set in the runner's config (claude_api.credit_usd), at most 1. 0 when no credit amount is set. |
resets_at |
When the credit expires: the start of the day after claude_api.expires, in the runner's time zone. Left out without an expiry. |
length_seconds |
Left out: the window has no fixed length. |
status |
rejected while the credit is spent or expired, or while the subscription is held after the API refused the key; else allowed. |
limited_until |
Set 24 hours out when a run failed because the API refused the key (the run finishes as usage_limit); left out otherwise. A new key clears it. |
The runner offers Taskbase only one of the two Claude adapters at a time:
- With
claude_api.use_first: true, it offers the API key adapter while it has credit and is not held, and the login adapter otherwise. - Without it (the default), it offers the login adapter, and the API key adapter only while the login subscription is held, full, or at its Taskbase cap.
The login is at its cap when the caps from the last heartbeat answer
put one of its windows at or above its cap, worked out the same way as the claim-time check: only a
window whose resets_at is still ahead counts, and the session window adds 5 points for each run in
progress on the login (reachesCaps in agent-runner's internal/runner/limits.go). The runner then
reports claude-api beside the login. Taskbase's cap check holds the login and sends Claude claims to
the key: caps are keyed by subscription, so the login's cap does not hold claude-api. The runner
reports the change at once, in a second heartbeat. Without credit, or with the key held, only the login
stays in the report, and Claude claims wait as before (agent-runner task #1909,
agent-runner PR #283, merged
2026-10-28 after v0.5.28, so in v0.5.29 or later; agent-runner's docs/usage-limits.md, "Which
subscription a Claude run uses"). An older runner ignores caps, and keeps the key waiting while the
login is capped.
The adapter it does not offer, and the API key adapter while its credit is spent or expired, are
left out of adapters in the report, so Taskbase never matches a task to them. Taskbase itself holds
the subscription only through limited_until and caps; status does not hold it,
and caps do not apply to the credit window.
In the Runners view (Taskbase PR #588, task #1640; read in ui/src/runners/ on 2026-10-25):
the runner card and the Capacity section of the runner's Settings drawer draw the credit window
as a Claude API credit bar (Credit for a provider other than anthropic). With a
resets_at, the drawer shows expires and the expiry time, or expired once it has passed; the
card shows the same in the bar's tooltip. The bar takes the limit-reached colour once used
reaches 1 or the credit has expired, and 75% or more shows as high. The drawer shows no cap control for it.
A report may also carry spent_usd and credit_usd on the credit
window, and use_first on the limit. When it does, the bar reads "$2.00 of \(8.00", or "\)3.00 spent" with no
fill when there is no credit_usd, and a used first marker appears on the subscription. Without
them the bar shows the share used as a percentage. The runner does not send these fields yet
(agent-runner internal/taskbase/runner.go, read 2026-10-25; agent-runner task #1642). Until it
does, the spend in dollars and use_first show only in the runner's desktop status window and
agent-runner status --json (credit).
Owners can also set the key and its settings from the runner's Settings drawer, in its Claude API key section, which shows the delivery state, the settings and the spend; see Claude API key from Taskbase.
Claude API key from Taskbase¶
A runner's owners and administrators can set its Anthropic API key and the
claude_api settings (credit_usd, expires, use_first, as in Claude API credit)
from Taskbase instead of on the machine (task #1666,
Taskbase PR #596; api/internal/runner/claude_api.go
and claude_api_pg.go, read 2026-10-26). Taskbase keeps the key, encrypted, only until the runner
takes it in a heartbeat; afterwards it keeps the key's last 4
characters and the settings. The runner stores the key in its own secrets file and the settings in
its config (agent-runner task #1667).
Only runners that report the feature claude_api_remote can take a key. Image runners cannot: their
secrets file does not survive a restart.
PUT /api/runners/{id}/claude-api¶
| Field | Meaning |
|---|---|
key |
Optional. 20–512 printable ASCII characters without spaces, after trimming. Left out, the current key is kept. |
credit_usd |
Optional. More than 0 and at most 1,000,000, rounded to cents; null or left out for none. |
expires |
Optional. The last day the credit may be used, YYYY-MM-DD; null or left out for none. |
use_first |
true to send Claude runs to the key while it has credit, before the login subscription. Left out means false. |
The settings are replaced, not merged: a field left out is cleared. Every accepted change starts
a new generation in state pending, and the answer is 200 with the runner.
| Status | When |
|---|---|
403 |
The caller is an agent or a service API key, or is not an owner or administrator |
409 |
The runner is an image runner, or does not report claude_api_remote |
400 |
Unknown fields or a body that is not the shape above (the message never quotes the body), an invalid field, or a change without key while the runner has no key from Taskbase and none waits for it |
503 |
A new key, and the API has no TASKBASE_SECRET_KEY |
DELETE /api/runners/{id}/claude-api¶
Removes the key and the settings; 200 with the runner, or 404 when no key was set from Taskbase.
The waiting encrypted key, if any, is deleted at once. When the runner may hold the key, the removal
becomes a new generation in state removing and is sent to the runner; the row is deleted once the
runner applies it. When the runner cannot hold it — the last change was rejected or expired, and
no key from Taskbase was applied before — the row is deleted at once. This endpoint does not check
the runner's update mode or features.
The claude_api view¶
GET /api/runners and the other runner views carry claude_api, or null when no key was set
from Taskbase. Everyone who can see the runner sees it. The key itself never appears.
| Field | Meaning |
|---|---|
state |
pending, active, rejected, expired or removing (below) |
reason |
Why the runner rejected the change, or why the key expired; left out otherwise |
key_last4 |
The key's last 4 characters |
key_set_at |
When the key was set |
key_waiting |
true while the encrypted key waits for the runner |
key_on_runner |
true once the runner applied a key from Taskbase that has not been removed since |
credit_usd, expires, use_first |
The settings |
generation |
The latest change |
updated_by, updated_at |
Who made the latest change, and when |
acknowledged_at |
When the runner last answered a change; null before |
The runner's features sit next to it.
Reported Claude API state¶
The heartbeat request's optional claude_api_state is the state applied on the runner
(Taskbase task #1673, PR #599;
api/internal/runner/claude_api.go, agent_api.go, and store_pg.go, read 2026-10-26).
It is either an object with these fields or null when the runner stores no key:
| Field | Rule |
|---|---|
key_last4 |
Required, 1–4 printable ASCII characters; never the key itself |
credit_usd |
More than 0 and at most 1,000,000, or null when unset |
expires |
YYYY-MM-DD, or null when unset |
use_first |
Boolean: whether the runner uses the key before its login subscription while credit remains |
applied_at |
Required RFC 3339 timestamp of when the runner applied this state |
Unknown fields and invalid values fail the whole heartbeat with 400. If the field is
absent, the runner does not report its state and Taskbase clears its stored report.
Registration keeps any stored report unchanged. The runner side is agent-runner task #1676.
Runner views expose claude_api_reported: {state, changed_at}, or null until the runner
reports a state. state is the reported object above, or null for no key. changed_at
uses Taskbase's clock when it receives a state different from the previous report; repeated
reports of the same state keep the timestamp.
The Claude API key section shows this reported state in place of Taskbase's claude_api
when the states differ and changed_at is later than claude_api.updated_at. It compares
the key's last 4 characters, credit, expiry and Use first; a report of no key differs
when Taskbase believes a key is on the runner. The section then reads Changed on the
runner with the date from applied_at, or No key on the runner: removed on the machine.
A later change in Taskbase shows its delivery state again until the runner applies it
(ui/src/runnerClaudeAPI.js and ui/src/runners/RunnerClaudeAPI.jsx, read 2026-10-26).
States¶
| State | Meaning | Next |
|---|---|---|
pending |
A change waits for the runner | active when applied, rejected when refused, expired when a waiting key is not taken within 7 days |
active |
The runner applied the latest change | pending on a new change, removing on delete |
rejected |
The runner refused the latest change (reason) |
pending on a new change; removed on delete, as above |
expired |
The runner did not take the key within 7 days of key_set_at; reason says so |
pending on a new change; removed on delete, as above |
removing |
A removal waits for the runner | row deleted when applied; rejected when refused, with key_on_runner set so it can be removed again |
The runner sweeper drops a key still waiting 7 days after it was set (ClaudeAPIKeyTTL). A
settings change without a key keeps a key that still waits, together with its key_set_at: the
heartbeat still sends that key, and it still expires 7 days after it was set. When no key waits, the
change carries no key and does not expire (api/internal/runner/claude_api_pg.go, SetClaudeAPI
and ClaudeAPIDelivery, read 2026-10-25).
In the Runners view, the Settings drawer's Claude API key section shows … and the last 4
characters, when the key was set, the state in words ("Waiting for the runner to take the key",
"Active on the runner", "The runner rejected it: …", "Expired before the runner took it — add it
again", "Removal waiting for the runner"), the settings and the spend from the credit window.
Owners and administrators get Add key, Change (an empty key field keeps the current key) and
Remove key. On a runner without claude_api_remote it asks to update the runner to v0.5.27 or
later; on an image runner it says image runners are not supported (ui/src/runners/RunnerClaudeAPI.jsx
and ui/src/runnerClaudeAPI.js, read 2026-10-26).
Security¶
- The key is encrypted with AES-256-GCM under
TASKBASE_SECRET_KEY(OpenBaohetzner-mgmt/taskbase/secret-key, the same key that encrypts Mattermost webhooks), bound to the runner's id, and stored inrunner_claude_api.key_sealed. - It is decrypted only to answer that runner's own heartbeat, over TLS.
key_sealedis cleared when the runner applies or rejects the generation, when the key expires, or on delete. Afterwards onlykey_last4and the settings remain.- The key is never logged, shown in a runner view, or quoted in an error message.
Open questions¶
- The UI names agent-runner v0.5.27 as the first release with
claude_api_remote(CLAUDE_API_SINCE). Agent-runner task #1667, which builds it, was not done on 2026-10-26, so the release number is not confirmed. - The encryption binds the key to the string
organization:<runner id>(aadinapi/internal/notice/cipher.go), the same form webhook URLs use with an organization id. A sealed key copied into another table could open as the webhook of the organization with the same id. It needs write access to the database, so it is noted here rather than treated as a flaw.
Runner slots¶
How many runs a runner takes at once is set per runner in Taskbase
(ADR-0011 decision 1), stored in runners.slots_setting (migration 046).
PUT /api/runners/{id}/slots sets it, { "slots": 2 }, or clears it, { "slots": null }, and
returns the runner; 400 for anything but a whole number from 1 to 64 or null. The runner's
owners and administrators may set it, and the set_runner_slots MCP tool does the
same.
- Claims use the number set in Taskbase, else the
slotsthe runner reports. - The heartbeat answer sends it as
slots, omitted when unset. The runner applies it within one heartbeat, without a restart, keeps it in itsstate.json, and reports the number it uses withslots_source: "taskbase". With nothing set, or after it is cleared, the runner usesslotsfrom itsagent-runner.yamland reportsslots_source: "config". - Lowering it never stops a run in progress; the runner takes nothing new until its runs fall below the new number. Setting it to 1 is the rollback for several runs at once.
- Each active run's subscription is kept in
task_runs.subscription: set at the claim, then replaced by the subscription the runner reports for the run in its heartbeat. Runs in progress per subscription count toward the session cap, and the runner views return them asruns_in_progress,{"claude": 2, "codex": 0}, listing every subscription the runner reports.
Runners on agent-runner v0.5.9 or earlier do not read slots from the heartbeat answer: they keep
their config's number and report no slots_source. Taskbase still caps their claims at the number
set in it, so lowering works on them, but raising it beyond their config does not.
On the Runners page each card shows "n of m busy" against the effective number. The Settings
drawer's Capacity section shows the slots and where they come from — from Taskbase or from runner config — with waiting for the runner
until the runner reports the number set in Taskbase with slots_source: "taskbase", and the runs in
progress per subscription ("claude 2 · codex 0"). The runner's owners and administrators get an
Edit control and Use the runner's config to clear the setting. Switching the Mac mini to two slots,
and rolling back, is in Two Slots on the Mac Mini Runner.
Session turns¶
A person's message in an agent session becomes a turn: a short, stateless run of the session's persona, answered by a runner within seconds (ADR-0013). Turns have their own claim, slots and lease, apart from tasks.
Capability. A runner takes turns only when it reports session_turns: true at registration and in
heartbeats. agent-runner reports it when session_slots is not 0 and every adapter can answer a
turn, that is, has output claude-stream-json or codex-json, since Taskbase may hand a turn to
any of them. Otherwise it logs why at startup and offers no sessions.
Session slots. runners.session_slots is how many turns the runner runs at once, separate from
its task slots, so a chat never waits behind a long task. NULL means 1. 0 keeps the runner out of
sessions. PUT /api/runners/{id}/session-slots sets it, { "session_slots": 2 } (0–64), or clears
it, { "session_slots": null }, for the runner's owners and administrators. Lowering it never
stops a turn in progress. The heartbeat answer sends the effective number as session_slots.
Until it arrives, the runner uses session_slots from its agent-runner.yaml and reports where its
number came from in agent-runner status. The Runners page shows "sessions n of m" on each card for runners that take
turns, and the Settings drawer has a Session slots editor.
Running turns in runner views. Each runner in GET /api/runners and GET /api/runners/{id}
carries session_turns_running, the turns it is running, oldest first: id, persona (the
session's persona, such as request-builder, assistant or attention-helper), model (null when
the turn names none), claimed_at and duration_seconds (how long it has run, as of the view). A
turn's subject is left out, because an instance runner serves organizations the viewer may not reach
(Taskbase PR #404). The runner card lists
them as "Chat turn" lines (Listing runs).
POST /api/runners/{id}/session-turns/claim?wait=20 (the runner's principal) is a long-poll. While
it has a free session slot and is running, agent-runner keeps one open on its own goroutine, beside
the task claim loop. Taskbase answers at once with the oldest claimable pending turn, as soon as
Postgres NOTIFY session_turn_pending fires (a new turn, a requeue, or a running turn ending), or with
204 after wait seconds (at most 20). Failed claims back off like task claims.
A turn is claimable when:
- the runner is the session's chosen runner (
sessions.runner_id; a SQL filter in the claim, so no runner version can take another session's turn — Choosing the runner and the model); - the runner is running (not paused or draining) and in scope: it serves the session's organization, or for a general chat at least one organization;
- it has a free session slot;
- the session's model (else the persona's
default_model, else the runner's default) resolves on one of its adapters whose subscription is not held; - the session's owner still owns the runner, unless the owner is an administrator. Otherwise the turn stays pending until the person switches runner.
The claim reads the session's choice when it runs, so a pending turn follows a switch. Holds and usage caps apply as for tasks, without ADR-0011's 5 points per run in progress. Required labels and the dedicated label do not apply. The claim fails a turn whose persona is gone, whose owner no longer reaches the organization or no longer exists, or — for a general chat — whose runner serves none of the owner's organizations.
Read scope, fixed at claim. The claim stores the organizations the turn may read in
session_turns.scope_org_ids: the session's organization, or for a general chat the owner's reach
(grants and groups via the cached Keycloak lookup; every organization for an administrator)
intersected with this runner's scope. The turn scope reads it on every request and refuses a turn
without one (Turn-scoped access). A requeued turn is
scoped again at its next claim. It also stores the one project the turn may read files of,
scope_project_id: the request session's project or the task's project, null for a general chat.
Repository and docs tools. A turn reads its own project's repository with list_repository_files
and read_repository_file, and the platform docs (Skatzi/platform docs/content) with
list_platform_docs and read_platform_doc, in every session; in a general chat the docs are its only
source. All four are read-only and enforced by Taskbase, not by the runner, which passes them on like
every Taskbase tool (ADR 0023;
Agent Sessions — Reading files).
200 returns:
turn: id, session, adapter, model (resolved from the session's choice),requested_model,scope_org_ids,scope_project_idand the 60-second lease;persona: slug and body, used as the system prompt;frame: session id, subject, project, organization, date and the draft's JSON Schema; for a session about a task alsocontext, the item's context (Agent Sessions — The frame); for a general chatprojectandorganizationare null, and it carriesorganizations[]with their projects andattention, a summary of the open Needs attention items in them (Agent Sessions — The general frame);draftanddraft_revision;messages: the transcript, untrusted text, whose last message is the one to answer. A person's message may carryattachments[], the images sent with it: the metadata ofGET /api/sessions/{id}plusurl.
GET /api/session-turns/{turn}/attachments/{aid} is each attachment's url, and serves the
image's bytes. Only the runner the turn runs on may read it (403 for another runner), only while the
turn is running (409 after), and only an image of the turn's session (404 otherwise). Older
runners ignore attachments; agent-runner passes the images to the agent from task #1788 on. A task
run's images come in its claim instead (Images in the claim).
POST /api/session-turns/{id}/progress {text, activity} appends partial reply text and an
activity line ("looking up project tasks"), both masked for secrets, and renews the lease. agent-runner posts at
most every 300 ms, and an empty keep-alive every 20 s during long tool calls.
POST /api/session-turns/{id}/finish {outcome, reply, reason, usage} writes the masked reply as
the agent's message, or fails the turn with an error the person sees (e.g. usage_limit). Usage has
the same fields as a run's.
Leases and restarts. A turn whose 60-second lease runs out, or that a runner finishes with
runner_restart, goes back to pending once and the session's runner retries it from the same transcript.
The partial text is discarded. A second loss makes it lost, and the person can send again. A turn
running 3 minutes fails with timeout. At shutdown or before an update, agent-runner stops claiming
turns, lets running turns finish for up to 30 s, then finishes them as runner_restart. At startup
it finishes the same way the turns a crashed process left in state.json. In container mode their
leases expire instead.
On the runner. Each turn is a fresh agent process in an empty temporary directory, with no clone.
The prompt is the frame (session, subject, organization and project — neither for a general chat —
and date); for a general chat the organizations it reads with their projects (id, name, repository)
and the open Needs attention items in them as JSON lines labelled as untrusted; the subject context
from frame.context labelled as untrusted (task sessions only; request sessions have none), the
draft schema (for a general chat, the action plan with the create actions and task_ref), the
current draft, the earlier messages labelled as untrusted, then the new message. The runner runs the
turn on the claim's model; a tier it still gets, or only a requested_model, becomes the first
model of the turn's adapter serving that tier. When the agent reports no split by model (Codex), the
finish usage reports the totals under that model. The runner does not narrow the Taskbase tools:
whatever Taskbase opens to turns, such as save_action_plan and get_project_pipeline, reaches the
agent. Nothing of the conversation stays on the runner. Turns do not run an
adapter's command; they run its session variant:
| Output | Session command |
|---|---|
claude-stream-json |
claude -p --model {model} --output-format stream-json --verbose --include-partial-messages --no-session-persistence --strict-mcp-config --mcp-config {mcp_config_file} --tools "" --allowedTools mcp__taskbase --setting-sources "" --system-prompt-file {persona_file} {prompt} |
codex-json |
codex exec --ephemeral --ignore-user-config --ignore-rules --sandbox read-only --skip-git-repo-check --color never --json --model {model} -c web_search="disabled" -c features.shell_tool=false, the task command's mcp_servers.taskbase settings, then {persona} and {prompt} |
Claude has no built-in tools, only the taskbase MCP server's, and streams text as it is written.
Codex has a read-only sandbox, no shell tool and no web search, and gives each message whole. An
adapter's session_command replaces the variant and takes the same placeholders as command.
The turn's environment drops the Gitea token, every variable named like a token, password, secret,
key or credential, and SSH_AUTH_SOCK, keeping only the agent program's own provider login.
Usage. Each claimed turn counts as one run of role session in usage trends,
and once the session is confirmed, in the session line of its request task's usage. A turn's usage
and rate-limit reports update the subscription's limits like any run's.
agent-runner status and state.json show session_turns, session_slots, session_slots_source
and active_turns (turn and session id, persona, adapter, model, subscription and start time, never
the conversation).
Runner models¶
A runner's owners and administrators can replace the models and tiers an adapter offers without editing the runner's
agent-runner.yaml (Taskbase PR #123).
Overrides are stored per adapter name in runners.model_overrides (migration 038) and returned on
the runner as model_overrides:
An adapter without a key uses the runner's config. PUT /api/runners/{id}/models sets or clears
the overrides of one or more adapters in one write and returns the runner:
{ "adapters": { "claude": [ { "id": "claude-opus-5-5", "tiers": ["medium", "large"] } ], "codex": null } }
null clears that adapter's override; adapters not named keep theirs. Unknown fields are refused,
and each list is checked (400 otherwise):
- the adapter must be one the runner reports — except that an override for an adapter the runner no longer reports can still be cleared;
- each adapter needs at least one model, and at most 64;
- ids match
^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$(the id ends up as a--modelargument) and appear once per adapter; - tiers come from
small,mediumandlarge, and each tier is served by at most one model per adapter. A model without a tier is used only by tasks that name it.
The runner receives the overrides as models in its register and
heartbeat answers, applies them, and reports the models it then
uses with models_source: "taskbase" (or "config" for an adapter without an override) in its
next heartbeat. Claims, the queue's no_runner flag and the
queue sweep all match on the models the runner reports, so a change
takes effect only once the runner has picked it up.
On the Runners page the Settings drawer's Models section shows, for each adapter, where its models come from — from Taskbase or from runner config — and waiting for the runner until the reported models and source match what Taskbase holds. The runner's owners and administrators get an Edit button per adapter: tier toggles per model (turning a tier on takes it from any other model), add and remove model, and Reset to the runner's config when an override is set.
Update errors¶
When a self-update fails, the runner keeps its version and reports why in
the optional update_error of its register and
heartbeat report
(Taskbase PR #127):
version— the release it tried to install; required, a token without whitespace;error— required; trimmed, and cut to 1024 bytes rather than refused when longer;retry_at— optional RFC 3339 time of the next attempt.
Only the latest report is kept, in runners.update_error (migration 040): a report without the
field, or with null, clears it. Runners that never send it are unaffected — the strict body
decoding accepts their reports as before. The runner views (GET /api/runners,
GET /api/runners/{id}) and the list_runners / get_runner MCP tools return it as
update_error, and an error for the runner's effective target raises
runner.update_failed. An image runner's update_error is discarded; it never
raises runner.update_failed, and a heartbeat resolves any open event.
The Runners view shows it on the runner card under the chips, e.g. "update to v0.2.0 failed:
checksums.txt signature does not match the public key — retrying at 14:05".
Machine load¶
The runner reports the load of its machine in the optional machine of its
register and heartbeat report
(ADR-0011,
Taskbase #481, runner side agent-runner #482). Every key is optional — a platform that cannot read
one leaves it out — and unknown keys are refused by the strict body decoding (400):
load— the 1, 5 and 15 minute load averages; exactly three values, each 0–1e6;cpus— the number of cores, 1–4096;memory_free_pct— free memory in percent, 0–100;disk_free_bytes— free space on the data disk, ≥ 0;disk_total_bytes— size of the data disk, > 0 and not less thandisk_free_bytes;as_of— RFC 3339 time of the reading.
Only the latest report is kept, in runners.machine (migration 049): a report without the field,
with null or with {} clears it. Runners that never send it are unaffected. The runner views
(GET /api/runners, GET /api/runners/{id}) and the list_runners / get_runner MCP tools return
it as machine.
The Runners page shows it in a Machine row in the General section of the runner's Settings
drawer, e.g. "load 2.7 / 10 cores · 85%
memory free · 74 GiB of 228 GiB disk free". The load is the 15-minute average; hovering it shows the
1, 5 and 15 minute averages and as_of. Each part turns the warning colour at ADR-0011's stage 1
thresholds: 15-minute load above the number of cores, memory free below 20 %, disk free below
20 GiB. A runner that sends none shows "no data".
Agent review settings¶
PUT /api/projects/{id}/review turns agent code review on for a project
(ADR-0007); the UI has it under the
project's Settings → Agent review.
persona must be an active persona of the project's organization; an empty or null persona turns
review off and resets the rest to their defaults. model is optional (a tier or model id, null for the
runner's default), labels defaults to ["role=reviewer"], max_rounds to 3 (1–10). Returns the
project, whose review is null while review is off. It is a route of its own so that a client unaware
of review cannot turn it off by omission, and agents cannot change their own review.
Agent review¶
With review on for a project (ADR-0007,
settings above), a task entering its Review column is claimed as a review run on that same task.
Taskbase stores its reviewer, verdict, round and usage in the task's ordinary run history.
The PR may be in the task's own repository or another repository under the organization's
gitea_org linked to a project in the same Taskbase organization. The task's project supplies
the review settings, verdict handling and round limit.
| Finish | Taskbase |
|---|---|
An implementation run succeeds with a reviewable pr_url |
The task moves to Review from whatever column it is in (unless it is done or in Done) and is queued as a review run when review is enabled, including for a PR in another linked repository of the same organization. When its counted review rounds are already at the project's max_rounds, it is not queued: it waits in Review as needs_attention, with dispatch_reason set to the requeue's rounds message and a task.needs_attention event with reason review_rounds_exhausted and that message as detail. A task that still ends up dispatched outside Review is repaired by the stuck-review sweep |
An implementation run succeeds with a reviewable pr_url and digest.investigation_only: true |
No review is queued and no review round is used: the task goes to Blocked (needs_attention) with reason investigation_only. The PR stays linked on the run and on the attention item (below) |
An implementation run succeeds without pr_url |
With review enabled, the task goes to Blocked (needs_attention) — unless it was already marked done during the run, which leaves it done and clears dispatch; with review off, it stays dispatched in Review |
| An implementation run succeeds with a Gitea PR in an unlinked repository or another organization | The run keeps pr_url and sets pr_unlinked = true; the task goes to Blocked (needs_attention) with reason pull_request_unlinked regardless of review settings, and no review is queued |
| An agent task is moved into Review | Queued for a reviewer runner matching the project's review model and labels, provided a reviewable PR exists and the round limit allows it — rounds counted as by the claim query and requeue, without blocked and out_of_date verdicts and without the first three review runs lost or requeued with no verdict (below). Otherwise it leaves the queue (dispatch_state NULL) and is not queued; a task already needs_attention stays so |
Review run, approved |
The reviewer merges. Gitea sync moves the original task to Done; the review verdict stays on its run |
Review run, changes_requested |
The original task returns to In Progress with the feedback in its next claim's revision; moving it to Review after the fixes starts the next round. At review_max_rounds, it goes to Blocked (needs_attention) |
Review run, blocked |
The original task goes to Blocked (needs_attention); no revision run is queued and the round is not advanced, so a requeue once the blocker is cleared claims the same round again |
Review run, out_of_date |
The original task returns to In Progress for a merge-only run: its claim's revision.verdict is out_of_date. The round is not advanced and the model tier does not move, so the review after the merge claims the same round again, even when that round is the last. The third out_of_date in a row (no approved or changes_requested in between) sends the task to Blocked (needs_attention) instead, with dispatch_reason "the pull request keeps falling behind its base; consider running related tasks one after another" and a task.needs_attention event with reason review_out_of_date |
Review run, merge_handoff |
For a drain-class pull request (label drain-before-merge): the reviewer approves and does not merge. The original task returns to its implementer for a merge run: its claim's revision.verdict is merge_handoff. No review round is used. When the next review also ends merge_handoff (the merge run left the pull request open), the task goes to Blocked (needs_attention) with reason review_blocked and detail "the merge run ended without merging the approved pull request" (below) |
| Review run fails, is cancelled or gives no verdict | The original task goes to Blocked (needs_attention) |
The original task is only moved while it is still dispatched, not done and not in Done, so a pull
request someone merged meanwhile is left alone. merge_handoff and out_of_date are the
exception: they queue their merge run, or park the task after the loop limit, even when the task
left dispatched during the review, as long as it is still an open agent task with no dispatch
state or needs_attention. A review run that raises a question before its verdict takes the task
out of dispatched that way; before Taskbase #2685 such a task stayed in Review with no dispatch
state and no merge run. A task stranded so is requeued as described in
Stranded tasks.
Merge hand-off¶
Some upgrades take a service every agent run needs offline, such as Gitea or Taskbase's database.
The drain step
holds agent work around their merge, so the operator merges them, not the reviewer. The agent
working the pull request marks it with the label drain-before-merge, and the review ends with the verdict
merge_handoff instead of approved
(ADR-0007).
- The reviewer approves the pull request in Gitea and does not merge it.
- Taskbase queues the original task for an implementation run. Its claim's
revision.verdictismerge_handoff: this is a merge run, asout_of_dategives a merge-only run. - The merge run holds agent work, merges, watches the gate and resumes (pause_organization and resume_organization). The merge closes the issue, and the Gitea sync moves the task to Done as usual.
- If the merge run ends with the pull request still open, the next review's second
merge_handoffin a row parks the task as described in the table above.
merge_handoff counts as an approval in approval rates. It is stored in task_runs.review_verdict
from migration 089 (Database schema).
Sources: task #2422 and its merged pull request
taskbase#688 (2026-11-03), and the
list_task_runs MCP tool description; the code was outside this writer's read scope. Open: whether
the round counts above (claim, requeue, move into Review) leave out merge_handoff verdicts the way
they leave out blocked and out_of_date, and whether the reviewer or Taskbase checks the label.
Investigation-only runs¶
An implementation run that cannot build the task yet may still open a pull request that holds only
an investigation, such as a readiness note or a blocker document. It says so in its finish with
"digest": { "investigation_only": true }. When the pull request is reviewable and the project has
a review persona, Taskbase treats the run like one without a pull request:
- starts no review, so no review round is used and the project's
max_roundsis not checked:investigation_onlywins overreview_rounds_exhaustedeven when the rounds are used up; - parks the task as
needs_attentionwith reasoninvestigation_only, shown as "Investigation only, nothing to review yet" (Attention), and moves it to Blocked when it sits in In Progress or Review (elsewhere it keeps its column); - leaves the task's
dispatch_reasonas it was: only the rounds message of a reviewable pull request sets it on finish; - keeps the pull request linked on the run and on the attention item;
- raises a
task.questionitem as well when the digest hasopen_questions.
The implementation that later lands on the same pull request therefore gets every round of the
project's max_rounds. Every review of real work still counts as a round, with the same exceptions
as before (below), so the protection against review and
implementation ping-pong is unchanged. The flag cannot loop: each such run waits for a person,
or for the start_after below.
A task marked done during the run, or sitting in Done, stays done: it leaves dispatch, moves to
Done and raises no item. A handoff that also sets start_after to a time still to come (task
2405) queues the task again to start then, as for any succeeded implementation run without a pull¶
request to review, and parks nothing. In a project without a review persona the run is handled like one without a pull request and with agent review off: the task stays dispatched and moves to Review only from In Progress or Review, where a reviewable pull request would move it from any column.
investigation_only is a work reason: triage
takes it like no_pull_request, and its standard options are Try again and Park it
(Options).
agent-runner sends the flag when the agent's RUN_HANDOFF_JSON block sets the key
investigation_only to true, and leaves it out otherwise; an invalid value is dropped and does not
fail the run (agent-runner task #2349,
agent-runner#325, merged 2026-11-03).
The Taskbase side is task #2311,
taskbase#674, merged 2026-11-02.
The behaviour above is read from Taskbase's FinishRun (api/internal/runner/store_pg.go) and
TestInvestigationOnlyRunUsesNoRoundOnPostgres (api/internal/runner/review_rounds_pg_test.go) at
commit 3c300f39 (task #2395).
Requeue and exhausted rounds¶
POST /api/tasks/{id}/requeue on a needs_attention task still sitting in its project's Review
column is only allowed for a direct review (a review persona is set, and the task is not a legacy
review_of_id review) when its counted review rounds — review runs, not counting blocked or
out_of_date verdicts nor the first three runs lost or requeued without a verdict
(see below), the same count the claim query and the move into Review use — are below the project's max_rounds and it has
an implementation run with a reviewable pull request (pr_unlinked = false). This is the same eligibility the claim query applies, so
a requeue can never queue a task that no claim will ever match.
An investigation-only run uses no round. An implementation run marked investigation only starts no review, so there is no review run to count, and the implementation that later lands on the same pull request has every round left.
A review run with no verdict keeps its round. A review run that ends without a verdict because
it was lost (its lease expired) or finished with a requeuing reason
(usage_limit, adapter_unavailable, runner_restart) does not count either, so the next review
claims the same round again. Lost and adapter_unavailable runs requeue without a cap of their own,
so only the first three such runs on a task are free (task.MaxFreeReviewRetries); each further one
counts as a round again. A review that keeps being lost therefore still stops, and the
queue sweep parks it as review_rounds_exhausted once its rounds are
used up (task.ReviewRoundsSQL in api/internal/task/store.go, Taskbase #1637, PR #585, read
2026-10-25).
Otherwise it is refused with 409 and the task is left unchanged:
- No implementation run with a pull request at all: "This task has no implementation run with a pull request to review. Move it to In Progress for an implementation run first."
- Rounds used up: "All
<max_rounds>review rounds are used. Raise the project's review rounds, or move the task to In Progress for another implementation run." — "round is" whenmax_roundsis 1 (ErrReviewRoundsExhaustedinapi/internal/task/store.go).
The same messages are the dispatch_reason of a task parked in Review because no claim could
match it: by the run finish and the stuck-review sweep
(rounds used up), and by the queue sweep (either message). The first two
park the task instead of queuing it; the queue sweep parks, within one sweep, a review queued by any
other path, so no task stays queued for a review no claim can match (Taskbase #1634, PR #584,
read 2026-10-25).
Recovery after raising the rounds. Raise the project's review rounds (max_rounds in
PUT /api/projects/{id}/review); nothing else is needed. On its next run (every 15 s) the
queue sweep's auto-recovery requeues every review parked in Review with
the rounds message whose counted rounds are now below max_rounds, once a viable runner can claim
it, and its attention item resolves. The endpoint itself does not requeue anything. A person can
also requeue the task by hand once the rounds are raised.
The check does not apply to an idle dispatched task sitting in Review — requeue moves it to
Backlog as an ordinary task instead — nor to a needs_attention task outside Review, a legacy
review task, or a project without a review persona.
Stranded tasks¶
POST /api/tasks/{id}/requeue, and Try again in Needs attention,
also take an idle, open agent task with no dispatch state in two cases:
| The task | The requeue |
|---|---|
Its newest run is a merge_handoff review |
moves it to the Backlog, so its implementer gets the merge run |
| It has an open attention item | leaves it in Review for another review round, within the review-round limit above |
Any other task with no dispatch state is still refused with 409. Before Taskbase #2685 a task
left in Review with no dispatch state, for example after a merge_handoff review that also raised
a question, could not be requeued at all: "requeue: only a needs_attention or dispatched task
without an active run can be requeued".
Sources: Taskbase task #2685, its merged pull request
taskbase#698 and follow-up task #2687,
read 2026-11-07. The Taskbase code (api/internal/task/store_pg.go,
api/internal/runner/store_pg.go) was outside this writer's read scope. Open: what the requeue
does with a stranded task holding an attention item that is not in Review, and which message it
gives when that task's review rounds are used up.
Preferred models¶
A task can name up to three model ids it prefers, best first, in preferred_models, beside its size
tier in model (ADR-0014;
Taskbase #858, #859). The tier stays the fallback, so model must be a tier or unset while the list
is set (400 otherwise). The model-selection policy
says which models the project manager names for which work.
For an implementation or revision run, a runner claiming the task:
- runs the first preferred model that it offers on an unheld subscription;
- else leaves the task while another viable runner offers one of the preferred models on an
unheld subscription — a runner seen recently, with
desired_staterunning, that serves the task's organization and could ever claim the task (scope, required labels, dedicated label, and an offer of the task's effective tier); - else runs the task's effective tier, as for a task without preferences.
"Unheld" is the hold test of Usage caps: a reported limit, a manual hold or a cap
holds a subscription; busy slots do not. So a task that prefers a model waits for a free slot on a
runner with that model unheld, and falls back to its tier only when every such subscription is held.
A preferred model that no runner offers is skipped: it never parks the task, and the
unclaimable-queue sweep checks the tier only. The Go claim
(chooseModel) and the SQL claim (PostgresStore.Claim) apply the same rule; the
queue's no_runner flag uses it too.
Escalation. While a task is escalated, a preferred model counts only if a
viable runner of the organization reports it at the effective (escalated) tier or above; the others
are skipped. A medium task that prefers gpt-6-sol, which every runner reports only at medium, skips
Sol once escalated to large: it runs a later preferred model reported at large, if it has one,
else its large tier. With
escalate_models off, preferences always apply.
Reviews run on the project's review model and ignore preferred models.
Recording the choice. Each run records the task's preferred_models at claim time and
model_choice (database schema):
model_choice |
Meaning |
|---|---|
preferred |
One of the task's preferred models ran |
fallback |
The task had preferred models, but none had capacity and its tier ran |
tier |
The task had no preferred models, or the run is a review |
Both are NULL on runs from before migration 062. requested_model keeps the task's (possibly
escalated) tier even when a preferred model ran. The task dialog, the organization's Runs tab and
the runner cards show the model with its choice ("gpt-6-astra · preferred", "claude-opus-5-5 · large
fallback"); model effectiveness filters by model_choice. The
agent-runner logs model_choice next to model when it claims a task.
Model escalation¶
A changes requested verdict from round 2 on, or a failed implementation or revision run, can move a
task up a model tier before its next run is queued
(ADR-0007). tasks.model_escalation
(0–2) holds how many tiers up the task currently sits, reset to 0 whenever the task's model changes;
the claim shifts the task's model by it, capped at large, and records the result as above.
A project turns this off with escalate_models (default on):
PUT /api/projects/{id}/escalation¶
Humans only; agents acting for a run are refused, so a task cannot turn off its own escalation. Returns the project.
Usage can be grouped by escalation (escalated or not escalated) — see
Usage Trends.
The proposed run handoff and claim context contract is in ADR-0009.
How agents reach Taskbase¶
The agent a runner launches talks to Taskbase through the runner's local MCP
proxy, which adds X-Taskbase-Run: <run id>. The API then confines the request
to that run's organization and to data routes; the runner endpoints above,
runner management, cancel and requeue are closed to it. A run of an attention-triage
task may requeue the one task it triages
(What a triage run may do). See
Run-scoped access.
During a session turn the proxy adds X-Taskbase-Turn: <turn id> instead (and strips
either header if the agent sends one). The API then accepts only the user of the runner running that
turn, and only GET routes open to agents in the session's organization, plus GET /api/sessions/{id}
and PUT /api/sessions/{id}/draft of the turn's own session. A request may not carry both headers.