0006 - Agent Runner and Taskbase as Agent Controller¶
Status¶
Accepted. Revises one principle of ADR-0005 (see Revision to ADR-0005).
Amended 2026-09-24: runners are scoped as instance or organization runners in Taskbase rather than by the runner user's organization grants, and an agent's access is confined to its run's organization (see Runner scope and Identity and credentials). Runners report their providers and models, and a task can ask for a model so cheap work runs on cheap models (see Providers and models).
Amended 2026-10-04: records the agent-runner as built — self-update's two
triggers, guards and failure handling (Self-update), the
separate desktop app that controls the runner only through its CLI (Desktop
app), the secrets.json file that replaces Keychain-based
secrets on every OS (Secrets), and per-adapter availability holds
alongside ADR-0008's subscription holds, with the adapter_unavailable run
reason (Adapter availability holds).
Amended 2026-10-05 (Taskbase task #399): a persona may have a default model
per organization, used when a task names none, before the runner's
default_model (Providers and models); moved from the
deferred table, whose trigger fired.
Amended 2026-10-05 (Taskbase #340): records the release boundary between GoReleaser, the Linux signing and publishing job and the macOS desktop job (Self-update).
Amended 2026-10-05 (Taskbase #362 and #313, agent-runner #363 and #378): an
administrator can set an adapter's model ids and tiers from Taskbase, which
the runner applies and reports back with models_source (Model lists from
Taskbase); and a failed self-update is reported
to Taskbase as update_error and shown on the Runners page
(Self-update).
Amended 2026-10-05 (agent-runner task #428): a self-update drain waits for the active runs to finish, with no time limit and without cancelling them; the five-minute limit stays for shutdown only (Reliability, Self-update).
Amended 2026-10-06 (agent-runner task #359): the Windows desktop app is built and released alongside the macOS one (Desktop app).
Amended 2026-10-06 (agent-runner task #360): the Windows desktop app updates
itself through agent-runner app-update, like the macOS app (Desktop
app).
Amended 2026-10-06 (agent-runner task #488): a self-update that fails because a release file is missing is retried within minutes, and the macOS job swaps its re-signed files in rather than re-uploading them over the old ones (Self-update).
Amended 2026-10-06 (Taskbase #473): a run's lease lasts 10 minutes from each claim or heartbeat, and the runner retries a failed heartbeat after 15 seconds instead of waiting out the two-minute interval (The runner pulls work, Reliability).
Amended 2026-10-09 (Taskbase task #675, PR #229): a runner has one or more owners. Only its owners and global administrators may change or operate it — scope, slots, pause / drain / resume, delete, target version, models, caps and owners — and owners can add other owners. Scope still decides who may create a runner and where an owner may move it (Runner scope, API, The control room).
Amended 2026-10-09 (Taskbase task #679, PR #231; agent-runner task #680, PR
156): a task may name a reasoning effort — low, medium or high —¶
beside its model or tier. Taskbase keeps it provider-neutral and passes it with
the claim; each adapter maps it to its program through effort_args in the
runner config, and an adapter without a mapping ignores it
(Providers and models).
Amended 2026-10-09 (agent-runner tasks #687, #688 and #689, PRs #157, #158
and #160; decision #683): the runner installs with no terminal, from a macOS
.dmg or a per-user Windows installer. The app download carries the runner,
and first-run setup stays the existing wizard (Desktop app).
A single validated setup page, a Taskbase setup code and discovery API, and
creating the Gitea token from the app were considered and declined (What we
deferred).
Amended 2026-10-09 (epic #46: Taskbase task #713, agent-runner tasks #714 and
715, platform task #716, PR #198): a runner can also run as a container¶
on Kubernetes, for people without a machine of their own. It is updated by its image rather than by self-update, keeps its Codex login in OpenBao, and runs in an isolated namespace on hetzner-mgmt under an accepted risk (Container runners).
Amended 2026-10-10 (agent-runner task #742, PR #166): the release workflow keeps only the newest 10 published releases, so a rollback through a Taskbase target reaches back only that far; older versions remain as git tags (Self-update).
Amended 2026-10-12 (ADR-0013, Taskbase
tasks #815 and #816, agent-runner task #819, platform task #820): a runner has a
second claim path, for the chat turns of interactive agent sessions. It is
a long-poll beside the task claim, with its own session_slots separate
from slots. An agent answering a turn is confined by a turn scope
(X-Taskbase-Turn) instead of a run scope. See The runner pulls
work, Data model and
API. The same amendment corrects the online window from 60
seconds to the code's 3 minutes (OnlineWindow).
Amended 2026-10-12 (agent-runner task #875, platform task #881): review and revision workspaces clone the linked pull request's repository when the claim includes it (Workspaces).
Amended 2026-10-14 (agent-runner task #962, platform task #964): a task run
can get a second local MCP server, gitea, with three read-only status
tools. It reads Gitea with the runner's own token and grants the agent nothing
it did not already have (Identity and credentials).
Amended 2026-10-26 (Taskbase tasks #1666 and #1673, platform tasks #1670 and
1677): runner owners and administrators can deliver a Claude API key through¶
Taskbase. This is an exception to the runner-local provider credential boundary: Taskbase stores the encrypted key only while delivery is pending, then keeps the key's last four characters and settings. See Claude API key from Taskbase for the current delivery and reporting contract.
Amended 2026-10-28 (platform task #1941, agent-runner tasks #1916 and #1936):
the deferred per-task sandbox's trigger has fired — instance runners serve
several organizations and job_env gives jobs organization secrets. The
runner now starts every agent through agent-runner sandbox-exec: a
Landlock ruleset on Linux and in container mode, a Seatbelt profile on
macOS, and no sandbox on Windows, where an organization's secrets stay on
runners scoped to it. On Linux without Landlock the runner refuses to start
while job_env is set. Gitea tokens are not scoped per organization; the
runner's Gitea user is (Job sandbox, Identity and
credentials, Secrets,
Workspaces).
Amended 2026-10-28 (platform task #1988, agent-runner task #1986): on Linux and in container mode each run gets a home of its own under its workspace, the service user's home is read and execute only, and the runner copies the Claude and Codex logins into the run's home and keeps them in step with the service user's files (Job sandbox).
Amended 2026-10-28 (platform task #1994, agent-runner task #1989): on Linux
and in container mode each run gets a temporary directory of its own under
its workspace, and the shared /tmp is no longer granted. The runner makes
its own temporary directories in the data directory, which the sandbox
denies (Job sandbox).
Amended 2026-10-28 (platform task #1999, agent-runner tasks #1991 and #1993):
on macOS too each run gets a home and a temporary directory of its own under
its workspace. The Seatbelt profile denies writing the service user's home
and the directories on the runner's PATH, and allows back the run's
workspace and ~/Library/Keychains, which the run's home links to so that
Claude Code finds its login in the login Keychain (Job sandbox).
Amended 2026-10-28 (platform task #2058, agent-runner task #2040,
agent-runner 0.5.31): a runner labelled role=ops grants its runs read-only
access to the kubeconfig files its service KUBECONFIG names; every other
runner denies them. The design is unchanged (Job sandbox).
Date¶
2026-09-24
Context¶
ADR-0005 defined what an agent is (a persona
synced from <org-slug>-agents) and that Taskbase dispatches agent tasks by
priority to "a runtime executor, any implementation". It left the executor
itself undefined, and none of the agent side is built yet — Taskbase has
assignee, assignee_type and priority on tasks, but no agent_types sync
and no dispatch.
The executor now has concrete requirements:
- Provider-agnostic — Anthropic, OpenAI, or a self-hosted model.
- Cross-platform — Windows, Linux and macOS machines, mostly on home networks behind NAT, reachable only over the tailnet.
- Heterogeneous work — some tasks need a GPU, most do not, so work must be matched to machines that can do it.
- Reliable and self-updating — a new release rolls out without anyone logging in to each machine.
- Observable and controllable from Taskbase — Taskbase is the control room: one place to see both where the implementation stands and what every agent is doing, and to pause, drain or cancel.
Decision¶
Build agent-runner, a standalone service in its own repository
(Skatzi/agent-runner), and extend Taskbase into the agent controller.
Architecture¶
graph LR
subgraph Hetzner Cluster
TB["Taskbase - controller and control room"]
MCP["taskbase-mcp - agent tools"]
GITEA["Gitea - repos and releases"]
end
subgraph Machine on a home network
RUNNER["agent-runner service"]
PROXY["local MCP proxy"]
AGENT["agent program - one per task"]
WS[("workspace per task")]
end
RUNNER -->|register, heartbeat, claim, finish| TB
TB -->|desired state, cancels, target version| RUNNER
RUNNER -->|spawn| AGENT
AGENT --> WS
AGENT -->|MCP with per-task secret| PROXY
PROXY -->|fresh user token| MCP
MCP --> TB
RUNNER -->|clone, download releases| GITEA
AGENT -->|push branch, open PR| GITEA
Every connection is outbound from the runner. Taskbase never connects to a machine, so NAT and home firewalls need no configuration.
The runner pulls work¶
A runner claims work rather than having it pushed:
Taskbase still owns ordering — the claim returns the highest-priority
claimable task — so this is ADR-0005's "dispatch when an executor signals
capacity", with the claim itself as the capacity signal. It is not ADR-0004's
superseded get_next_task design: the runner process claims, and the model
never sees the queue.
One task per claim, and nothing is lined up behind a runner. A task is
queued when it is open and assigned to an agent — meaning available to any
runner that can serve it, not assigned to a particular one. A runner claims one
task at a time per free slot (slots, default 1) and asks again only when a
slot frees up.
Every run is a fresh session. The runner starts a new agent process in a new workspace for each claimed task and never resumes an earlier conversation, so no context carries over between tasks; what the agent needs comes from the task, the persona and the repository.
Each claim creates a run holding a lease. Heartbeats renew the leases of
the runs a runner reports as active. A lease that expires (runner crashed,
machine lost power, network gone for longer than the lease) marks the run lost and
returns the task to the queue.
Amended 2026-10-06 (Taskbase #473, Taskbase 85d1927, agent-runner v0.5.11):
the lease lasts 10 minutes from each claim or heartbeat (LeaseDuration,
previously 5), so it survives about four missed two-minute heartbeats. A runner
retries a failed heartbeat after 15 seconds, doubling (30 s, 1 min) up to
the two-minute interval, and a success restores the interval. Three runs
(2026-10-05 19:41, 2026-10-06 14:10 and 14:36) were lost when two heartbeats in
a row did not arrive under the 5-minute lease while their runner kept working,
and were restarted from scratch. A runner that really died is noticed later
(about 10 minutes); its restart still recovers its runs.
Session turns take a second path (amended 2026-10-12,
ADR-0013). A runner that reports the
capability session_turns at registration and in each heartbeat also holds
POST /api/runners/{id}/session-turns/claim?wait=20 open on its own goroutine
while a session slot is free and its desired state is running. Taskbase
answers at once with the oldest claimable pending turn, as soon as Postgres
NOTIFY session_turn_pending signals one, or with 204 after at most 20
seconds; the runner then asks again at once.
- Separate from tasks.
session_slots(default 1; 0 keeps the runner out of sessions) counts turns only, so a chat never waits behind a task run, and turns never take a task slot. - Claimable means the runner is running and in scope for the session's
organization, has a free session slot, and resolves the session persona's
default_model(else its own default) on an unheld adapter. Holds and usage caps apply as for tasks, without ADR-0011's 5 points per run in progress. Required labels do not apply. - Stateless. Each turn is a fresh agent process in an empty temporary directory, with no clone. The claim returns the persona, a short frame, the draft and the transcript, which the runner replays as the prompt, so "every run is a fresh session" still holds.
- Its own lease. A turn's lease is 60 seconds, renewed by each progress
post (at most every 300 ms) and by a keep-alive every 20 seconds. A lost
lease or a
runner_restartfinish returns the turn topendingonce; a turn running 3 minutes fails withtimeout.
Labels match work to machines¶
A runner declares labels describing its machine; a task declares
required_labels. A runner may claim a task only if every required label is
in its set. A task with no requirements runs anywhere.
# agent-runner.yaml on a GPU machine
labels: [gpu, cuda, vram-24g] # os=<os> and arch=<arch> are added automatically
Labels live in the runner's config because the machine is the authority on its own hardware. Taskbase displays them. A queued task whose requirements no online runner satisfies is flagged in the control room rather than waiting silently.
Provider-agnostic through adapters¶
The runner does not implement an agent loop. For each run it launches an existing agent program through an adapter — a command template in the runner's local config:
adapters:
claude:
provider: anthropic
command: ["claude", "-p", "--model", "{model}", "--append-system-prompt", "{persona}", "{prompt}"]
mcp_config: templates/claude-mcp.json
effort_args: ["--effort", "{effort}"] # amended 2026-10-09
models:
claude-haiku-4-5: [small]
claude-sonnet-5: [medium]
claude-opus-5-5: [large]
default_model: medium
Placeholders: {persona}, {persona_file}, {prompt}, {prompt_file}, {workspace},
{mcp_config_file}, {model}, and {effort} in effort_args only (amended
2026-10-09, see Providers and models). Each adapter supplies a template for its program's MCP
config format, rendered per run with the proxy URL and secret.
Agent programs already solve file editing, shell execution, context management and provider support; a self-hosted model is reached through a program that speaks to it (e.g. one configured for Ollama or vLLM). How to launch a program stays runner-local configuration, preserving ADR-0005's runtime-agnostic brain. Taskbase displays what runners report and matches tasks to runners by name, as it does with labels. An adapter's model ids and tiers may also be set from Taskbase (amended 2026-10-05; see Model lists from Taskbase). Provider credentials normally stay on the runner; Claude API key delivery is the exception (amended 2026-10-26).
Session variants (amended 2026-10-12, agent-runner task #819,
ADR-0013). A session turn does not run
an adapter's command. It runs a built-in session variant for the
adapter's program, chosen by its output: for claude-stream-json, Claude
with --tools "", --allowedTools mcp__taskbase, --setting-sources "",
--include-partial-messages and the persona as --system-prompt-file; for
codex-json, codex exec in a read-only sandbox with the shell tool and web
search off. An adapter's optional session_command replaces the variant and
takes the same placeholders. A runner offers sessions only when every adapter
has one of these two outputs, since Taskbase may hand a turn to any of them.
The full commands are in Taskbase — Runners and
Runs.
Providers and models¶
Not every task deserves the most capable model. A task may name the model it needs, so routine work runs on a small, cheap model and only hard work on a large one.
Runners report what they offer. Registration and every heartbeat carry the
runner's adapters: each adapter's name, provider (a display string such as
anthropic, openai or ollama), models and optional subscription name.
When subscription is omitted, Taskbase uses the adapter name. The control
room shows the reported adapters per runner. Commands remain runner-local;
no keys, endpoints or command lines are reported in the adapter list. The
separate Claude API key delivery
stores the key encrypted in Taskbase until it is sent to the runner over TLS.
The runner's heartbeat report contains only its last four characters and
settings.
Tasks name a model or a tier. tasks.model is optional and holds either:
- a tier —
small,mediumorlarge— which each runner maps to one of its own models in config (or in a Taskbase override, amended 2026-10-05), so the task stays provider-neutral; or - a model id such as
claude-sonnet-5orqwen3-coder, when a specific model is wanted.
Matching works like labels. A runner advertises the set of its model ids
plus the tiers they cover. It may claim a task only if the task's model is
empty or in that set. An empty model runs on the runner's default_model,
which should be a cheap tier, so leaving the field blank never picks the
expensive model by accident. A queued task whose model no online runner in
scope offers is flagged, like an unmatched label.
A persona may have a default model (amended 2026-10-05). Each organization
can give a persona an optional default_model — a tier or a model id — set in
the organization's agent settings in Taskbase. It lives in Taskbase rather than
in the persona file: persona files stay runtime-agnostic (ADR-0005), and
organizations sharing one agents repository can choose their own cost policy.
The model a run uses is resolved at claim time in this order:
- the task's own
model, when set; - otherwise the assigned persona's
default_modelin the task's organization; - otherwise the runner's
default_model.
Resolving at claim rather than copying the default onto the task at assignment
means a changed persona default applies to tasks already queued, and tasks
created through the API or MCP get it too. Matching uses the resolved model
exactly as for a model on the task. Model escalation on later review rounds
(task #281) starts from the resolved tier, so a persona defaulting to medium
still escalates. Runs keep recording requested_model (the resolved request)
and the model that ran. The task form shows "Persona default (X)" instead of
"Runner default" when the assignee has one. Prefilling the model in the UI when
a persona is picked was rejected: it misses tasks created through the API and
MCP, and needs the same mapping anyway.
The run records what actually ran. At claim time Taskbase resolves the
model as above against the adapters the runner reported: the first adapter, in config order, offering that model id or tier.
The claim response names the adapter and model, the runner fills {model} in
that adapter's command template, and task_runs keeps both for every run.
Tasks may name an effort (amended 2026-10-09, Taskbase task #679 and
agent-runner task #680). Size picks how heavy a model runs a task; effort picks
how much it reasons. tasks.effort is optional and holds low, medium or
high; Taskbase stores only that neutral word, and an empty effort means the
adapter's default. Effort
is not a claim requirement — any runner that matches the task may take it. The
claim records it on the run (task_runs.effort) and returns it in the run and
the task, for implementation and review runs alike. The runner maps it per
adapter:
adapters:
claude:
effort_args: ["--effort", "{effort}"] # Claude Code
# efforts: {high: xhigh} # optional level → program value
codex:
effort_args: ["-c", 'model_reasoning_effort="{effort}"'] # Codex CLI
effort_args are appended to the adapter's command only when the task names
an effort, with {effort} filled in, so a task without one runs exactly the
command it ran before. efforts optionally maps a level to the program's own
value; unmapped levels pass as they are. An adapter without effort_args
ignores the effort: the runner logs that for the run and runs the program at
its default. The runner's log, run log and agent-runner status show the
effort a run used.
Adapter availability holds¶
Amended 2026-10-04 (task #342, building on ADR-0008's subscription holds): a subscription hold from ADR-0008 takes out every adapter billed against it; this is a hold on one adapter alone, for reasons a subscription limit does not cover.
- Zero-token login recovery. A failed provider login — Claude's or
Codex's own error text, or a configured
auth_patternfor a custom adapter — is told apart from a subscription limit, finishes the run with reasonadapter_unavailable, and holds only that adapter, indefinitely. Every minute the runner checksclaude auth statusorcodex login status— no model call, no tokens spent — and lifts the hold the moment login works again; a custom adapter with no supported check needsauth_patternand stays held until an operator fixes login. A Codex 401 is checked againstcodex login statusbefore being treated as a login failure, so a task's own API error is not mistaken for one. - The fast-failure circuit breaker. Three runs on the same adapter that
each fail within 15 seconds, with no other reason recognised, hold that
adapter for ten minutes regardless of cause — a misconfigured command or a
crashing agent program, say — and the third run is itself finished as
adapter_unavailableso its task requeues rather than waiting out a full run timeout. - Reported, not hidden. Both kinds of hold are carried on the adapter in
every heartbeat (
hold: {reason, detail, until?};untilis omitted for a login hold, since it lifts on recovery rather than at a fixed time) beside its unchanged model list, so Taskbase can still give a task to another adapter serving the same tier and the control room can show why. A held adapter is excluded from claim resolution the same way a held subscription is. Holds persist across a runner restart. adapter_unavailableas a run reason sits beside ADR-0008'susage_limit: Taskbase requeues the task without the model escalation a plain failure gets (revised by ADR-0007), since the adapter — not the task — was at fault, and withoutusage_limit's three-strikes cap, since a login or fast-failure hold already stops the loop on its own.
See Taskbase — Runners and Runs for the
reported hold object and the API's handling of adapter_unavailable.
Model lists from Taskbase¶
Amended 2026-10-05 (Taskbase #362, agent-runner #363): an adapter's model ids
and tiers no longer have to be edited in agent-runner.yaml on each machine.
An administrator may set them from Taskbase, per runner and per adapter
(amended 2026-10-09: so may the runner's owners — see Runner scope).
- Set on the Runners page.
PUT /api/runners/{id}/modelssets or clears an override for adapters the runner reports (clearing also works for one it no longer reports, so a stale override can be removed). Taskbase checks each list — at least one model, valid unique ids, known tiers, each tier on at most one model — and stores it inrunners.model_overrides(migration 038), keyed by adapter name. - Sent in the answers. The register and heartbeat answers carry the
overrides as
models, omitted when there are none. The runner applies them in memory and persists them instate.json, so they hold across a restart before Taskbase answers again. An adapter with no override uses its config's models; an invalid override is logged and the adapter keeps its current list. Runs in progress keep the model they were claimed with. - Reported back. Every adapter in register and heartbeat now carries
models_source—taskbasewhen an override applies,configotherwise — beside the models it actually uses. - Still runner-local. Only model ids and tiers can be set for adapters. Commands and endpoints stay in the runner's config. Provider credentials normally do too; Claude API key delivery is the exception added in 2026-10.
- Claims match what is reported. Claim resolution and matching use the adapters the runner last reported, not the stored override; an override takes effect once the runner has applied it and said so in a heartbeat.
See Taskbase — Runners and Runs for the Runners page and the endpoint.
Runner scope¶
Runners work like CI runners: a machine is either shared across Taskbase or dedicated to particular organizations.
| Scope | Claims from | Created by |
|---|---|---|
| instance | every organization | an administrator, who becomes its first owner |
| organization | only the organizations listed on the runner | anyone holding a grant on every listed organization, who becomes its first owner |
Scope is recorded on the runner in Taskbase, not derived from the runner user's organization grants. Deriving it from grants would force an instance runner to be an administrator or to hold a grant on every organization, and would hand the agent the same reach as the runner.
A runner is created in the control room before it registers: its name, scope, organizations, and the Keycloak user allowed to register as it. The runner then registers by name, and only that user may do so. Nothing is issued or stored for the runner — no registration token, no API key — so the "ordinary Keycloak user" model is kept.
An organization runner whose last organization is deleted is left with an empty list and claims nothing: it fails closed.
Amended 2026-10-09 (Taskbase task #675): a runner has owners — Keycloak users recorded on the runner. Whoever creates it becomes its first owner and may name co-owners. Only its owners and global administrators may change or operate it: rescope it, set its slots, pause, drain or resume it, set its target version, models or caps, delete it, and add or remove owners. Owners can add other owners; only an administrator may remove the last one. Scope still decides who may create a runner, and an owner who rescopes one needs the same reach for the new scope, so ownership cannot carry a runner into organizations the owner cannot reach. Seeing a runner is unchanged: instance runners, and organization runners listing an organization the caller reaches. Agents may never change a runner. Runners created before owners existed have none, so only administrators manage them until an administrator adds owners.
Identity and credentials¶
- Runner identity — each runner is an ordinary Keycloak user (e.g.
runner-home-1) logging in throughagent-loginwith the password grant, as documented in MCP Server. That user needs no organization grants: runner endpoints check that the caller is the runner's user, and claims are bounded by the runner's scope. Credentials come from a local file or a secret command, never from Taskbase. - Agent access to Taskbase — the agent never receives the Keycloak
credential. The runner starts a local MCP proxy on
127.0.0.1per run, guarded by a random per-run secret, which forwards to the hostedtaskbase-mcpwith a fresh token on every request. A static token header would not work: access tokens live five minutes. - Run-scoped access — the proxy adds the run id (
X-Taskbase-Run) to every request, andtaskbase-mcppasses it through to the API. A request carrying a run id is authorized as the run: the caller must be the user of the run's runner, the run must be active, and the request may reach only the organization of the run's task — as if it held a grant on that one organization. The whole organization rather than the single task, because agents create follow-up tasks, comment on related work and read epics. Once the run finishes, the run id grants nothing. - Git access — the runner user has a Gitea account and token, used to clone
and handed to the agent for pushing branches. Amended 2026-10-28 (task
#1941): the token reaches whatever the runner's Gitea user reaches, and the
job holds it by design, so no sandbox narrows it. Gitea token scopes are
categories (
read:repository,write:issue, ...), not organizations or repositories (access_token_scope.go), so a token is confined only through its user. The rule is therefore on the user: an organization runner's Gitea user is a member only of the Gitea organizations of the runner's Taskbase organizations. An instance runner's Gitea user reaches every organization's repositories, and a job of one organization can push to another's; that is accepted while every organization on instance runners is run by the instance's administrators. A Gitea user and token per organization, chosen per run likejob_env, is deferred (see the table below); only the job sandbox makes it meaningful, since without it a job reads every token insecrets.json. - Gitea MCP server (amended 2026-10-14, agent-runner task #962) — beside
the Taskbase proxy, a task run can get a second local MCP server,
gitea, built into the runner and started the same way: a random127.0.0.1port guarded by a random per-run secret. It offers three read-only tools —issue_status,pull_statusandci_status(the combined commit status; Gitea Actions jobs are commit statuses). It calls Gitea with the runner's own token, the sameGITEA_TOKENthe agent already gets, so it never sees more than the agent could: GET only, on an allow-list of five API paths, with no write tools, no arbitrary paths and no redirects followed. An adapter enables it through the{gitea_mcp_url}and{gitea_mcp_secret}placeholders in its MCP template; chat turns (ADR-0013) get no Gitea server. Actions on work items still go through Taskbase. The residual risk is unchanged: the agent can still call any Gitea endpoint its token allows, for example with curl. See agent-runner's Gitea MCP server.
Secrets¶
Amended 2026-10-04 (task #343, shipped in agent-runner v0.5.x): the runner's
Keycloak password, Gitea token and optional Claude setup token live in one
file, secrets.json next to agent-runner.yaml — the same on macOS,
Linux and Windows, replacing the Keychain-backed *_command secret sources
that runner configs used.
- Protection is the OS account, not encryption: owner-only permissions
(
0600on macOS and Linux; a DACL for the runner's user andSYSTEMalone on Windows), written atomically. The runner refuses to use a secrets file other accounts can read or that another user owns, so a copied or loosened file is noticed rather than silently trusted — startup fails only if the Keycloak password or Gitea token would have come from that file; if only the Claude token is affected, the runner starts and just that adapter is unavailable. At-rest protection still relies on full-disk encryption, the same model as an SSH key or a cloud CLI's credentials file. This was chosen over an OS keychain for simplicity and autonomy: per-user keychain confusion for a service account, approval prompts that block a headless service, and different behaviour on every OS, traded for no per-secret encryption. - Precedence: an explicit source still named in the config
(
password/*_command/*_file, and the Gitea/Claude equivalents) wins over the file;agent-runner secrets listshows which source is in use, andsecrets importmoves existing config or Keychain sources into the file once. - A missing or unreadable secret marks that adapter unavailable (see Adapter availability holds) rather than failing a task outright, and the Claude token is re-read for every run, so setting it takes effect without a restart.
- The file lives outside the binary, so self-update never touches it.
- Amended 2026-10-28 (task #1941): the OS account protects the file from
other users, not from the jobs the runner starts, which run as the same
user. Since agent-runner #1916 the file also holds
job_env, one organization's variables handed only to that organization's jobs. Keeping a job away from the file, and so from other organizations'job_envand the runner's own Keycloak password, is the job sandbox's work. Where there is none (Windows), an organization's secrets go only on runners scoped to that organization.
Workspaces¶
Each run gets <data>/workspaces/<run-id>/ with a fresh clone, deleted when the
run ends. Task runs clone the task's project repository. Review and revision
runs clone the linked pull request's repository supplied in the claim as
review.pr or revision.pr, respectively. Older review and revision claims
without that field fall back to the task's project repository.
Concurrency is the runner's configured slots (since
ADR-0011, set per
runner in Taskbase, with the config as the fallback). A workspace by itself is
an isolation of files, not a security boundary: every run's agent runs as the
same OS user. Since 2026-10-28 (task #1941) the job sandbox
makes it one on Linux, in container mode and on macOS, where an agent reaches
its own workspace and no other run's. On Windows it is still not one.
Job sandbox¶
Added 2026-10-28 (platform task #1941). The analysis, with every option per platform and its cost, is agent-runner's Job isolation (agent-runner task #1936).
Why. The deferred table's trigger for a per-task sandbox — "tasks from
other organizations or people run on these machines" — has fired: instance
runners claim from every organization, and job_env (agent-runner #1916)
puts organization secrets in secrets.json. Every job runs as the runner's
OS user, so without a sandbox any job, of any organization, can read the
runner's Keycloak password, every organization's job_env, other runs'
workspaces and, on Linux, a concurrent run's /proc/<pid>/environ.
Decision. The runner starts each agent through a hidden subcommand,
agent-runner sandbox-exec -- <argv>, which confines itself and then
execs the agent, so the agent and everything it starts inherit the
confinement. Nothing changes for the agent's user, its logins or its
workspace's ownership: the sandbox removes access, never identity.
- Linux and container mode: Landlock. Before
exec, the subcommand applies a Landlock ruleset: read-write on the run's workspace (which holds the run's home and temporary directory, see below); read and execute on the system directories and the service user's home. Landlock only grants, so everything else — the runner's config,secrets.jsonor/secrets, its state and logs, and other runs' workspaces — is unreachable. Landlock needs no privilege, onlyno_new_privs, which the container'sallowPrivilegeEscalation: falsealready sets. Its implicit ptrace restriction lets a sandboxed process inspect only processes in its own or a nested domain (kernel documentation)./proc/<pid>/environand process memory need that ptrace access, so a job cannot read the runner's environment, nor that of another run, which has its own domain. A Landlock rule cannot exclude a subdirectory of a granted one: on native Linux, where~/.config/agent-runnerand~/.local/share/agent-runnerlie underHOME, the service user's home is granted entry by entry around the runner's directories. The rule is that no runner directory is reachable. - A home per run (Linux, container mode and macOS; amended 2026-10-28,
platform task #1988, agent-runner task #1986; on macOS platform task
#1999, agent-runner task #1991**).** Each run's agent, and every
program the runner confines, gets
HOME=<workspace>/home, removed with the workspace; a probe or login check without a workspace gets a temporary one. Nothing one run writes to its home —~/.gitconfig,~/.claude/settings.json,~/.codex/config.toml, programs in~/.local/binor~/go/bin— reaches another run. A shared, writable home let one organization's job plant a hook that a later run executed with another organization'sjob_env.PATHentries under the service user's home get their counterpart in the run's home in front of them, so a program the run installs (go install) is found in that run. The run gets neitherCODEX_HOMEnorCLAUDE_CONFIG_DIR. - The service user's home is read and execute only — entry by entry
around the runner's directories on native Linux. No run can write there,
and the CLIs installed there keep running: the native Claude installer
links
~/.local/bin/claudeinto~/.local/share/claude/versions, and Codex standalone lives in~/.codex/packages. On macOS the Seatbelt profile denies writing the service user's home and the directories on the runner'sPATH(Homebrew's prefix may belong to the service user), and allows back the run's own workspace and~/Library/Keychains. - Logins are copied in and kept in step. When the service user has them,
the runner copies
~/.claude/.credentials.jsonand~/.codex/auth.json(or$CODEX_HOME/auth.json) into the run's home. While the program runs, the runner compares the copies with the service user's files every 2 seconds, and once more when it ends. A login the program renewed is copied back by rename once two consecutive reads agree, since Codex rewritesauth.jsonin place and one read can catch it half written; a login another run renewed meanwhile is copied into the running one's home. So overlapping runs pass a rotated refresh token on to each other as they did with one shared file, up to about 6 seconds later. The runner copies back only a regular file, read through the home it opened at copy-in, and never a login the service user lacked. The logins are copied, not linked: Claude Code 2.1.310 writes.credentials.jsonwithO_NOFOLLOWand a temp-file rename, so a link would lose a rotated refresh token; Codex 0.164.0 writesauth.jsonin place (codex-rs/login/src/auth/storage.rs,OpenOptionswithtruncate(true).write(true).create(true)). - Claude Code's login on macOS is in the login Keychain, not in
.credentials.json, and the Security framework looks for the login Keychain underHOME. So the run's home getsLibrary/Keychainsas a link to the service user's, made again for each program the runner starts, so that a link the program left behind cannot redirect it. Claude Code 2.1.310 names the item after$USER(-a "$USER" -s "Claude Code-credentials"), notHOME. This was checked withsecurityon macOS 15.5: with a freshHOMEit finds no login Keychain, with the link it finds and updates items. A subscription-backedclaude -pwas not run end to end, so a Claude setup token is the safer login on macOS until it is. - What the home per run leaves open. The subscription logins are still shared by design: a run can write its copy and the runner copies it back, so a run can swap in another account's login. Two overlapping runs that renew the same login within those seconds, or a CLI that does not read its login file again, can still see one renewal fail. That run reports a login failure, later runs start from the last saved login, and if they fail too the operator logs in again as the service user (or gives Claude a setup token). On macOS the agent writes the login Keychain itself, so the logins are shared there in the same way.
- Tools that ignore
HOME, on macOS. A program that writes the service user's~/Library(outsideKeychains) whateverHOMEsays, or that installs into aPATHdirectory (brew install), fails in a run. Git, Go, Claude Code and Codex use the run's home. - A temporary directory per run (Linux, container mode and macOS;
amended 2026-10-28, platform task #1994, agent-runner task #1989; on
macOS agent-runner task #1993**).** Every
program the runner confines gets
<workspace>/tmpasTMPDIRand asCLAUDE_CODE_TMPDIR, since Claude Code ignoresTMPDIRand defaults to/tmp/claude-<uid>. The shared/tmpis no longer granted, so it is no channel between runs. A program that writes to a literal/tmppath fails withPermission denied. - The runner's own temporary directories live in the data directory.
Chat turns (
agent-runner-turn-*), Claude limit probes (agent-runner-probe-*) and login checks (agent-runner-home-*) are made in<data>/workspaces/, which the sandbox denies, not in/tmp, where a running agent could drop a file such as.claude/settings.jsoninto them before the program started. The workspace clean at startup removes the ones an earlier process left. - What the temporary directory per run leaves open.
/dev/shmis still shared on Linux. On macOS the run may not write/tmp(/private/tmp), the runner'sTMPDIRor the service user's/private/var/folders/…/T; BSDmktempwith no template or with-tand Foundation'sNSTemporaryDirectory()write there whateverTMPDIRsays, so they fail in a run. Claude Code puts its sockets in its temporary directory only when that path is at most 44 bytes long; otherwise it tries/tmp/claude-<uid>, which a run cannot write, so a feature that needs those sockets can fail. Details are in agent-runner's Secrets. - macOS: Seatbelt. The subcommand runs the agent under
/usr/bin/sandbox-execwith a generated profile that denies reading and writing the runner's config and data directories except the run's own workspace, theagent-runnerexecutable and~/Library/LaunchAgents, through which a job could start a program outside the sandbox at the next login. It denies writing the service user's home and thePATHdirectories, as above, and inspecting processes outside the sandbox.sandbox-execis marked deprecated in its man page (sandbox-exec(1)) but ships with current macOS; if Apple removes it, macOS falls back to the Windows rule. - The ops kubeconfig (Linux, container mode and macOS; amended
2026-10-28, platform task #2058, agent-runner task #2040, from
agent-runner 0.5.31**).** With the watchdog enabled, the chart mounts the
break-glass Secret at
/break-glassand setsKUBECONFIG=/break-glass/kubeconfig, outside every grant above, so on 0.5.30 the ops agent'skubectl,fluxandhelmgotpermission denied. When it builds the sandbox at startup, a runner labelledrole=opsadds read-only grants for the absolute entries of the service'sKUBECONFIGthat are existing regular files; links resolve to the files behind them, as a Secret mount's..datalinks do. Every other runner denies those paths, also under an otherwise readable home, which on macOS, where Seatbelt reads by default, a non-ops run could read before. Only the file is granted: not its directory or the rest of the Secret (github-token), not relative entries, and not the certificate or exec-plugin files a kubeconfig names, which need access of their own; the break-glass kubeconfig embeds its credentials. The service's environment and the configured labels decide this, so a run cannot add a grant by changing its ownKUBECONFIG. A kubeconfig that does not exist when the runner starts is not granted until the runner restarts. - Windows: no sandbox. The rule stays: an organization's secrets, in
job_envor anywhere else on the machine, go only on runners whose scope is that organization. Its jobs can still read each other's workspaces and the runner's own secrets. - Without the sandbox's kernel support (Landlock missing or disabled, or
sandbox-execabsent): the runner refuses to start whilejob_envis set, naming the cause, and otherwise starts with a warning and runs jobs unsandboxed. Silently running a job of one organization next to another's secrets is the failure this exists to prevent, so the secrets case fails closed, like an unsafesecrets.json; a runner without organization secrets loses nothing it had before the sandbox. A Landlock ABI that lacks a newer feature (network rules, IPC scoping) is used as far as it goes, as the kernel documentation advises. - What it does not change. The job still gets the run's Gitea token and the Taskbase MCP secret by design (Identity and credentials), and the network stays open.
Rejected (reasons in the analysis):
- A separate OS user per job — per-OS sudo, launchd and systemd plumbing, and it breaks the Claude and Codex logins in the runner user's home and the workspace's ownership.
- A pod per job — container mode only, and a much larger change to the chart and its isolation than a ruleset in the same pod.
- Read-and-drop (the runner reads its secrets into memory, then drops file access) — the jobs are the same user, so dropped access is not dropped for them, and the runner's memory stays readable.
- The agents' own sandboxes (Claude Code's, Codex's) — configured per adapter, not on every adapter, and task runs bypass approvals; the runner's boundary must not depend on the agent it confines (see also ADR-0023 on what those settings do and do not stop).
Data model (Taskbase)¶
runners:
id, name, principal, version, os, arch, labels text[], slots,
scope -- instance | organization
adapters jsonb -- [{name, provider, subscription?, models: [{id, tiers}], hold?}]
-- from registration and heartbeat; subscription defaults to name;
-- hold reports a per-adapter outage, amended 2026-10-04
-- (see Adapter availability holds)
default_model -- tier or model id used when neither the task nor its
-- persona names one
model_overrides jsonb -- {adapter: [{id, tiers}]} set by an administrator,
-- amended 2026-10-05 (see Model lists from Taskbase)
update_error jsonb -- {version, error, retry_at} from the last heartbeat,
-- amended 2026-10-05 (see Self-update)
session_turns -- runner reports it answers session turns, amended 2026-10-12
session_slots -- null (1 when session_turns) | 0..64, set in Taskbase,
-- amended 2026-10-12 (ADR-0013)
reported_state -- idle | busy | draining | updating (from heartbeat)
desired_state -- running | paused | draining (set in the control room)
last_seen_at, created_at
unique (name)
agent_types (ADR-0005), amended 2026-10-05:
default_model -- optional tier or model id for this persona in its
-- organization; used when a task names none
kind -- task | session, amended 2026-10-12 (ADR-0013)
sessions, session_messages, session_turns -- amended 2026-10-12: a chat
-- turn is a session_turns row, not a task_run; see ADR-0013
runner_organizations:
runner_id, organization_id -- organization runners only
primary key (runner_id, organization_id)
task_runs:
id, task_id, runner_id, adapter, model, started_at, lease_expires_at,
finished_at, outcome, summary, pr_url
-- outcome: null while active; succeeded | failed | cancelled | lost
tasks:
...existing columns...
required_labels text[] not null default '{}'
model -- null | small | medium | large | a model id
dispatch_state -- queued | dispatched | needs_attention (agent tasks only)
dispatch_state extends ADR-0005's queued/dispatched with needs_attention:
a failed or cancelled run parks the task for a human instead of retrying it
blindly. A lost run returns the task to queued. A succeeded run leaves it
dispatched; what happens next — review, merge, done — is still decided by the
target repo and mirrored by the Gitea sync.
The board follows the run (amended 2026-09-24). A claimed task moves to the project's In Progress column, a succeeded run to Review, a failed or cancelled one to Blocked, and a lost or requeued one back to Backlog; the merge that closes the task's issue moves it to Done through the Gitea sync. Columns are matched by name, and a task someone moved by hand during a run is left where they put it. Without this an agent's task sat in Backlog until its pull request was merged, and the board showed nothing of the work in between.
A runner is shown online when last_seen_at is under 3 minutes old
(OnlineWindow; amended 2026-10-12, this text said 60 seconds, which never
matched the code).
API (Taskbase)¶
| Endpoint | Caller | Purpose |
|---|---|---|
POST /api/runners |
control room | Create a runner: name, scope, organizations and the user that may register as it |
PUT /api/runners/{id} |
control room | Change a runner's scope or organizations |
DELETE /api/runners/{id} |
control room | Remove a runner; its run history is kept |
POST /api/runners/register |
runner | Register by name as the runner's user; reports version, os, arch, labels, slots, adapters and default model; returns the id |
POST /api/runners/{id}/heartbeat |
runner | Report state, version, labels, slots, adapters and active runs; renew leases. The response carries control |
POST /api/runners/{id}/claim |
runner | Claim the highest-priority task within its scope matching its labels and models; the response names the adapter and model to use |
POST /api/runs/{id}/finish |
runner | Record outcome, summary and PR link |
POST /api/runners/{id}/session-turns/claim?wait= |
runner | Long-poll claim of a session turn, at most 20 s; returns the turn (adapter, model, lease), persona, frame, draft and transcript, or 204 (amended 2026-10-12, ADR-0013) |
POST /api/session-turns/{id}/progress |
runner | Append partial text and activity to a running turn; renew its lease (amended 2026-10-12) |
POST /api/session-turns/{id}/finish |
runner | Record a turn's reply, outcome, reason and usage (amended 2026-10-12) |
PUT /api/runners/{id}/session-slots |
control room | Set or clear a runner's session slots (owners and administrators; amended 2026-10-12) |
PUT /api/runners/{id}/desired-state |
control room | Pause, drain or resume a runner |
PUT /api/runners/{id}/models |
control room | Set or clear an adapter's model list override (owners and administrators; amended 2026-10-05 and 2026-10-09) |
GET /api/runners/{id}/owners |
control room | List a runner's owners (amended 2026-10-09) |
PUT/DELETE /api/runners/{id}/owners/{username} |
control room | Add or remove an owner (owners and administrators; amended 2026-10-09) |
POST /api/runs/{id}/cancel |
control room | Ask the runner to stop a run |
POST /api/tasks/{id}/requeue |
control room | Return a needs_attention task to the queue |
Creating an instance runner takes an administrator; creating an organization runner takes a grant on every organization it lists. Changing or operating a runner — every control-room write above except create, cancel and requeue — takes one of its owners or an administrator, and a rescope also needs the create rule for the new scope (amended 2026-10-09). The runners list shows a caller the instance runners plus the organization runners of organizations they can reach, each with its owners and whether the caller may manage it.
Turn scope (amended 2026-10-12, ADR-0013). During a turn the runner's
local MCP proxy sends X-Taskbase-Turn: <turn id> instead of
X-Taskbase-Run, and strips either header if the agent sends one itself.
Taskbase then accepts the request only from the user of the runner holding
the running turn, and only for 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.
Control reaches the runner through the heartbeat response, sent every 2 minutes:
A runner that reports session_turns also gets session_slots in the
response (amended 2026-10-12); until it does, it uses session_slots from its
config.
Run sequence¶
sequenceDiagram
participant Runner
participant Taskbase
participant Gitea
participant Agent
Runner->>Taskbase: register with name, labels, slots, version, adapters
loop every 2 minutes
Runner->>Taskbase: heartbeat with state and active runs
Taskbase-->>Runner: desired state, cancels, target version
end
Runner->>Taskbase: claim
Taskbase-->>Runner: run with lease, task, persona, repo, adapter and model
Runner->>Gitea: clone into a fresh workspace
Runner->>Agent: spawn through the adapter
activate Agent
Agent->>Taskbase: tools over MCP through the local proxy
Agent->>Gitea: push branch and open a PR
Agent-->>Runner: exit
deactivate Agent
Runner->>Taskbase: finish with outcome, summary and PR link
Runner->>Runner: delete workspace, claim again
The control room¶
| View | Shows | Actions |
|---|---|---|
| Runners | online/offline, state, labels, providers and models, slots in use, version, last seen, active runs, owners | create; for owners and administrators only: pause, drain, resume, rescope, slots, target version, models, caps, owners, delete |
| Agent queue | queued agent tasks by priority, required labels, model, "no matching runner online" flag | reprioritise, edit required labels and model |
| Runs | per task: runner, adapter, model, duration, outcome, summary, PR link | cancel, requeue |
| Progress | epics and milestones, including agent tasks | existing views |
Reliability¶
- Runs as a native service — systemd, launchd or a Windows Service — installed
with
agent-runner service install, restarted by the service manager on exit. - Per-run timeout; a run past it is killed and finished as
failed. - On shutdown or before an update the runner drains: stops claiming, lets
active runs finish up to a timeout, then exits. Amended 2026-10-04: the
timeout is five minutes; during a self-update specifically, heartbeats keep
going throughout and the runner reports state
updatingrather than just going quiet (see Self-update). Amended 2026-10-05 (agent-runner task #428): only a shutdown drain — service stop, system shutdown, Windows pre-shutdown — has the five-minute limit, after which the runs left are cancelled. A self-update drain stops claiming and waits until the active runs finish on their own, however long that takes (each is still bounded byrun_timeout); nothing is cancelled. See Self-update. - On startup it finishes any runs it still owns from a previous process as
failedwith a "runner restarted" summary. Since ADR-0011 decision 3 (agent-runner v0.5.10), those runs and the runs a shutdown drain cancels carry the reasonrunner_restart, which requeues their tasks instead of parking them. - If Taskbase is unreachable it backs off and keeps active runs going; leases
that expire meanwhile are resolved as
lostby Taskbase. Amended 2026-10-06 (Taskbase #473): a failed heartbeat is retried after 15 seconds, doubling up to the two-minute interval, against a 10-minute lease.
Self-update¶
- Releases are published to Gitea Releases on
Skatzi/agent-runnerby goreleaser: binaries for windows, linux and darwin on amd64 and arm64, a checksum file, and a signature over it. - Taskbase holds a single target runner version, set by an administrator and returned in every heartbeat. Rolling out is setting it; rolling back is setting it to an older release (amended 2026-10-10: one of the newest 10 kept — see the release retention amendment below).
- When the target differs from its own version, the runner downloads the release, verifies the checksum and the signature against a public key compiled into the binary, drains, replaces its executable, and exits for the service manager to restart it.
Amended 2026-10-04 — as built (Taskbase #319 and #323): the single target is
now an instance-wide default plus an optional per-runner override,
both set by global administrators (amended 2026-10-09: a runner's owners may
set its override too). A runner's effective target is its
override, else the default, else none; register and heartbeat answers carry
only that. This lets one runner try a release, or stay back, while the rest
follow the default. Taskbase also accepts only a target it can see on Gitea as
a usable release — non-draft, non-prerelease, v0.2.0 or later, signed and
built for all six platforms — so an administrator cannot point runners at a
tag they would fail to install. The settings and release list are described in
Runners and Runs.
Amended 2026-10-04 — as built (agent-runner task #209): there are two
triggers for the one path above. The Taskbase target is one; the other is
agent-runner update [--version vX.Y.Z], used by operators and the
desktop app, which updates the executable it is run as and
restarts the service if one is installed and running — stopping it drains
first — useful with no target set, or to move ahead of one. Either way:
- Guards. Only a target of the form
v<semver>is acted on; anything else is logged and ignored. A development build (a commit-hash version) updates whenever a target is set, which is how a source-built machine moves onto releases. A target older than the running version is a rollback, handled the same way as any other update. - Download. The release is resolved through the Gitea Releases API on
Skatzi/agent-runnerwith the runner's own Gitea token, since the repository is private — the token never leaves the configured Gitea host. The binary,checksums.txtandchecksums.txt.minisiggo to<data_dir>/update/. - Verification, before anything drains: the minisign signature over
checksums.txtagainst the public key compiled into the binary, the downloaded binary's SHA-256 against that file, and running the staged binary'sversionmust print the release tag — which catches a wrong-platform or mis-stamped binary that would otherwise update in a loop. - Failure leaves the current version running: the reason is logged and
kept in
state.json(shown byagent-runner status), and that version is retried no sooner than an hour later; a different target is tried at once. Amended 2026-10-05 (agent-runner task #378, Taskbase #313): the failure is also reported to Taskbase. Register and every heartbeat carry an optionalupdate_errorobject{version, error, retry_at?}while the runner's last self-update to its current Taskbase target failed;erroris trimmed and cut to 1 KB on a UTF-8 boundary. The field is omitted — which clears it in Taskbase — once a retry is in progress, the update succeeds, or the target changes. Taskbase stores the latest one inrunners.update_error(migration 040) and shows it on the runner's card on the Runners page ("update to v0.2.0 failed: … — retrying at 14:05");get_runnerandlist_runnersreturn it. Amended 2026-10-06 (agent-runner task #488, PR #138): a release that exists but lacks a file the update needs — the platform binary,checksums.txtorchecksums.txt.minisig— or answers 404 for one is most likely being re-signed by the macOS job. That version is retried after 1, 2 and 4 minutes, and after that the hourly retry applies. Other failures (bad signature, checksum mismatch, wrong version, release not found) keep the hourly retry. A different target is still tried at once.retry_atinupdate_errorreflects the shorter wait. This applies to updates to a Taskbase target;agent-runner updatereports the failure and does not retry. - Replace: the new binary is written beside the executable with its file
mode, fsynced, then renamed over it. On Windows, which cannot overwrite a
running executable, the runner first renames it to
agent-runner.exe.old, removed on the next start. - Restart: the process exits for the service manager to restart it —
launchd's
KeepAlive, systemd'sRestart=always, the Windows service's recovery action; one started by hand in a terminal just exits. Automatic rollback when the new version fails to come back stays deferred, as before. - Releases before self-update (v0.1.0) need one manual replacement of the executable.
Amended 2026-10-05 (agent-runner task #428, PR #113): the drain before a
self-update to a Taskbase target has no time limit. The runner stops
claiming and waits until its active runs finish on their own, however long
that takes — each is still bounded by run_timeout — and cancels nothing.
Heartbeats keep the runs' leases alive and the runner reports state
updating; state.json and status --json show the update phase
draining with active_runs, the number of runs it waits for. A busy runner
can therefore be given a new target at any time: it updates once it is free.
- If the target changes back, or is cleared, while it waits, the runner claims again and installs nothing; a different new target starts that update instead. Neither counts as a failed update.
- The five-minute limit and the cancel apply to shutdown only — service stop, system shutdown, Windows pre-shutdown. A shutdown during an update drain follows the shutdown rules and installs nothing.
agent-runner updaterestarts the service, so it drains as for shutdown.
This is agent-runner v0.5.10; runners on v0.5.9 or earlier still drain for at most five minutes before an update.
Releases are produced in two stages: a Linux Gitea Actions job runs
GoReleaser, then signs GoReleaser's own checksums.txt with minisign and
publishes the release right away, so every tag is usable without
waiting on a Mac — scripts/publish-release.sh downloads nothing from the
release itself; a macOS job later builds the desktop app,
adds its zip's checksum to checksums.txt and re-signs it — until that job
runs, the release simply has no app zip.
Amended 2026-10-05 (Taskbase #340, agent-runner PR #73): the release boundary
as built. GoReleaser only builds the six runner binaries and checksums.txt.
It creates the release as a draft and signs nothing. The signature comes from
the release workflow's own minisign step. PR #73 first had the macOS job sign
and publish the draft, so a Mac outage held back every release. Agent-runner
commit 9fd1d069 then moved signing and publishing to the Linux job, as
described above. The macOS job only adds the app zip and re-signs. It runs on
a dedicated instance-wide macos-arm64:host runner under its own macOS
account. That account is kept apart from the agent runner's account and
secrets. See macOS Release Runner
for its access boundary, secret exposure and removal.
Amended 2026-10-06 (agent-runner task #488, PR #138): scripts/publish-release.sh
no longer replaces a release's files in place. It uploads the new files as
<name>.new first, then deletes each old asset and renames its replacement
(PATCH …/releases/{id}/assets/{attachment_id} with name). A runner
updating while the macOS job re-signs therefore finds checksums.txt missing
only between those two API calls, and the short retry above covers that gap.
Leftover .new files from an earlier attempt are removed at the start of a
run.
Amended 2026-10-10 (agent-runner task #742, PR #166): releases are retained
up to a limit. The release workflow's last job, prune, runs only once every
other release job — GoReleaser, the macOS desktop job and the container
image — has succeeded. It runs scripts/prune-releases.sh, which keeps the
newest KEEP_RELEASES (10) published vX.Y.Z releases by semver and deletes
older ones with their files. Drafts, tags of another form and the tag being
released are never deleted. Taskbase's target picker lists only the releases
that remain, so a rollback through a Taskbase target reaches back only as far
as the oldest kept release. Older versions remain as git tags, because Gitea
1.25 keeps the tag when a release is deleted, but they cannot be installed
through self-update without a release.
Desktop app¶
Amended 2026-10-04 (agent-runner task #246): Agent Runner.app, a macOS
menu-bar app for the machine the runner runs on, is a separate program from
the runner engine and its own Go module (desktop/go.mod), which keeps the
runner's release build CGO_ENABLED=0 and the GUI toolkit's cgo dependency
out of it.
It reads and controls the runner only through its CLI — agent-runner
status --json, service start|stop|restart, update --version and
app-update — never the runner's config, secrets file, or Taskbase/Gitea
credentials directly, and it does not reimplement updating. status --json
carries data_dir and taskbase_url so the app can open the log folder and
Taskbase's /runners page without reading the config. First-run setup
(task #305) writes credentials into the runner's own secrets file,
not the macOS Keychain.
Toolkit: Go with fyne.io/systray (cgo on macOS, pure Go on Windows and
Linux; the macOS and, since task #359, Windows builds are packaged — see the
amendment below). Start-at-login is a per-user LaunchAgent
(com.skatzi.agent-runner-desktop) on macOS and the AgentRunnerDesktop
value under HKCU\Software\Microsoft\Windows\CurrentVersion\Run on Windows.
v1 is unsigned and
not notarised — for local use on a machine that already runs the runner.
(Since task #688 the app also installs the runner itself: see the
installers amendment below.)
App self-update (task #325, agent-runner issue #62): the app follows the
runner's own release version rather than having one of its own. The runner
owns the mechanics — agent-runner app-update --check and --version
vX.Y.Z --path ... — reusing the same minisign key and checksum file as the
runner's own update, verifying the signed app zip, clearing macOS's
quarantine attribute, and swapping the bundle; the app itself retains no
release credentials. A release with no app zip (the macOS build has not run
yet) offers no app update.
Amended 2026-10-06 (agent-runner task #359, PR #112): the Windows app is
packaged and released. The same app runs in the Windows notification area
(epic 28). Because the tray library is pure Go on Windows, the release
workflow's Linux job cross-builds it — no Windows build machine — as
Agent-Runner_windows_amd64.zip and Agent-Runner_windows_arm64.zip. Each
holds agent-runner-desktop.exe, with an embedded icon and a version resource
whose product version is the release tag (the same version the runner
reports), and a short README.txt.
checksums.txtand its minisign signature cover every app zip on the release. The Linux job signs the six runner binaries plus the two Windows zips and publishes the release; the macOS job later addsAgent-Runner_darwin_arm64.app.zipand signs again, taking the binaries' and Windows zips' checksums from the Linux job's outputs, so CI still never downloads release assets.- The Windows app is not code-signed in v1: SmartScreen may block the first
start, and the user chooses More info → Run anyway after checking the
zip against the signed
checksums.txt. - App self-update on Windows (task #360) is not built yet; the update entry is hidden from the menu there. (Built since: see the next amendment.)
This is agent-runner v0.5.10; v0.5.9 and earlier releases carry no Windows app zip.
Amended 2026-10-06 (agent-runner task #360, PR #128): the Windows app updates itself through the runner, as the macOS app does. The runner still owns all release access and verification; the app keeps no release credentials.
agent-runner app-update --check|--version vX.Y.Z --path C:\…\agent-runner-desktop.exepicks the release'sAgent-Runner_windows_<arch>.zipfor the runner's own architecture. It verifies the zip against the minisign-signedchecksums.txtas for the macOS zip, and checks thatagent-runner-desktop.exeis a PE executable for that architecture whose version resource ProductVersion equals the tag.- The runner stages the new
.exebeside the app, renames the running.exeaside toagent-runner-desktop.exe.old— a running executable cannot be overwritten but can be renamed, the same procedure as the runner's own Windows self-update — renames the new one into place, and restores the old one if that fails. - The app starts the new
.exewith the same flags and quits. The new copy removes.oldand any staging leftovers on start, retrying while the old copy exits. - Updates are offered only to an app named
agent-runner-desktop.exe(the release zip's name), so development builds are never replaced. The app's folder must be writable by the user running it.
Real-Windows verification is agent-runner task #361.
Amended 2026-10-09 (agent-runner tasks #687, #688 and #689, PRs #157, #158 and #160; decision #683): the runner installs without a terminal. A person downloads one installer per OS from the release and needs no command line. Decision #683 chose installers only: the app keeps today's setup wizard, and nothing was added to Taskbase. The Keycloak user, Gitea token and Taskbase runner are still created first, as before.
- The app download carries the runner, which is copied into a folder the
user owns. The runner's self-update renames a new binary
beside its executable, so the service must run a copy the user can write,
and not one inside an app bundle (replacing a file there would break a
signed bundle's signature). The bundled copy is therefore only a seed. An
installed runner is never replaced by it, whether older or newer, and keeps
following Taskbase's target version. A machine set up earlier with a runner
elsewhere (e.g.
/usr/local/bin) keeps using that one. - macOS:
Agent-Runner_darwin_arm64.dmg, holdingAgent Runner.appand an Applications alias to drag it onto. No.pkgand no root step. The app carries the runner of the same tag asContents/Helpers/agent-runner. When it finds no runner on start, it copies that one to~/Library/Application Support/agent-runner/bin/agent-runner, which is then the app's default--runner. The service is unchanged: the per-user LaunchAgent of the user running the app, installed without sudo, which runs that copy. The.dmgis for the first install only; app updates still swap the bundle from the.app.zip. The macOS release job builds both. - Windows:
Agent-Runner_windows_<arch>_setup.exe, a per-user NSIS installer with no administrator prompt. It installsagent-runner-desktop.exeand the runner of the same tag asagent-runner.exeinto%LocalAppData%\Programs\agent-runner\, a folder the user can write, with a Start-menu shortcut and an uninstall entry under HKCU. Running a newer installer over an install keeps anagent-runner.exethat is as new or newer, and renames an older one aside. The Linux release job builds the installers withmakensis, beside the zips (which now also carryagent-runner.exe), andchecksums.txtcovers them. The service is unchanged: a Windows service running as the installing user, installed by the wizard through the existing elevation and password hand-off. - The uninstaller stops and removes the service through one
administrator prompt (
agent-runner service uninstall), then removes the files, the shortcut and the start-at-login value. It keeps the config and secrets unless the person ticks a box, and always keeps the workspaces and logs. If the service cannot be removed, it removes nothing. - First-run setup stays the existing wizard. Both installers end in the app, which opens the wizard when there is no config.
- Signing: both installers ship unsigned. On macOS the person opens
the app once through System Settings → Privacy & Security → Open
Anyway. On Windows they choose SmartScreen's More info → Run anyway
after checking the download against the minisign-signed
checksums.txt. Apple Developer ID signing with notarization (agent-runner task #691) and Authenticode signing (task #692) follow once a person has the credentials.
Real-Windows install, upgrade and uninstall are untested until agent-runner task #711 is done.
Container runners¶
Added 2026-10-09 (epic #46). How to set one up is in Run a runner in the
cluster; the manifests are
components/agent-runner/ with one overlay per runner under
cluster/<cluster>/agent-runners/. Since 2026-10-14 (task #975) each runner
is a Flux HelmRelease of agent-runner's own Helm chart, with the OpenBao
secrets, the Codex login sync and the Cilium policies added by the component;
the pod and the decisions below are unchanged.
Why. Every runner so far was a person's own machine. Someone without a
machine they can leave running — the first is a friend working on europehub
in organization Emmalia, with only a ChatGPT subscription — still wants their
own runner, using their own subscription and scoped to their own
organization. The runner therefore also runs as a pod on hetzner-mgmt: one
Deployment per runner, replicas: 1 with strategy Recreate, so two pods
never act as the same runner. Everything else is unchanged — the runner is an
ordinary Keycloak user with a Gitea account, created in the control room with
the person as its owner and the person's organization as its scope.
Updates: by image, not self-update. A pod's root filesystem is read-only
and is replaced on every restart, so the runner cannot replace its own
executable. Container mode (AGENT_RUNNER_CONTAINER=1, set in the image)
turns self-update off and reports update_mode: "image" in registration and
every heartbeat. Taskbase then ignores the instance default and any override
for that runner, refuses to set a target for it (409), never reports a
version mismatch or update_error, and the Runners page shows Updated by
image instead of the target controls (Runners and
Runs). New versions
arrive as image tags: agent-runner's release workflow pushes
harbor.prod.skatzi.com/skatzi/agent-runner:<tag> (and latest) for every
v* tag, together with the Helm chart of the same version, and a person
rolls a runner forward or back by changing its chart version
(agent_runner_version) — a pull request, reconciled by Flux. The same image carries the
Codex CLI and the Claude Code CLI, so it serves either provider. Container
mode also logs to stdout only, refuses the service-manager and desktop-app
commands, reads its config from /config/agent-runner.yaml, and on SIGTERM
stops claiming, lets running runs finish within shutdown_grace (25 minutes)
and otherwise releases their leases so the tasks go back to the queue; the
pod's terminationGracePeriodSeconds is 1800 to cover that. Its liveness
probe is agent-runner healthcheck, healthy while the last heartbeat is under
two minutes old.
Login: kept in OpenBao, not on a volume. There is no persistent volume
(decided 2026-10-09): /data — workspaces, state and HOME=/data/home — is
an emptyDir on the node's disk and is lost with the pod, which costs
nothing because every run clones fresh. The one thing that must survive a
restart is the agent's subscription login. Codex keeps its ChatGPT login in
~/.codex/auth.json and rotates the refresh token when it refreshes, roughly
weekly, so a read-only copy in a Secret would go stale and force a new login
after the next restart. Instead the pod seeds it and writes it back:
sequenceDiagram
participant OB as OpenBao
participant ES as External Secrets
participant Seed as seed-codex-auth
participant Codex as runner and Codex
participant Sync as codex-auth-sync
ES->>OB: read the stored Codex login
ES->>Seed: login mounted as a file
Seed->>Codex: copy to auth.json, mode 0600
Codex->>Codex: refresh rotates the token
Sync->>Sync: poll every 60 s, compare hash
Sync->>OB: AppRole login, kv put the new auth.json
- An init container copies the stored login into
~/.codex/auth.json; on the very first start there is none and the runner starts without it. - A native sidecar polls the file every 60 seconds and, when its hash
changes, writes it to OpenBao with its own AppRole, whose policy allows
only
create,updateandreadon that one runner's login path. The AppRole credentials are mounted into the sidecar only, never into the runner container. Being a native sidecar, it starts before the runner, stops after it and checks once more on SIGTERM. - The person logs in once with Codex device authentication: an
administrator runs
codex login --device-authin the pod, and the person enters the code shown on their phone. Nobody else needs their ChatGPT password. - The runner's Keycloak password and Gitea token are ordinary External
Secrets mounted as files (
password_file,gitea_token_file). - If the pod restarts within about two minutes of a token refresh, the seed may be the previous login and Codex asks for a new one; with refreshes about weekly, that is accepted.
Only the Codex write-back is built. A Claude container runner would use the long-lived Claude setup token, which does not rotate, as one more file from the runner's External Secret — no write-back needed. That is deferred until a Claude container runner is wanted.
Isolation, and why it matters on hetzner-mgmt. Agents run arbitrary code from repositories — tests, scripts, package installs — with approvals bypassed. hetzner-mgmt also hosts Gitea, OpenBao, Keycloak, Harbor and Taskbase, so a pod that could reach their in-cluster services, the Kubernetes API or the node would put the whole platform within reach of any repository an agent works on. On a person's own machine the blast radius is that machine; here it would be everyone's. The pod is therefore locked down:
- its own namespace
agent-runners, with Pod Securityenforce: restricted; - no service-account token (
automountServiceAccountToken: false) and no service links; - non-root (uid/gid 10001), a read-only root filesystem, all capabilities
dropped,
seccompProfile: RuntimeDefault; - resource limits — 2 CPU, 4 Gi memory and 20 Gi ephemeral storage for the runner, set per overlay;
- a Cilium network policy: no ingress; egress only to DNS, the internet
(
world) on 80 and 443, and the platform's public hostnames on 443 (Taskbase, the MCP server, Gitea, Keycloak, and OpenBao for the sidecar). Everything else in the cluster is denied by default, and thehost,remote-nodeandkube-apiserverentities and the private and link-local ranges — including the Hetzner metadata service169.254.169.254— are denied explicitly. The platform hostnames resolve to the shared gateway, so the policy also allows the gateway'singressidentity. The gateway's Envoy enforces the pod's egress policy again on its hop to the route's backend, so the backend pods of those hostnames are allowed as well, each on its HTTP port only (Taskbase API and MCP, Gitea, Keycloak, OpenBao). The pod thereby reaches the same APIs the internet does, also directly, but never their databases, other ports or any other pod (found on 2026-10-10: without these rules every platform hostname answered403 Access denied).
The accepted risk (accepted 2026-10-09). This is a namespace boundary on
shared nodes, not a separate machine. A container escape or a Kubernetes or
Cilium vulnerability would put an agent on a node next to the platform's
services. Within the pod, the agent can read and modify the runner's own
Codex login and read its Keycloak password and Gitea token — the same reach
an agent has on any runner, limited to this runner's identity, whose access
Taskbase already confines to the run's organization. Once the job
sandbox is in the image (2026-10-28, task #1941), Landlock keeps
the agent out of /secrets and /config, so it keeps only the Gitea token it
is handed and its home's Codex login. And everything the
platform exposes publicly, the agent can reach too, exactly as anyone on the
internet can. Until the network-policy verification and the restart test are
done on the cluster (task #722), the overlay stays at replicas: 0.
Deferred, with triggers (also in the table below):
- a Codex/Claude login flow in the Taskbase UI, where the runner shows a device code to its owner — when a second container runner is added, or kubectl-assisted login becomes a chore;
- a browser-capable image (Playwright/Chrome,
browserlabel) — when container runners need browser tasks; - Postgres or Docker for tests inside the pod — when a repository's tests cannot run without them;
- a separate cluster or node pool for agent runners — when there is more than one container runner, or the isolation proves insufficient.
Revision to ADR-0005¶
ADR-0005 principle 1 reads "the brain is a priority dispatcher, not a state tracker". This ADR splits that in two:
- Execution state is tracked by Taskbase — runners, leases, runs, and a task's
dispatch_state. The control room needs it, and only Taskbase sees every runner. - Workflow state is still not — review, merge and done remain the target repo's business, mirrored by the Gitea sync, exactly as ADR-0005 decided.
Implementation order¶
- Taskbase — the ADR-0005
agent_typessync; then runners, labels, claims and leases; then runs and the control-room views. agent-runnerv1 — service install, register, heartbeat, claim, one adapter (Claude), the MCP proxy, workspaces.- Releases and self-update.
- A second adapter — the proof of provider independence.
What we deferred (and what would trigger adding it)¶
| Concept | Trigger to add |
|---|---|
| Organizations opting out of instance runners | An organization needs its work kept on its own machines |
| Project-scoped runners | A repository needs machines no other project in its organization may use |
| Editing runner labels from the Taskbase UI | Changing a label by editing a machine's config becomes a nuisance |
| Default required labels per persona | Most tasks for a persona are given the same labels by hand |
| GPU auto-detection | Hand-maintained labels drift from the real hardware |
Label values and comparisons (vram>=16) |
A real requirement can't be expressed as plain labels |
| A sandbox on Windows (AppContainer or a restricted token) | An organization's secrets must go on a shared Windows runner |
| A container or VM per task, beyond the job sandbox | An agent damages its host through what the sandbox leaves open (network, system directories) |
A Gitea user and token per organization on instance runners, chosen per run like job_env |
An organization not run by the instance's administrators uses instance runners, or one organization's repositories must be kept from another's jobs |
| Checking that an organization runner's Gitea user reaches only its organizations | A runner's Gitea user is found with wider access than its scope |
| Distinct identity per persona | Personas on one runner need different grants |
| Choosing the model automatically from the task | Picking a tier by hand becomes the bottleneck, or is routinely wrong |
| Token and cost reporting per run | Model choice needs data rather than judgement |
| A default effort per persona or per project | Most tasks of one persona or project get the same effort by hand |
| A separate effort for review runs (project review settings) | Reviews are routinely too shallow or too slow at the task's effort |
| Raising effort automatically when a run fails (like model escalation) | Failed runs often succeed on retry with more effort |
Effort levels beyond high (xhigh, max) |
A task needs more than high and the adapters offer it |
| Runners reporting which adapters honour effort | A task's effort is silently ignored because the adapter has no mapping |
| Falling back to another tier when none is online | Tasks wait for a model while other capable runners sit idle |
| Automatic retry of failed runs | Most failures turn out transient and requeueing by hand is a chore |
| Live log streaming to Taskbase | The run summary is not enough to debug failures |
| Update channels and automatic rollback | A bad release actually strands runners |
| A single setup page that checks every value live, replacing the wizard (considered for the no-terminal install, declined by decision #683) | Setup mistakes found one at a time by the wizard's check become a real support burden |
| A Taskbase setup code and a discovery API listing the runners a user may register as (declined by decision #683) | Copying the runner name and service URLs into the wizard by hand causes failed setups |
| Creating the Gitea token from the app with the account's password (declined by decision #683) | Creating the Gitea token by hand is the step people get stuck on |
| A Codex/Claude login flow in the Taskbase UI, the runner showing a device code to its owner (container runners, epic #46) | A second container runner is added, or kubectl-assisted login becomes a chore |
A browser-capable container image (Playwright/Chrome, browser label) |
Container runners need browser tasks |
| Postgres or Docker for tests inside a runner pod | A repository's tests cannot run without them |
| A separate cluster or node pool for agent runners | There is more than one container runner, or the namespace isolation proves insufficient |
| Writing back a Claude login for container runners | A Claude container runner is wanted and its setup token is not enough |
Each is additive — none requires changing the v1 schema.
Links¶
- ADR-0005 — Taskbase Agent System (revised by this ADR)
- Taskbase MCP Server — user login through
agent-login - Taskbase Authentication — organization grants