Skip to main content

Gateway Task Routing

Blueprint · ← Capability matrix · Gateway task routing · Canary promotion →

Every inference request from Plane ② hits the gateway with model_profile + task type. The gateway filters the capability matrix, applies constraints, and returns a completion (or abstains).

THE CLAIM

Abstention is a first-class outcome. No approved fit means no call, not "use whatever is cheapest."

Per-call path

  1. Receive inference request: messages, model_profile, task_type, data class, region, tenant budget remaining
  2. Load pinned matrix_version (request or session pin)
  3. Filter endpoints: profile ∩ task ∩ data class ∩ region ∩ entitlements
  4. Score remaining: cost cap, latency SLO, budget remaining
  5. Pick stable or canary per promotion policy
  6. Run inference; apply output filter
  7. Return completion + model_route_id to Plane ②
  8. Abstain if the filtered set is empty or every candidate exceeds caps

Caller contract: Inference handoff. Platform stack: G.A.I.N LLM.

Filter then score

StageInputsDrop if
Profilemodel_profileUnknown profile id
Taskplan / synthesize / classifyTask not listed on the profile
Data classRequest classificationEndpoint not approved for that class
RegionResidency claimEndpoint region mismatch
Costmax_cost_usd_per_1k_tokensCandidate over cap
Latencymax_latency_ms vs recent SLOCandidate over SLO (unless only fit)
BudgetTenant remainingWould exceed remaining budget

Do not skip data class or region to save cost. Those are hard filters. Cost and latency are scored among the remaining set.

Failover

Failover stays inside the filtered set.

EventAction
Primary 5xx / timeoutNext scored endpoint in the same profile + task + region
Primary over SLOCanary or secondary if still in matrix
All endpoints failAbstain; Plane ② escalates (cached answer, human, or user-visible failure)
Provider outage in one regionDo not silently route to another region unless the matrix lists it for that data class

Log every failover hop: attempted_route_id, error_class, next_route_id.

Cost caps

CapEnforced at
Per-call token costGateway, before the request
Per-tenant budgetGateway, remaining budget on the request
Per-profile ceilingMatrix max_cost_usd_per_1k_tokens

Over cap → next cheaper fit in the filtered set, else abstain. Do not downgrade data-class or region to find a cheaper model.

Abstain

Return a structured abstain to Plane ②. Do not invent a completion.

ReasonPlane ② should
no_approved_endpointFail closed; do not call a vendor SDK as backup
budget_exhaustedUser-visible throttle or queue
residency_unsatisfiedEscalate; never cross region
task_not_on_profileFix the route row or matrix; do not guess a task

Failure classes

FailureSymptom
Model choice only in the system promptPlane ③ skipped
Failover to any healthy endpointResidency or data-class leak
Empty filter set still calls a default modelSilent policy bypass
No model_route_id in traceCannot attribute cost or incidents

Trace fields

matrix_version, model_profile, task_type, model_route_id, endpoint_id, canary (bool), failover_hops, cost_usd, abstain_reason

Canary promotion →