Agent Architecture¶
How Taskbase gets work done by AI agents: who decides what runs, where it runs, and how the result comes back. Two decisions define it:
- ADR-0005 — what an
agent is: a persona defined in the agents repository every organization shares (
Skatzi/skatzi-agents). - ADR-0006 — how agent work is
executed:
agent-runnermachines pull tasks from Taskbase, which acts as controller and control room.
This page is the overview. The runner API is documented in Runners and Runs, agent tools in MCP Server, and agent confinement in Authentication. The earlier push-based executor design with resumed sessions (ADR-0004) is superseded.
The pieces¶
graph LR
subgraph Hetzner cluster
TB["Taskbase - controller and control room"]
MCP["taskbase-mcp"]
GITEA["Gitea"]
end
subgraph A machine anywhere
RUNNER["agent-runner"]
PROXY["local MCP proxy"]
AGENT["agent program, one per task"]
end
RUNNER -->|register, heartbeat, claim, finish| TB
RUNNER -->|spawn in a fresh workspace| AGENT
AGENT -->|MCP with the run id| PROXY
PROXY --> MCP
MCP --> TB
AGENT -->|push branch, open PR| GITEA
RUNNER -->|clone| GITEA
| Piece | Responsibility | Does not |
|---|---|---|
| Taskbase | Holds the queue and its priority order; matches tasks to runners by scope, labels and model; tracks runners, runs and leases; hosts the control room | Know anything provider-specific, or decide review/merge/done |
| agent-runner | Registers a machine, heartbeats, claims one task per free slot, launches an agent program through an adapter, reports the outcome | Implement an agent loop, or keep state between tasks |
| Agent program | Does the task — reads the repo, edits, tests, pushes a branch, opens a PR, creates follow-up tasks | Outlive its task |
| Target repository | Owns the workflow: branch protection, review rules, CLAUDE.md conventions |
— |
All connections are outbound from the machine, so runners work behind NAT and home firewalls.
Context reuse keeps each run in a fresh session while storing a bounded handoff on the run. Taskbase stores neutral digest data and offers eligible same-task candidates in claims; the runner is responsible for checking freshness and rendering any prior-run note. See Runners and Runs, Usage Trends, and ADR-0009.
Taskbase digests and context-reuse counters are available. The runner handoff and freshness implementation and typed task links are still in review; the runner reference records the current PRs and the behavior not yet available.
Principles¶
- Pull, one task at a time. A task assigned to an agent is queued — available to any runner that can serve it, never lined up behind a particular runner. A runner claims one task per free slot (default one) and asks again only when a slot frees up.
- A fresh session per task. Every run gets a new agent process in a new workspace. Selected, bounded run digests can inform later work without resuming a session. The current task, persona and repository remain authoritative.
- Execution state in Taskbase, workflow state in the repo. Taskbase tracks runners, runs,
leases and a task's
dispatch_state. Whether work is reviewed, merged or done is decided by the target repository and mirrored by the Gitea sync. - Provider-agnostic. Runners launch existing agent programs through adapters and report adapter
name, provider, models and optional
subscriptionname. When omitted,subscriptiondefaults to the adapter name. Commands and credentials stay runner-local. A task names a model tier (small,medium,large) or a model id; the cheapest adequate tier keeps cost down. - Agents act only for their run. An agent reaches Taskbase through the runner's MCP proxy and is confined to the organization of the task it is working on.
- Failures park, they do not retry. A failed or cancelled run leaves the task
needs_attentionfor a human to requeue; a run lost to a silent runner goes back to the queue. A task still assigned to the project's review persona for implementation or revision — from before the project turned review on, or assigned there by mistake — is parked the same way the moment an eligible runner reaches it at claim time (guard). Editing it clears the reason shown, but reassigning it to an implementation persona and then requeuing it is what actually resumes the work.
A task's journey¶
- Assigned. A person or agent assigns an open task to an agent persona
(
assignee_type = 2,assignee= the persona's slug), optionally with amodelandrequired_labels. It becomesqueued. A project's review persona only ever reviews: assigning it to a task for implementation or revision is refused (MCP Server) — reassign the task to an implementation persona, or move it to Review to start a review instead. - Claimed. The next free runner in scope that has the labels and offers the model claims it:
a run starts with a 10-minute lease, the task becomes
dispatched, and the runner is told which adapter and model to use. - Worked. The runner clones the project's repository into a fresh workspace and launches the agent with the persona, the task and an MCP config pointing at its local proxy. Heartbeats every two minutes renew the 10-minute lease; a failed heartbeat is retried after 15 seconds.
- Finished. The runner reports
succeeded(with a summary and PR link),failedorcancelled. Succeeded leaves the task to the repository's workflow; failed or cancelled park it asneeds_attention. - Or lost. If no heartbeat renews the lease for 10 minutes, Taskbase marks the run
lostand returns the task to the queue (Timings).
Handing a task to an agent¶
In the task dialog, set the assignee type to Agent and pick the persona — the list comes from the shared agents repository, shown under each organization's Settings → Agents. With an agent assigned, the dialog also offers:
- Model — Persona default (X) when the assignee has a default model, Runner default otherwise, a size (small for routine work, medium for features, large for hard problems — the most expensive), or an exact model id reported by a runner that can serve the organization. Pick the cheapest that will do.
- Required labels — only runners with all of them take the task; usually empty.
Persona defaults are set in Organization settings → Agents: each persona card has a Default model picker.
A persona file may also suggest one with the optional frontmatter key default_model (a tier or model
id); the sync stores it only while the persona has no default in the organization, so a default
picked here is never overwritten (Gitea Integration).
Saving an open task with an agent assigned queues it; the next free runner that fits claims it.
Persona frontmatter¶
A persona is personas/<slug>.md in the shared agents repository: a --- frontmatter block, then the
markdown body used as the system prompt.
| Key | Required | Meaning |
|---|---|---|
name |
yes | Display name |
description |
yes | One line on what the persona is for |
kind |
no | task (default): implements tasks. session: only chats in agent sessions and is never given a task |
default_model |
no | A tier (small, medium, large) or model id. Stored as the organization's persona default only while that default is NULL; never overwrites one set in Taskbase |
Any other key, an unknown kind or an invalid model skips the file at sync, and the persona keeps its previous state.
Session personas¶
A persona with kind: session answers people in agent sessions instead of working on
tasks (ADR-0013). There are
three, one per subject: request-builder (default_model: small) for request chats,
attention-helper (small) for chats about a Needs attention task, and assistant (medium) for
general chats across organizations
(ADR-0016):
- Never a task. Assigning a task to it (create, update or request) answers
400. The claim, the unclaimable sweep, the Agent queue and the UI's persona pickers pass it over, andlist_agent_typesreports each persona'skind. A task assigned before its persona became a session persona stays editable until it is reassigned. - One short run per message. Each message the person sends becomes a turn. The runner the person chose for the session — one they own, or any in scope for an administrator — claims it through a separate long-poll, using a session slot rather than a task slot, on the model the person chose. The runner starts a fresh agent process in an empty directory with no clone, and replays the transcript and draft from Taskbase (Runners and Runs).
- Read-only, plus its draft. The agent's MCP requests carry
X-Taskbase-Turn, which confines them to GET routes of the organizations fixed at the turn's claim (the session's organization, or for a general chat the owner's reach ∩ the runner's scope), plus reading its own session and saving its draft (get_session,save_request_draft,save_action_plan; see MCP Server). It has no shell, file or web tools, and no secrets in its environment. - Nothing filed by the agent. Only the person's Confirm creates the request task, or runs an action plan as the person.
Control room¶
People steer the fleet from Taskbase: create runners and set their scope, pause, drain or resume them, cancel a run, and requeue a parked task. The endpoints are listed in Runners and Runs; the UI views are planned in the Taskbase control room epic.
Status¶
| Part | State |
|---|---|
| Runner API, claims, leases, cancel and requeue | Built (Runners and Runs) |
| Run-scoped agent access and MCP task fields | Built |
agent_types and persona lookup on claim |
Built — GET /api/organizations/{id}/agent-types, MCP list_agent_types |
| Session personas and chat-built requests (ADR-0013) | Built — Agent Sessions |
| One chat page, chosen runner and model, general chats (ADR-0016) | Built — Agent Sessions |
| Persona sync from the shared agents repository (ADR-0005, amended) | Built — every 5 minutes; see Gitea Integration. A push webhook is planned |
agent-runner itself |
Not yet — repository Skatzi/agent-runner |
| Control-room UI, releases and self-update | Planned |