Skip to main content

Layer 2 · intelligence

model

blocks/2-intelligence/model.yaml

layer 2intelligence
5entities
9commands
9events
4views
17refusals
5KPIs

What a model is and how it is reached. A provider offers models; a model has capabilities, a context window and a price per token class; an endpoint is where one model is served; a route is a name that resolves to one endpoint and model, and says how it authenticates and how it is billed. An inference is one request on a route with its usage, latency and outcome. A retired route accepts no new inference.

Depends on​

  • shared · layer 0 · 18 references

Used by​

  • gateway · layer 2 · 14 references
  • agent · layer 4 · 5 references
  • harness · layer 4 · 22 references
  • process · layer 5 · 5 references
  • work · layer 5 · 5 references
  • runtime · layer 8 · 5 references

Entities​

Endpoint​

Where one model is served, an address and the protocol it speaks.

Identified by endpoint_id (EndpointId).

fieldtypemeaning
model_idModelId
addressstring
wireWire
hostingHosting
start_wait_secondsoptional integerHow long a Managed or Local server takes from a start until it answers; absent for one that is always up.

Relations:

  • model references Model (one, by model_id)

Lifecycle of Endpoint

ClosedOpencloseClosedOpenclose
Ends in Closed.

Inference​

One request on one route. Started when the request is accepted, Finished when it ended, with the usage, the latency and how it ended. Content is never held: the request is a digest and a length.

Identified by inference_id (InferenceId).

fieldtype
route_idRouteId
requestContent
usageoptional Usage
latencyoptional Latency
outcomeoptional InferenceOutcome

Relations:

  • route references Route (one, by route_id)

Lifecycle of Inference

FinishedStartedfinishFinishedStartedfinish
Ends in Finished.

Model​

One model of one provider, with what it can do, how much it reads and what a token costs.

Identified by model_id (ModelId).

fieldtypemeaning
provider_idProviderId
nameName
capabilitieslist of Capability
context_windowintegerTokens the model reads at once, input and output together.
priceTokenPrice

Always holds: context_window > 0.

Lifecycle of Model

CurrentRetiredretireCurrentRetiredretire
Ends in Retired.

Provider​

Who offers models, a vendor API, a cloud platform, or a model host the owner runs.

Identified by provider_id (ProviderId).

fieldtype
nameName

Relations:

  • models owns Model (many, by provider_id)

Lifecycle: one state, Registered; a recorded Provider does not change.

Route​

A name that resolves to one endpoint and the model it serves. Callers name routes, never endpoints.

Identified by route_id (RouteId).

fieldtypemeaning
nameName
endpoint_idEndpointId
model_idModelId
authRouteAuthHow the route authenticates to its endpoint.
billingRouteBillingHow a call on the route is paid for.

Relations:

  • endpoint references Endpoint (one, by endpoint_id)
  • model references Model (one, by model_id)

Lifecycle of Route

ActiveRetiredretireActiveRetiredretire
Ends in Retired.

Commands​

CloseEndpoint​

Close an endpoint.

Called by: Model operator.

fieldtype
endpoint_idEndpointId
outcomewhenresult
closedotherwisemoves the Endpoint Open → Closed; emits EndpointClosed
wrong-state refusedthe Endpoint is in a state that does not allow itEndpointStateConflict: The endpoint is not in a state this command acts from.

DeclareModel​

Declare a model.

Called by: Model operator.

fieldtype
model_idModelId
provider_idProviderId
nameName
capabilitieslist of Capability
context_windowinteger
priceTokenPrice
outcomewhenresult
unknown-provider refusedno Provider for provider_idUnknownProvider: No provider of this identity is registered.
declaredcontext_window > 0creates a Model in Current; emits ModelDeclared
invalid-window refusedotherwiseInvalidContextWindow: The context window is not a positive number of tokens.

DefineRoute​

Define a route.

Called by: Model operator.

fieldtype
route_idRouteId
nameName
endpoint_idEndpointId
model_idModelId
authoptional RouteAuth
billingoptional RouteBilling
outcomewhenresult
auth-missing refusednot (defined(auth))RouteAuthMissing: A route names how it authenticates; a route without it is not defined.
billing-missing refusednot (defined(billing))RouteBillingMissing: A route names how it is billed; a route without it is not defined.
unknown-endpoint refusedno Endpoint for endpoint_idUnknownEndpoint: No endpoint of this identity is open or closed; none was ever opened.
unknown-model refusedno Model for model_idUnknownModel: No model of this identity is declared.
endpoint-closed refusedthe Endpoint of endpoint_id has state == ClosedEndpointIsClosed: The endpoint is closed; no route may point at it.
model-retired refusedthe Model of model_id has state == RetiredModelIsRetired: The model is retired; nothing new is served from it.
model-not-served refusedthe Endpoint of endpoint_id has model_id != input.model_idModelNotServed: The endpoint serves another model than the one named.
definedotherwisecreates a Route in Active; emits RouteDefined

