ADR-0086: The composer chooses the model of the next turn¶
Status: Accepted, amended by ADR-0087 (on a phone the picker is a pill and a Select model sheet) Date: 2026-10-27 Deciders: Alex Nodeland Amends: ADR-0083 (the strip says when a turn answered with another model than it asked for)
Context¶
A message may name the model of the turn it starts (artifactr ADR-0097): the runner asks artifactr:use_model as the message's author, builds the model with the host's model_for, and answers with the agent's own model, with a notice why, where either says no. That record left three things to its phase D2: the host's list of the models a person may use, the composer's choice, and stackr's factory. Its requirements: model_for is a closed dict that raises LookupError for any other name; per-tenant narrowing is enforced where the turn is checked, not only in the picker, and the list and that check read one source; only default and fast are offered to every tenant by default; the picker is disabled or labelled while a run is active; a test sends a message naming a model the tenant isn't offered and sees the default answer with a notice.
The owner's answers: the choice is per message, pre-selected per thread with the thread's last model, remembered by the browser, else the default; where the runner falls back, the turn says quietly which model answered; a message that joins a running turn can't change its model.
Decision¶
- The application's models are a closed list. stackr's template reads
LITELLM_MODELS, a JSON list of{id, label, family, local, reasoning}, whereidis a gateway model group;defaultandfastare always on it, and an entry for either says how the picker shows it.Modelsis the runner'smodel_for: a listed name is built once, over the gateway, as the agent's own model is, with the smoke tests' mocked reply; any other name raisesKeyError, and nothing is built from a name a message gave. A listed model that islocalis counted local by the run's liveness limits. - Which of them a workspace allows is one setting,
models:allowed. A lattice-coreSubsetover the listed ids (lattice ADR-0030), registered beside lattice's settings: its default isdefaultandfast; the operator'sLITELLM_MODELS_ALLOWEDreplaces it as every tenant's ceiling; a tenant's and a workspace's admins only narrow it. With grantr, grantr's store holds the tenant's and workspace's layers; without it, the operator's value applies everywhere. A tenant can't be offered more than the operator offers every tenant: there is no per-tenant widening, as ADR-0030 has none. - The runner's check reads it.
Models.narrowed(authorize, settings)wraps theauthorizethe workspaces ask:artifactr:use_modelfor a listed model the workspace'smodels:allowedleaves out is refused, so the turn answers with the default and postsmodel_not_allowed's notice; a name not listed goes on tomodel_for, whoseLookupErrorpostsmodel_unknown's; anything else is the application'sauthorize's, or allowed without one. GET /portalr/v1/models?workspace=<id>lists them. portalr's router takes aModelshook,(tenant, workspace) -> [OfferedModel]; without it there is no route. The caller names the tenant withX-Tenant, or a key's own, and must holdartifactr:use_modelin the workspace, as the turn's own check asks; what is listed is what the hook answers, which the template reads from the samemodels:allowedthe runner's check reads. Each is{id, label, family, local, reasoning}: no gateway address, no key. The answer isno-store.- The composer's picker is an add-on, loaded on its first focus. The thread's page listens for the composer's first
focusin; then it loadsapp/src/on-demand/model-picker.tsxand the models, never as the page loads. The picker is the kit'sSelectField, labelled "Model", in the composer's row beside the agent's mode (ADR-0085); it is hidden where the workspace allows one model, or the list can't be read. It starts on the model last chosen in the thread, which the browser keeps asportalr:model:<thread>(read and written intry, so storage that can't be used keeps the choice for the page), when the workspace still allows it, else on the default, or, where the workspace'smodels:allowedleaves the default out, on the first model it allows, so nothing is ever shown unchosen. A message namesmodelonly when it isn't the default. While a run is active, running or paused, the picker is disabled, and its hint, "The running turn keeps its model", describes it (aria-describedby). Its keyboard is the kit's select's, and a finger gets the kit's 44 px. - A fall-back is said quietly.
clientkeeps the model a message asked for (MessagePosted.model), and for each run the one its latest start answers with (RunStarted.model, none after a fall-back) and the one the message that made that start asked for. Where those differ, the run fell back, and a quiet line under the strip says "Deep wasn't used: answered by …", with the model the provider named (usage.model, which the strip's token chips already show), or "the default model" until it has. The runner's notice in the thread says why. - A resumed run is judged by its reply. The runner takes a resumed turn's model from the reply that resumed it, else the run's; the store compares the model the run answers with against that reply's, never the run's first message's, so a reply that names another model isn't reported as a fall-back.
- Bytes. The add-on is its own chunk,
model-picker, 1,005 gzipped bytes as built, with a budget of its own of 1,100. The query and the fall-back check (client/src/models.ts) are in it, not in the queries every page holds, and name the tenant's header themselves; the page passes the kit'sSelectFieldto the add-on rather than the add-on importing it, as an import made the bundler split the select into a chunk every route names, 230 bytes of the initial. The thread's page grows by its lazy import and a focus listener, and the store by two fields: the app's initial is 203,380 of 203,500 bytes, after the polish pass.
Options considered¶
- A per-tenant list that widens the default. It would make
models:allowedthe one setting that a lower tier widens, against ADR-0030; the operator's ceiling and the tenants' narrowing cover the case. - Scoping
artifactr:use_modelby model in grantr. Grants name resources, and a model isn't one (artifactr ADR-0097); a setting narrows by name. - A tenant-level list. grantr reads a setting in a workspace; the picker always lives in one, and reading it there is exactly what the runner's check reads.
- A native
select. It cost the fewest bytes, and the kit's lint refuses it (ADR-0056).
Consequences¶
- Easier: an operator offers a model by listing it and widening
LITELLM_MODELS_ALLOWED; an admin narrows it per tenant or workspace in Settings; the picker and the runner can't disagree. - Harder: the picker shows what the workspace allows, not what a thread's restrictions allow: a person who may post in a thread but not use a model in its workspace is refused by the list, and gets no choice. The fall-back line is shown to the person whose page has loaded the add-on; others read the runner's notice.
- To revisit: the model's cache hints beside the picker (the streaming design's phase E); a choice that also sets the thread's default, if the owner wants one.