LAR-1 confidence routing
LAR-1 is a routing strategy for agents that describe their own state of knowledge. The agent sends a small metadata block with each request saying how confident it is, what kind of evidence it holds and whether the answer concerns the present moment or memory, and the router maps that to a deployment type. Unverified claims and low confidence go to the strongest cloud model, medium confidence to a fast cloud model, high confidence to a local model, and very high confidence to a deep model. It runs only in async mode, which is how the gateway always calls the router, and is part of the free gateway.
A real-world scenario
An operations agent answers questions about last night's deploy. When it has just retrieved the deploy log and is 62 percent confident, the question goes to a small local model that costs nothing. Above 70 percent it goes to the deep model, which is worth its price when the agent is about to act on a firm answer. When it is working from an unverified chat message, the router sends the question to claude-sonnet-5-5 regardless of confidence, because unverified evidence is exactly where a strong model earns its price. The agent never picks a model itself, it only reports what it knows.
Step by step
In the Admin UI
- Open
/ui/models-and-endpointsas a proxy admin and add four deployments with the same model name,assistant. On each one open the detail view and settypeunder Model Info tocloud-smart,cloud-fast,localordeep. - Open
/ui/router-settings, pick the Loadbalancing tab and set Routing Strategy tolar1, then click Save Changes. The thresholds below are set inrouter_settings.routing_strategy_argsinconfig.yaml, because the tab only exposes arguments for latency based routing. - Open
/ui/logsafter sending traffic. Each row shows the deployment that answered, so you can confirm that low confidence requests landed on thecloud-smartdeployment.
With curl
model_list:
- model_name: assistant
spanway_params:
model: anthropic/claude-sonnet-5-5
model_info:
type: cloud-smart
- model_name: assistant
spanway_params:
model: anthropic/claude-haiku-5-5
model_info:
type: cloud-fast
- model_name: assistant
spanway_params:
model: ollama/llama4
model_info:
type: local
- model_name: assistant
spanway_params:
model: openai/gpt-6.1-sol
model_info:
type: deep
router_settings:
routing_strategy: lar1
routing_strategy_args:
confidence_threshold_low: 0.3
confidence_threshold_medium: 0.5
confidence_threshold_high: 0.7
The three thresholds must satisfy 0 < low < medium < high < 1.
curl -i -X POST http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "assistant",
"messages": [{"role": "user", "content": "What changed in the deploy last night?"}],
"metadata": {"lar1": {"confidence": 0.82, "evidence": ["RETRIEVED"], "time": "NOW"}}
}'
Expected result
The request above goes to the deep deployment, because the confidence is above the high threshold and the evidence is retrieved. The x-spanway-model-id response header names that deployment and the spend log row records it. The same request with "evidence": ["UNVERIFIED"] goes to the cloud-smart deployment, with "time": "MEM" to cloud-fast, and with "confidence": 0.2 to cloud-smart.
Request metadata
| Field | Values | Default |
|---|---|---|
confidence | 0 to 1 | 0.5 |
evidence | List of SYNTH, RETRIEVED, UNVERIFIED, CONFIRMED | [] |
time | NOW, MEM, CTX, PRE | NOW |
act, mind | Further LAR-1 dimensions, accepted and recorded but not used for routing | INF, REF |
The target type is decided in order: UNVERIFIED evidence always routes to cloud-smart, a MEM time dimension routes to cloud-fast, then confidence below low goes to cloud-smart, below medium to cloud-fast, below high to local, and otherwise to deep. Missing metadata quietly uses the defaults. Invalid metadata also falls back to the defaults and logs a warning. When no healthy deployment of the target type exists, the first healthy deployment of the group is used and a warning names the type that was substituted.
Errors
| What you see | Why | Fix |
|---|---|---|
The gateway fails at start up naming confidence_threshold | The thresholds are not strictly increasing between 0 and 1. | Order them low < medium < high. |
| A log warning saying the LAR-1 metadata was invalid and defaults were used | confidence is outside 0 to 1, or evidence or time holds an unknown value. | Fix the agent's metadata. The request still ran with the defaults. |
| A log warning saying a deployment type was substituted | No healthy deployment carries the target type. | Add a deployment with that model_info.type, or check why it is in cooldown on Models + Endpoints, Health Status. |
| Every request lands on the same deployment | The agent sends no metadata.lar1, so every request uses the default confidence of 0.5. | Send the metadata block from the agent. |
| Requests are not routed by confidence at all | routing_strategy is not lar1, or the Admin UI save was refused because config.yaml owns the setting. | Set the strategy in the config file and restart. |
Related
- Routing lists the other routing strategies.
- Routing decision headers explains how to see which deployment answered.
- Router Settings page documents the Routing Strategy control.
- Logs page shows the deployment behind each request.