FinishInference​

Finish an inference.

Called by: Caller.

fieldtype
inference_idInferenceId
outcomeInferenceOutcome
usageUsage
latencyLatency
outcomewhenresult
finishedotherwisemoves the Inference Started → Finished; emits InferenceFinished
wrong-state refusedthe Inference is in a state that does not allow itInferenceStateConflict: The inference is not in a state this command acts from.

OpenEndpoint​

Open an endpoint.

Called by: Model operator.

fieldtype
endpoint_idEndpointId
model_idModelId
addressstring
wireWire
hostingHosting
start_wait_secondsoptional integer
outcomewhenresult
unknown-model refusedno Model for model_idUnknownModel: No model of this identity is declared.
model-retired refusedthe Model of model_id has state == RetiredModelIsRetired: The model is retired; nothing new is served from it.
openedotherwisecreates a Endpoint in Open; emits EndpointOpened

RegisterProvider​

Register a provider.

Called by: Model operator.

fieldtype
provider_idProviderId
nameName
outcomewhenresult
registeredotherwisecreates a Provider in Registered; emits ProviderRegistered

RetireModel​

Retire a model.

Called by: Model operator.

fieldtype
model_idModelId
outcomewhenresult
retiredotherwisemoves the Model Current → Retired; emits ModelRetired
wrong-state refusedthe Model is in a state that does not allow itModelStateConflict: The model is not in a state this command acts from.

RetireRoute​

Retire a route.

Called by: Model operator.

fieldtype
route_idRouteId
outcomewhenresult
retiredotherwisemoves the Route Active → Retired; emits RouteRetired
wrong-state refusedthe Route is in a state that does not allow itRouteStateConflict: The route is not in a state this command acts from.

StartInference​

Start an inference.

Called by: Caller.

fieldtype
inference_idInferenceId
route_idRouteId
requestContent
outcomewhenresult
unknown-route refusedno Route for route_idUnknownRoute: No route of this identity is defined.
route-retired refusedthe Route of route_id has state == RetiredRouteIsRetired: The route is retired; an inference on it is refused.
startedotherwisecreates a Inference in Started; emits InferenceStarted

Events​

eventfieldsemitted by
EndpointClosedendpoint_id EndpointIdCloseEndpoint
EndpointOpenedendpoint_id EndpointId, model_id ModelId, address string, wire Wire, hosting HostingOpenEndpoint
InferenceFinishedinference_id InferenceId, outcome InferenceOutcome, usage Usage, latency LatencyFinishInference
InferenceStartedinference_id InferenceId, route_id RouteId, request ContentStartInference
ModelDeclaredmodel_id ModelId, provider_id ProviderId, name Name, context_window integerDeclareModel
ModelRetiredmodel_id ModelIdRetireModel
ProviderRegisteredprovider_id ProviderId, name NameRegisterProvider
RouteDefinedroute_id RouteId, name Name, endpoint_id EndpointId, model_id ModelId, auth RouteAuth, billing RouteBillingDefineRoute
RouteRetiredroute_id RouteIdRetireRoute

Views​

viewrowsfields
Endpoints
Endpoints
each Endpointendpoint_id EndpointId, model_id ModelId, address string, wire Wire, hosting Hosting, start_wait_seconds optional integer, state State
Inferences
Inferences
each Inferenceinference_id InferenceId, route_id RouteId, request Content, usage optional Usage, latency optional Latency, outcome optional InferenceOutcome, state State
Models
Models
each Modelmodel_id ModelId, provider_id ProviderId, name Name, context_window integer, capabilities list of Capability, price TokenPrice, state State
Routes
Routes
each Routeroute_id RouteId, name Name, endpoint_id EndpointId, model_id ModelId, auth RouteAuth, billing RouteBilling, state State

Types​

