0014 - Preferred Models with a Size-Tier Fallback, and Per-Project Model-Selection Policy¶
Status¶
Accepted 2026-10-12. Proposed the same day (Taskbase task #842, epic #53, request #836). The owner (dunk) accepted it as proposed in Taskbase decision task #843: a preferred_models list with the size-tier fallback applied at claim time (Decision 1, option A), and .taskbase/model-policy.md served with the default policy by get_model_policy (Decision 2, option P1). Planning task #844 created the implementation tasks. Builds on ADR-0006 (providers and models), ADR-0008 (subscription holds) and ADR-0011 (caps and the per-run session share).
Shipped through the implementation tasks (Taskbase #858–#861, agent-runner #862, skatzi-agents #863) and documented in platform task #864. Where the merged code differs from the proposal, see As built.
Date¶
2026-10-12
Context¶
Request #836 asks for a model-selection policy: a document that names, per use case, the model a task should run on, in order of preference. The first confirmed rule: visual content (logos, images, graphics) runs on Astra when available, else Sol. The default policy lives in the platform docs (sibling task #841). Projects may override or extend it. The owner set two constraints:
- The size tier (
small/medium/large) stays the capacity fallback. A task that names a model must still run, on its tier, when that model's subscription or provider has no capacity. - The override mechanism is open. This ADR picks it.
The project manager (PM) applies the policy when it creates and sizes tasks. It runs in a clone of the request's project repository with the Taskbase MCP tools. It has no clone of the platform repository.
What exists today (Skatzi/taskbase, read 2026-10-12)¶
| Fact | Where |
|---|---|
A task has one model: a tier or a model id. Without one it takes its persona's default_model, else the runner's default. |
Candidate.ownModel, ownModelSQL in api/internal/runner/escalation.go |
Runner.Resolve walks the runner's adapters in reported order, skips held subscriptions, and takes the first model whose id or tier matches. A tier therefore already falls back across adapters: large runs on Opus, or on Astra when the Claude subscription is held (claim_limits_test.go, "large fallback"). |
resolveWith in api/internal/runner/match.go |
| A task pinned to a model id matches only that id. While its subscription is held, no runner can claim it and it waits; there is no fallback. | canClaim; SQL effectiveModel = ANY(availableModels) in PostgresStore.Claim |
| A model id nobody offers parks the task through the unclaimable-queue sweep ("No online runner offers the required model …"). | unclaimableReason, #289 |
Escalation raises tiers only, one step per qualifying failure, capped at large. A model id never escalates. A project turns it off with escalate_models. |
escalate, escalatingSQL, #281 |
| Complexity points come from the task's own tier when none are set. A task pinned to a model id is unsized in the trends and cohorts. | taskPoints, cohorts.go (epic #26) |
Runs record model (resolved), requested_model and escalated_from. |
task_runs |
Reviews run on the project's review_model, not the task's model. |
isReview branch of the claim |
Taskbase already reads files from Gitea through the contents API, for personas in Skatzi/skatzi-agents. |
api/internal/gitea/contents.go (ReadFile) |
Projects have gitea_repo; no setting holds text like a policy. |
internal/project/model.go |
| The PM persona says: "Always set the size, never a specific model". | skatzi-agents/personas/project-manager.md |
So today the PM must choose between a model id with no fallback (and an unsized task), or a tier with no say in the model. The policy needs both.
Decision 1 — How a task names preferred models and keeps its tier¶
Options considered¶
| Option | For | Against |
|---|---|---|
A. New field preferred_models (ordered model ids) beside the tier in model (recommended) |
The tier keeps its meaning everywhere: complexity points, escalation, persona defaults, the unclaimable sweep. Preference is additive: an empty list behaves exactly as today. Easy to show: "astra (preferred)" vs. "opus-5-5 (large, fallback)" | A new column, API/MCP field and claim logic in Go and SQL |
B. Turn model into an ordered list (["astra","sol","large"]) |
One field | Every reader of model changes: points, escalation (which entry escalates?), persona defaults, requested_model, the UI, effectiveness grouping. The tier is just "the last entry", easy to leave out, which brings back the waiting task |
| C. The PM checks capacity when it assigns and writes either the model id or the tier | No Taskbase change | Capacity changes between assignment and claim, often by hours (a task waiting on depends_on). The PM cannot see runner limits (list_runners is refused to run-scoped agents). A task assigned "astra" while Astra was free waits when Astra is held later |
| D. Do nothing in Taskbase; the PM sets tiers and the policy maps use cases to tiers only | No change | Cannot express "Astra, else Sol": both are tiers of the same adapter. Fails the confirmed rule |
Recommendation: A¶
Data. tasks.preferred_models TEXT[] NOT NULL DEFAULT '{}': model ids in order of preference, at most 3, no tiers, no duplicates. tasks.model stays the tier (or the persona default when null). Setting preferred_models while model holds a model id (not a tier) is rejected: the fallback must be a tier. API, MCP (create_task/update_task, kept when omitted, [] clears, like required_labels) and the UI expose it.
Claim rule. For an implementation run, a runner claiming the task:
- Takes the first preferred model that this runner offers on an unheld subscription (
availableModels), and runs it. - Else, if a preferred model earlier in the list than any this runner could run is offered on an unheld subscription by another viable runner that serves the task's organization (recently seen,
desired_staterunning, ADR-0008/0011 hold and cap test), this runner leaves the task for that runner. - Else (every preferred model is held everywhere, or offered nowhere) it runs the task's effective tier exactly as today, through
Resolve's adapter order.
"No capacity" therefore means what Taskbase already measures: the subscription is held (reported limit, manual hold, or a cap reached including the per-run session share). Busy slots do not count. A task that prefers Astra waits for a free slot on a runner with unheld Astra, as a task pinned to a tier waits for any slot today. Step 2 uses the runner rows Taskbase already stores, and counts only runners that pass canEverClaim for the task (scope, required labels, dedicated label), so a runner the task could never go to does not hold it back.
A preferred model that no runner offers never parks the task; it is skipped, and the tier runs. The unclaimable sweep keeps checking only the tier.
Escalation. Escalation keeps raising the tier only. While a task is escalated (model_escalation > 0), a preferred model is used only if some runner reports it at the effective tier or above; otherwise it is skipped and the escalated tier runs. Example: prefer sol (medium) on a medium task. After an escalation the run asks for large; Sol is skipped, Astra (large) is used if preferred, else the large tier. Rationale: escalation means "the work fell short, use a heavier model"; repeating the same lighter model contradicts it. With escalate_models off, preferences always apply.
Reviews keep the project's review_model. Preferred models apply to implementation runs only.
Points. Unchanged: from complexity_points, else the tier. Because the PM always sets a tier, tasks with preferences are sized.
Showing the choice. task_runs gets preferred_models (the list at claim time) and model_choice: preferred, fallback (a preference existed and the tier ran) or tier (no preference). The runner page, task page and run history show the resolved model with the choice ("gpt-6-astra · preferred", "claude-opus-5-5 · large fallback"). get_model_effectiveness gains model_choice as a filter, so the policy's rules can be checked against their fallbacks. The agent-runner logs the claim's model already; it needs no change for the rule, only to log model_choice if Taskbase sends it.
Persona defaults. Personas keep a tier default_model. Preferences come from the policy, per task, set by the PM; personas do not get preferred models in this ADR.
Decision 2 — Where the effective policy comes from, and how a project overrides it¶
Options considered¶
| Option | For | Against |
|---|---|---|
P1. Policy as code in Git; Taskbase serves the effective policy (recommended): default page in Skatzi/platform, optional override file at a fixed path in the project's gitea_repo; a new MCP tool/API get_model_policy(project_id) returns both, with sources and commit SHAs |
Policy changes go through PR review, like everything else (Everything as Code). The PM makes one call; it needs no platform clone and no extra credentials. Reuses the Gitea ReadFile Taskbase already uses for personas. Works for any project and any persona that later needs it |
A small Taskbase endpoint, cache and MCP tool. The merge of rules is done by the PM from text (see below), not by code |
| P2. The PM fetches the platform doc itself (raw Gitea URL or shallow clone) plus the file in its own clone | No Taskbase change | Depends on each runner's Git credentials reaching Skatzi/platform; another org's PM may have none. Every PM run repeats the fetch; failures are silent (the PM plans without a policy). The persona has to carry URLs and paths |
| P3. A project setting in Taskbase holding the override text | Editable in the UI; no repo file | Not as code: no review, no history beyond Taskbase's, and the default would still live in Git, so two systems hold one policy. More UI work |
| P4. Taskbase parses and merges the policy into the PM's claim | Deterministic merge | Needs a machine-readable rule format (YAML block) that the research page (#841) does not have; the claim payload grows for every PM run, including ones that create no tasks |
Recommendation: P1¶
Locations.
- Default: the policy page from #841 in
Skatzi/platform(planned pathdocs/content/contribution/guides/model-selection-policy.md; the endpoint reads the path from Taskbase configuration, so moving the page is a config change). - Project override:
.taskbase/model-policy.mdin the project'sgitea_repo, on its default branch. A dot-directory keeps it out of documentation sites that publishdocs/, and leaves room for later Taskbase files in the same place. A project without a repo or without the file uses the default.
Delivery. GET /api/projects/{id}/model-policy and the MCP tool get_model_policy(project_id) return {default: {repo, path, sha, text}, project: {repo, path, sha, text} | null}. Taskbase caches each file for 5 minutes by repo and path. If Gitea fails, it returns the last cached copy marked stale, or an error the PM reports; the PM then sets tiers only (today's behaviour), never guesses a model.
Merge: extend vs. override. Each rule in the default page has a stable use-case id (the first column of its rules table, e.g. visual-content). In the project file:
- a rule with an id that exists in the default overrides that rule entirely (its recognition text, its preferred models, or "size tier only" to switch preference off);
- a rule with a new id extends the policy;
- rules the project file does not name apply unchanged.
There is no whole-document replace: a project that wants none of the defaults names each one with "size tier only", which keeps the decision visible. When a task matches rules of both, the project rule wins; when it matches several new rules, the more specific one wins and the PM says which in the task. Otherwise the first matching default rule applies, from the top of its table down (settled in As built). The size tier is never part of a rule: it always comes from the persona table and is always set.
The PM does the merge from the two texts. That is enough for a handful of rules and avoids a rule format and parser. If the policy grows past what a model applies reliably (signs: PM tasks citing the wrong rule), a later ADR can add a machine-readable block and server-side merge (P4).
PM behaviour (persona change): call get_model_policy once per planning run; for each implementation task pick the persona, tier and effort as today, then match the task to a use case and set preferred_models from the effective rule; name the rule id in the task description ("Model policy: visual-content (project override)"). With no matching rule, set no preference.
As built¶
Recorded 2026-10-12 (platform task #864) from the merged code of the implementation tasks. Where this list and the proposal above differ, this list is right.
- Field.
tasks.preferred_models(migration 061) is checked as proposed: model ids only, at most 3, no duplicates, no spaces, andmodelmust be a tier or unset while the list is non-empty (400otherwise).update_taskandPUT /api/tasks/{id}keep the list when it is omitted ornull, and clear it with[](Taskbase #858). - Step 2 compares runners, not list positions. A runner that has any preferred model unheld runs the first of those (step 1), even when a model earlier in the list is unheld on another runner. A runner leaves the task only when it has none of the preferred models unheld and another runner has one. The proposal's "earlier in the list than any this runner could run" therefore reduces to "any preferred model elsewhere" (Taskbase #859,
chooseModel). - "Another viable runner" is a runner seen recently with
desired_staterunning, that serves the task's organization and passescanEverClaim: scope, required labels, dedicated label, and an offer of the task's effective tier (or of a default model when the task has none). The Go claim and the SQL claim (PostgresStore.Claim, which gets these runners as JSON) apply the same test. The organization queue'sno_runnerflag uses it too. - Escalation. As proposed. "Some runner reports it at the effective tier or above" is checked against the viable runners that serve the organization, including the claiming runner, using the highest tier each runner reports for the model. A model reported without a tier never qualifies while the task is escalated. With
escalate_modelsoff, the task never counts as escalated, so its preferences always apply. - Reviews record
preferred_models = '{}'andmodel_choice = 'tier'on their runs. Sotiermeans "no preferences applied", which covers reviews as well as tasks without preferences. - Run columns
task_runs.preferred_modelsandtask_runs.model_choice(migration 062) areNULLon older runs. The claim response carries both inrun. The agent-runner logsmodel_choicenext tomodelwhen Taskbase sends it (agent-runner #862). - Effectiveness filter.
model_choicefilters by the choice of each task's attributing run (its first succeeded implementation run that opened a pull request); runs from before migration 062 match no choice. BothGET /api/organizations/{orgId}/effectivenessandget_model_effectivenesstake it. The UI shows it on the Usage page's Models tab (Taskbase #861). - Policy endpoint. The default page's location is set by
MODEL_POLICY_REPOandMODEL_POLICY_PATH, which default toSkatzi/platformanddocs/content/contribution/guides/model-selection-policy.md. Theshaof each file is the file's blob SHA from the Gitea contents API, not a commit SHA. A file served from the cache after a Gitea failure carriesstale: true. A missing project file is cached like a present one, so a newly added override is picked up within 5 minutes. The endpoint answers404for an unknown project. It answers502when the default page, or an existing project's file, cannot be read and no cached copy exists. Run-scoped agents may call it for projects in their run's organization; another organization's project answers403(Taskbase #860). - Tie-break. The review of this ADR (#842) found that the policy page said "use the first matching row", while Decision 2 said "the project rule wins, then the more specific new rule". Both are now one rule, in this order: a matching project rule beats a default rule; among several matching new project rules, the more specific one wins, and the PM says which one it picked; otherwise the first matching default rule applies, from the top of its table down. The policy page and the PM persona (skatzi-agents #863) both say this.
- Use-case ids on the default page are slugs (
visual-content, …), replacing the numbers 1–9. The PM persona cites whatever the first column holds.
Taskbase's own documentation of the shipped behaviour is in Runners and Runs, MCP Server and the model-selection policy.
Consequences¶
- Tasks can follow the policy without ever waiting on a held subscription: the tier always remains, and Taskbase falls back at claim time, when capacity is known.
modelkeeps meaning "tier or model id". Pinned model ids still work and still wait, for the rare task that truly needs one model; the PM persona stops using them.- Complexity points and escalation work unchanged for tasks with preferences.
- Effectiveness data can compare a rule's preferred model with its fallback (
model_choice), which #841's evidence sections need for revisiting rules. - The claim gets one more condition (step 2) that reads other runners' state. The SQL filter gains the list of models available on viable runners of the organization, computed in Go as
availableModelsis today. - Policy changes are PRs in Git; Taskbase serves them within 5 minutes.
- Architecture diagram: no change. No service, store, queue or connection is added: Taskbase already reads from Gitea, and the PM already reaches Taskbase through MCP.
Implementation tasks¶
Build order: 1 → 2 → 3 → 4; 5 and 6 after 1–3; 7 after all.
| # | Repository (Taskbase project) | Task | Size |
|---|---|---|---|
| 1 | Skatzi/taskbase (2) | tasks.preferred_models column, validation (model ids only, ≤ 3, tier required), task API, MCP create_task/update_task field, OpenAPI |
medium |
| 2 | Skatzi/taskbase (2) | Claim rule (steps 1–3) in Go (canClaim, Resolve) and SQL (PostgresStore.Claim), escalation interplay, task_runs.preferred_models/model_choice; tests for held, offered-nowhere, other-runner, escalated and review cases |
large |
| 3 | Skatzi/taskbase (2) | GET /api/projects/{id}/model-policy and MCP get_model_policy with Gitea ReadFile, cache, stale handling; default path in config |
medium |
| 4 | Skatzi/taskbase (2) | UI: edit preferred models on a task; show resolved model with model_choice on task, run and runner pages; model_choice filter in effectiveness |
medium |
| 5 | Skatzi/agent-runner (12) | Log model_choice from the claim (only if task 2 sends it); no behaviour change |
small |
| 6 | Skatzi/skatzi-agents (14) | personas/project-manager.md: call get_model_policy, set preferred_models per the effective rule, keep setting tier and effort, cite the rule id; replace "never a specific model" |
medium |
| 7 | Skatzi/platform (1) | Accept this ADR with as-built notes; add the override section (file path, merge rules, use-case ids) to the policy page; document the claim rule in the Taskbase component docs | medium |