ADR-166 — Model capabilities ride the price feed: a declared source, a platform scope, accepted efforts folded per field; the runner's env tables are fallbacks
- Status: Accepted — the operator decided it on 2026-11-12 (the extended price feed, over a
catalog:block in the routing policy and over a narrower variant with no platform scope; no per-integration capability seat; a platformscalewaypreset feed in place ofOPENAI_COMPATIBLE_CATALOG_PROVIDER; a record of its own, ADR-163 keeping a pointer) - Date: 2026-11-12
- Deciders: jo (architecture, the four arbitrations), Claude (three designs, two judges, the implementation)
- Extends: ADR-163 — the feed, its fold and its channel are the seat this record reuses; nothing of ADR-163 is reversed.
- Relates to: ADR-122 (the gateway catalog, whole-entry precedence, exact ids) · ADR-121 (the routing cells, where the requested effort lives) · ADR-131 (the team's gateway key, which seals the bundle the feed rides) · ADR-164 (a
platformdocument beside the tenants' in one collection) - Serves: #2906 (provider/model configuration lives in the database); the retirement of the dedicated runner pools (honorabilite, egapro, vao)
Context
A gateway route sends the node's reasoning_effort on the wire, and a gateway model accepts only some values: scaleway/deepseek-v4.1-flash takes low, high, xhigh and max, and answers medium with HTTP 400. Which values a model accepts was readable from one place only: OPENAI_COMPATIBLE_REASONING_EFFORTS, an env table of the runner process. The dedicated runner pools carried it in their deployment values; the default runner did not. A Revi review of DomiFa, run on the default runner, sent medium to deepseek-v4.1-flash and failed on that 400.
The pools exist mostly to carry three env tables — OPENAI_COMPATIBLE_MODELS (prices, windows, output caps, flags), OPENAI_COMPATIBLE_REASONING_EFFORTS and OPENAI_COMPATIBLE_CATALOG_PROVIDER. Retiring them means each name gets a seat in the database, which is also the doctrine of #2906: the database is the seat of provider/model configuration, and the env tables are runner-side fallbacks.
ADR-163 already built most of that seat. Its price feed stores org and team feed lists in the database, folds the effective table at every launch and resume, seals it in the run bundle, and the runner plants it where the gateway catalog reads it. Three things were missing:
- a field for the accepted efforts;
- a way to state what no tariff source publishes — an effort list, a window or a price written by hand, without a fetch, a script or a server-side exec;
- a level above the org: the products that would share one gateway table sit in several orgs, and a per-org copy drifts.
Decision
One spec, one vocabulary.
modelspecs.SpecgainsReasoningEfforts— server-side feed state, never filled by the models.dev parse.modelspecs.ParseEffortLevelsis the one effort vocabulary (none,minimal,low,medium,high,xhigh,max, integers 1–100; trimmed, lower-cased), read by the runner's tolerant env reader and by the feed's strict parser. The operator-table decoderpricefeed.ParseEntries(OPENAI_COMPATIBLE_MODELS) keeps refusingreasoning_efforts.pricefeed.ParseFeedEntriesshares its body and accepts the field strictly: an empty list, a repeated level or a level outside the vocabulary is refused, naming the id; so is an id that normalizes to nothing, which the fold would drop unsaid (ParseEntrieskeeps accepting one, as the runner always has). Anexecfeed's stdout parsed withParseEntriesbefore this release, which left an entry under such an id out unsaid; that feed now fails its refresh whole, naming the cause, and ages as any failing feed (TestParseFeedEntriesRefusesABlankID). Both theexecsource and thedeclaredsource below parse with it.A
declaredsource: the answer is its params. A feed of typedeclaredstores its table inparams.entries: the operator-table JSON per gateway id, plusreasoning_efforts. It is a static source (pricefeed.StaticSource):- the fold reads it from its config at every fold;
- the reconciler never fetches it (
Dueis false), and a manual sync judges it and writes no state document, so nothing under its name outlives it for a fetched feed that later takes the name; - it never goes stale, and its entries carry the config's
updated_at; - the view reports it
declared, with its entry count anddeclared_at.
A declared entry answers whole, as the operator-table row it copies did: priced, or stating a window, an output cap, a cache price or a flag without the price pair — which it answers unpriced, the answer a pool's
OPENAI_COMPATIBLE_MODELSrow gave, so a pool's table declares as written (TestFoldADeclaredUnpricedRowAnswersWhole,TestResolveCatalog_ADeclaredUnpricedRowAnswersAsThePoolsRowDid). A declared row without the price pair never hides a price: where a priced entry answers the same id beside it (a later feed of its level) or below it (a less specific level) — and, on the runner, where the operator table or the catalog provider prices it — the priced answer answers whole, the row's window, output cap, cache price and flags step aside with a warning naming both feeds, the ids and the fields, and its accepted efforts still answer (TestFoldADeclaredUnpricedRowNeverHidesAPriceBelowIt,TestResolveCatalog_ADeclaredUnpricedRowNeverHidesAPriceBelowIt). Answering whole over a price, the row zeroed the cost of every run of the id, andcost_gtand the cost caps with it: a team'sreasoning: truebeside its efforts, a team's window alone, a platform row carried from one pool's table over an id another pool's env table priced. A row that must answer its window over a price states the price pair. ADR-163's rule — an unpriced entry never answers — stays the rule for fetched feeds: a source that lists an id without pricing it says nothing about it, while an operator's declared row says what it says. An entry stating onlyreasoning_effortsanswers its efforts alone. An empty document and an entry that states nothing are refused. A stored declaration that breaks these rules steps down in the fold with a warning that names the feed, and the view reads it asfailing. Declaring is not an exec capability: a tenant admin declares at their own scope, just as they can already point alitellmormodelsdevfeed at any URL.A platform scope. The
price_feedscollection gains a documentplatform— the deployment's own feed list, behind the super-admin routesGET/PUT /api/admin/price-feedsandPOST /api/admin/price-feeds/sync. Writes use the same CAS as the org and team lists and are auditedplatform.price_feeds.updated. The fold reads platform, then org, then team. An org purge removes only the org's and its teams' documents (org:/team:ids and prefixes), so the platform document and its states (platform/<feed>) survive it.Two maps on the run table, folded per field. The table the bundle carries has two maps:
Entriesholds the price entries (prices, window, output cap, cache price, flags) — every priced entry, and every declared entry stating those fields without the price pair where no priced entry answers its id (§2) — with any effort list stripped;Effortsmaps an id to{feed, values}.
Each map folds by ADR-163's precedence, per id: within a scope, the first answering feed whose entry belongs in the map wins the id — a fetched feed while fresh, a declaration always; across scopes, the more specific scope replaces that id (team over org over platform). An id can come from one feed in one map and another feed in the other. So a fetched feed that prices an id never erases a declared effort list, and an efforts-only declaration never hides a price.
A price entry answers whole from one feed: its prices, window, output cap, cache price and flags are never merged across feeds or scopes (ADR-122's whole-entry precedence, which the catalog ladder already holds over the env table). A feed that prices a declared id must restate the declaration's window, output cap and cache price, or the run loses them. The fold keeps the winner whole and warns, one line per (winner, shadowed) feed pair naming both feeds with their level, the ids and the fields left unstated; the line reaches the publisher's log and the effective view (
TestFoldWarnsWhenAWinningEntryLeavesShadowedFieldsUnstated). Filling a winner's unstated field from the entry it shadows was rejected: one entry would carry one feed's provenance over two feeds' numbers, a cache rate from one gateway beside the input rate of another.Entriesis always encoded ({}when empty), so an older runner, whose parser requires it, still plants an efforts-only table.A table over the channel's byte budget narrows its prices and keeps every id's efforts (
TestFoldOverBudgetKeepsDeclaredEfforts). A price the narrowing drops steps down to the operator floor; a dropped effort list would send a level the gateway refuses, and a run whose model is an env dial names no id at all. The prices it keeps are the run's named gateway ids', the ids' with accepted efforts and the declared ids', giving up the declared ids', then the efforts ids', as the budget needs: a run whose model is an env dial keeps a retired pool's declared rows while the budget holds them, as it read the pool's env table (TestFoldOverBudgetKeepsThePricesOfTheIDsWithEffortsAndTheDeclaredIDs,TestFoldOverBudgetGivesUpTheEffortsIDsPricesBeforeTheNamedOnes,TestPriceFeedOverBudgetDialRunSealsTheDeclaredRows). Only when the efforts alone exceed the budget do both maps narrow to the named ids.A level the fold cannot read refuses the run. ADR-163's step-down is for an answer the server knows to be absent: a level with no document, a fetched feed that never refreshed, a stale or failing one. A level whose config document, or the state of one of its enabled fetched feeds, does not answer — a database error, or the level's own read deadline (2 s, each level its own) — is an answer the server does not know, and a table sealed without it would carry none of that level's accepted efforts. The launch or the resume folding it is refused, retryably:
PriceFeedUnreadError, answered503witherror_code: PRICE_FEED_UNREADandretryable: true; its message names the levels, and the server log carries the read errors (TestPriceFeedFoldRefusesALaunchOverAnUnreadLevel,TestAnUnreadPriceFeedFoldRefusesTheLaunchAndTheResume,TestPriceFeedUnreadLaunchAndResumeAnswerARetryableOutage,TestPriceFeedFoldGivesEachLevelItsOwnReadDeadline,TestPriceFeedFoldStepsDownWhatItKnows). A declaration reads no state document and a disabled feed none, so neither can leave its level unread (TestPriceFeedFoldReadsNoStateForADeclarationOrADisabledFeed).The runner reads the run table first, the env table only as a fallback.
compatgw.AcceptedEffortsanswers a gateway id's accepted values and their source, in this order:- the run table's
Efforts, under the normalized id →feed:<name>; - otherwise
OPENAI_COMPATIBLE_REASONING_EFFORTS, by exact id →env:OPENAI_COMPATIBLE_REASONING_EFFORTS; - otherwise nothing, and the requested effort passes through as before.
A run-table entry the vocabulary refuses warns
REASONING_EFFORTS_INVALIDand steps down to the env table. Every writer of an effort reads through the one mapping (gatewayReasoningEffort): delegation, the human/interaction stand-in and the turn after a cut atmax_tokens.TestEveryReasoningEffortWriterIsInventoried(pkg/backend/model) keeps the list of those writers in a test. Thereasoning_effort_adjustedevent and its warning name the source.- the run table's
The sandbox crossing carries the host's answer. The crossing writes the host's merged table under
OPENAI_COMPATIBLE_REASONING_EFFORTS, the name an older sandbox image reads: the env table's valid entries, with the run table's efforts laid over them under the normalized id, under every env spelling of that id, and under the node's exact wire spelling. When neither table states anything, the crossing writes the explicit empty. A sandbox image of this release reads the run table first, as the host does; an older image reads the crossed name by exact wire id. Either way it maps the effort with the list the host used.Accepted efforts versus requested effort. The accepted efforts are a fact about the gateway that serves an id. Their seats stop at the feed's scopes — platform, org, team — and there is no capability seat on a bot, a binding, a credential or an integration. The requested effort is the intent of the workflow or of the operator. It stays where it lives today: the node's
reasoning_effort:, the launch override, an edge mapping, and the routing cells'effortacross the six levels of ADR-121. Dispatch maps the request onto the accepted list: the nearest named level, ties going to more effort (medium→highwhen onlylowandhighare on the list); integers compare only with integers.The per-gateway path, kept open and not built. Capabilities are keyed by the gateway wire id, not by the pair (gateway host, id). A team whose key points at another gateway serving the same id has a way out today: it declares its own team-level feed, which replaces the platform's answer for that id: the price entry whole when it states the price pair (§2), the effort list on its own. If one scope ever needs two answers for one id, the extension stays inside this seat: a host qualifier in the same feed document and on the same run table, answering before the bare-id entry. That is an additive map an older runner ignores, the same shape
Effortstook here. It would not be a new collection or a per-integration seat.A
scalewaypreset feed replacesOPENAI_COMPATIBLE_CATALOG_PROVIDERas the seat. The database answer to "this gateway's ids live under models.dev'sscalewaykey" is a platform feed of typescaleway. It keys every entry both asscaleway/<id>and as<id>, the two spellingsCATALOG_PROVIDER=scalewaylooked up. Placed after the declaration, it answers the ids the declaration leaves open. No typedcatalog_providerfield exists on the table.The env tables are runner-side fallbacks, unchanged.
OPENAI_COMPATIBLE_MODELSanswers below the run table in the catalog ladder (ADR-163).OPENAI_COMPATIBLE_REASONING_EFFORTSanswers below the run table's efforts.OPENAI_COMPATIBLE_CATALOG_PROVIDERanswers below both. Their names, decoders and tolerances do not change, and no env name is added.A read model, and the operator's tools.
GET /api/teams/{id}/price-feeds/effectivelets any member of the team read the effective table. It answers the table a run launched now for the team would seal: the same fold the publisher runs, at one instant. For each id it gives the answering entry and efforts with their feed and level, the ones the fold took, so two feeds of one name at two levels are told apart (TestPriceFeedEffectiveViewNamesTheLevelThatAnswers), every feed that states the id, the fold's warnings, andrunner_env_fallback: "not visible from the server". A request naming ids answers the table a run naming them seals. A listing whose folded table exceeds the run channel's byte budget answersover_budgetand no table, each id as a run naming it reads it, because each run seals its own narrowing (TestPriceFeedEffectiveViewListsAnOverBudgetTableAsEachRunNarrowsIt);entry_named_onlyandefforts_named_onlymark an id's entry or efforts that a run naming no gateway id, its model an env dial, does not seal (TestPriceFeedEffectiveViewMarksWhatARunNamingNoIDLacks). A level the view cannot read says so, and that a run launched now is refused until it reads (§4), without the database's error, which stays in the server log (TestPriceFeedEffectiveViewKeepsAReadErrorInTheServerLog). A member reads what every run of the team already carries, the folded table that is sealed into the bundle and crosses into the sandbox, plus the shadowed feeds a team feed must restate (§4); no feed's params. The CLI covers the rest:iterion remote price-feeds effectivereads that view;declarewrites one declared feed after checking it with the server's parser and printing the per-id diff;--models-file/--efforts-filetake a pool's two env tables as written — each id answers the prices, window, output cap and efforts it answered on the pool (TestRemotePriceFeedsDeclareTakesAPoolsUnpricedRow) — and refuse by name what the feed's strict parser refuses: an entry stating nothing, an id empty once trimmed, an effort list that is empty, repeats a level or names one outside the vocabulary;--dry-runprints without writing;--platformaddresses the platform scope on every write.
Consequences
Nothing new to operate. There is no new collection, no new channel and no new env name. The cloud twin is ADR-163's: the
price_feedsandprice_feed_stateMongo stores and their memory twins. A declaration lives in its config's params. A fetched feed's state entries gainreasoningefforts, the driver's default key, which an older binary skips on decode — and writes back without them when its refresh of anexecfeed fails (mixed versions, below). A state gainstype, the source type it was written for: a feed retyped under its name reads its predecessor's state as no state, and a record with no stamp, written by an older binary, counts as the feed's own.Mixed versions during a rollout.
- An older server replica refuses a
declaredfeed on write and folds no platform document and no declaration. The operator writes nothing until every replica runs the release. - An older replica's view renders a redacted param without naming it, so a list it answers and
declarewrote back would store the marker over the credential.declarerefuses a read whose source vocabulary has nodeclaredtype and writes nothing (TestRemotePriceFeedsDeclareRefusesAReadFromAnOlderReplica), and every scope's write refuses a list holding the marker(redacted)as a param's value (TestPriceFeedWriteRefusesTheRedactionMarker). - An older runner decodes the new table. Its priced entries answer, because the runner never judges freshness and the presence of an entry is the verdict; its efforts map is ignored and the runner's env table answers (
TestOldRunnerReadsTheNewTable). - An older replica holding the reconciler's lease cannot parse an
execfeed that printsreasoning_efforts: its refresh fails and writes the entries back as it decoded them, the prices fresh and the efforts gone, so runs seal none of that feed's efforts until a replica of this release refreshes it (TestAnOlderReplicasFailingRefreshDropsAnExecFeedsEfforts). Anexecfeed prints efforts only once no older replica can hold the lease. - An older sandbox image applies the database's list through the crossed name (
TestCrossingReasoningEffortsServesAnOlderSandbox). - The
image_inputflag (#3707) followsreasoning_effortson the parsers only:OPENAI_COMPATIBLE_MODELSrefuses it (TestTheOperatorTableRefusesImageInput), and feed entries carry it, which a server older than it parses strictly. It does not fold like efforts: efforts fold per field, whileimage_inputis a field of the price entry and answers with it whole — an unpriced declaration stating it steps aside for a priced entry, and only the entry that answers the id carries its flag to the run (TestFoldImageInputAnswersFromTheAnsweringEntryOnly). It is written into a declared orexecfeed only once no older server replica can fold or refresh it (TestAnOlderServerRefusesFeedEntriesStatingImageInput,TestAnOlderReplicasFailingRefreshDropsAnExecFeedsImageInput; the limits are indocs/agents/backends/image-acceptance.md).
- An older server replica refuses a
A tenant feed sets what its own runs are metered at. A team or org admin's declared price is the price its runs are metered at, so a near-zero declared price under-meters them, as a tenant
litellmormodelsdevfeed pointed at a URL it serves could since ADR-163; accepted. A declared row without the price pair cannot unprice an id (§2).The usage-progress sample prices through the run's context, as the dispatch and the meter do. On a default runner with no env tables, a gateway node priced by the feed would otherwise sample at zero dollars, and a supervisor's
cost_gtmonitor would go blind once the pools retire.Keyed by wire id. A team that serves an id from a gateway other than the platform's inherits the platform's list for that id until it declares its own.
The preset feed is a fetched feed. While stale it steps down. For as long as that lasts, the qualified lookup in the embedded snapshot that
CATALOG_PROVIDERfell back on is gone, except on a runner that still sets the env name. Only priced entries answer, so an id that models.dev lists without prices must be declared.The views stay blind for now.
/api/effort-capabilitiesanswers nothing for a gateway id. The model-capabilities view, the studio's effort picker and the cost preview do not read the tenant feed. These are a follow-up.The seal hole stays open. A run that carries no credential and no generic secret, and is not held to its team's gateway, seals no bundle, so it carries no feed table. Its gateway routes are funded by the runner pod's environment and read only the runner's env tables. Closing this is a follow-up in two releases: the runner first, then the publisher.
Prerequisites before a pool retires. This is the operator's runbook, not code:
- this release runs on every server replica, on the default runners and on the sandbox images;
- a platform declaration covers every gateway id the products' routing cells name, with the values carried over from the pool's tables (
declare --platform --models-file … --efforts-file … --dry-run), plus thescalewaypreset where the pool setCATALOG_PROVIDER; effective --teamanswersfeed:<name>for every one of those ids, and the answering entry carries the window, output cap and cache price the pool's table stated: no org or team feed, and no platform feed listed before the declaration, prices a declared id without restating them — the contributors list names who shadows, and the warnings name what is dropped; none of them readsentry_named_onlyorefforts_named_only, which a product whose model is an env dial would run without;- every product run seals a bundle — a team gateway key (ADR-131) in place, given the seal hole above;
- the pool's dials are re-seated as routing cells;
- the pool's non-LLM environment (sandbox image, node selector, spread) has a seat, or equals the default runner's;
- the runs stamped on the pool are drained before the team is unmapped, because
ErrPoolRemappedis permanent; - pools retire one at a time, each scaled to zero for one release cycle before its entry is removed.
The proof is
TestPriceFeedEndToEndRetiresThePool(pkg/server), deterministic and with no model spend. A super-admin's platform declaration goes through the real route. The real publisher launches on the default runner for a team that holds its gateway key, with the fold the server binary wires (server.PublisherPriceFeedEffective). The test opens the sealed record the published message names, under the message's per-run key, team, pool and run id, plants the table through the runner's adapter, and runs the executor against a stub gateway that records what it receives. The default runner, with noOPENAI_COMPATIBLE_*table, sendsreasoning_effort: highfor amediumnode andmax_tokensfrom the declared output cap. It records_gateway_spec.source = feed:pliage, a priced cost and a priced usage sample. A twin run on a pool runner whose env tables state the same values sends the same model,reasoning_effortandmax_tokensat the same cost; only the provenance differs. Two legs are not driven there:- the runner's own open:
injectCredentialsis unexported inpkg/runner.TestInjectCredentials_OpensThePublishersTeamGatewayLaunchhands it the real publisher's message; the run's context carries the team's sealed key and base URL, the ambient refusal of the pod's environment, and the table, which answers the declaration's efforts, window, output cap and prices there; - the call funded by the sealed key: a sealed gateway key's base URL is https on a public host (
secrets.ValidateGatewayBaseURL, which the E2E asserts refuses the stub's URLs), so the E2E funds the call with the runner's env pair (OPENAI_COMPATIBLE_BASE_URL/_API_KEY), which are no table.
The publisher's call to the fold (its presence, its org, team and named ids) is pinned by
TestPriceFeedFoldReadsTheOrgTheFreshTeamReadNames(pkg/server/cloudpublisher); the fold's own org and team order, named ids and warnings byTestPublisherPriceFeedEffectiveFoldsTheOrgAndTheTeamItIsGiven.- the runner's own open:
Alternatives rejected
- A
catalog:block in the routing policy, six levels with locks. It would be a second database seat for facts ADR-163 already holds. A whole-document PUT from an older replica erases it permanently. It extends pricing authority to manifests and bindings, and its size is XL. It wins only if a bot or a binding must declare its own capabilities. - Efforts inside
Entry.Spec, under whole-entry precedence. A feed that prices an id would erase the declared effort list. - Efforts on the credential, or any per-integration seat: refused by the operator. A capability is a fact of the gateway, and the escape hatch is a team-level declaration.
- A new
model_capabilitiescollection. It would need a second reconciler, CAS and set of routes for the same three scopes. reasoning_effortsinsideOPENAI_COMPATIBLE_MODELS. An older runner's strict decoder refuses the whole table, which would force a deployment order and lose every price on the way.- A typed
catalog_providerfield on the table. The preset feed is configuration of an adapter that already exists. - No platform scope (org and team only). The products span several orgs, so the table would become a copy per org, and the copies drift.
Not decided here
- Locks on a platform declaration against team overrides — a later ADR, with llmroute's locks as the precedent.
- Who owns the exchange rate behind a price. Prices are in USD per Mtok, and a tariff billed in another currency needs a rate that someone keeps current.
- Keying by gateway host — only the path in Decision 8.
- The retirement of each pool — the operator's runbook, under the prerequisites above.