typeisvalues or fields
Capability
What a model can do beyond reading and writing text.
one ofText, Vision, Audio, ToolUse, Reasoning, StructuredOutput, Embedding
Hosting
Who runs what serves an endpoint. Vendor is a provider's API, always up. Managed is a server the owner starts and stops on rented compute, so a call may wait for it to start and its start costs money before any token (agentic.runtime holds its instances and their phase). Local is a server on the owner's own machine.
one ofVendor, Managed, Local
InferenceOutcome
How one inference ended. Refused is the model or its provider declining the request; it is not the gateway's admission, which is agentic.gateway.
one ofOk, Refused, RateLimited, Error
Latencya recordtotal_ms integer, first_token_ms optional integer
RouteAuth
How a route authenticates to its endpoint: not at all (a local server), with a provider's API key, with an OAuth token of a person's subscription login, or with the identity of a cloud workload (a role or service account, no stored secret). The secret itself is the sandbox's or the gateway's, never the route's.
one ofNone, ApiKey, OAuthToken, CloudIdentity
RouteBilling
How a call on a route is paid for: per token at the model's price, under a flat subscription with limits of its own, by the time of a rented server (Managed hosting, agentic.runtime), or not at all (a server on the owner's own machine).
one ofPerToken, Subscription, ComputeTime, Free
TokenPrice
Price of one million tokens of each class, as Money in micro-USD. The classes are those of agentic.shared.Usage.
a recordinput Money, cache_read Money, cache_write Money, output Money
Wire
The request protocol an endpoint speaks.
one ofMessages, Chat, Responses, Native

KPIs​

5 KPIs from the KPI catalogue. A gate must be zero for a variant of an architecture to count.

Completeness​

KPIunitbettergatestatus
priced_message_share
Share of model messages whose model has a known price.
How: ModelTurnRecorded events with a priced model divided by all of them. The rest are the unpriced messages left out of the cost, so a cost figure over a low share is incomplete.
sharehigher–computed today
source: docs/kpis.md

Quality​

KPIunitbettergatestatus
cost_usd
Cost of the model messages at the list price of their model.
How: Per message, tokens by class (input, cache read, cache write, output) times the model's price, summed over ModelTurnRecorded events. The simulator sums priced tokens per inference.
usdlower–computed and simulated
source: docs/kpis.md
cost_per_task_usd
Cost of the model messages divided by tasks done.
How: cost_usd of a window divided by TaskCompleted events of the same window. Tasks not done still cost, so a failing system shows a higher value.
usdlower–simulated
source: design
cache_hit_share
Share of input tokens served from the prompt cache.
How: Cache read tokens divided by cache read plus cache write plus uncached input tokens, summed over ModelTurnRecorded events (reported as hit_permille).
sharehigher–computed today
source: docs/kpis.md
cache_bust_count
Model turns that wrote most of the context to the cache again.
How: Turns that read under half of the previous turn's context from the cache and wrote over half again, contexts over 20,000 tokens only, by cause (compacted, model_changed, ttl_expired, unexplained).
countlower–computed today
source: docs/kpis.md

Settings​

The settings a part of this block carries in an architecture document. agenticspec sim check refuses any other setting (setting_unknown) and a value outside its type (setting_invalid), and a part that lacks a setting marked required in the default column; the contract copies a setting into the ports it narrows. The last rows of each table are the settings every part takes. What no setting here types (a file, a path, an audience, the use of a model) goes into the part's notes, a map with free keys and values that the check takes as written and nothing reads.

A part model:

settingtypeunitdefaultcontractwhat
routestringmodel.inferenceThe route of the model, priced by the behaviour profile; a part that sets price is priced by it instead.
viastringThe endpoint of the architecture (endpoints:) the model is reached through, a gateway the binding addresses: a deployment asks egress to the endpoint, not to the model.
hostingenum Hosting: vendor, managed, localvendorWho runs what serves the model: a provider's API (vendor), a server the owner runs on rented compute (managed) or on its own machine (local). With billing, where the model's price comes from.
billingenum: subscription, metered, nonemeteredHow the model is paid for: a fixed subscription, metered per token at the part's price or else the route's, or none (nothing per call, as a local model).
pricepriceThe price of the model's tokens, USD per million tokens of each class (input, cache_read, cache_write, output), the classes of agentic.model.TokenPrice: a metered call to the part is priced by it, not by its route's price in the profile. The search keeps it fixed under optimize: all.
countinteger of at least 11How many copies of the part run.
perpartOne copy of the part for each copy of the named part.
notesnotesFree notes on the part, a map with keys and values of any kind: what no setting of its block types. The check takes any map; the simulator, the search and the contract never read it.