Agent Architecture & Optimisation
Decision Models: Decoupling Decision from Generation in AI Agent Fleets
Why using a 70B LLM to route tasks or pick tools destroys your latency and costs, and how to fix it with 2B decision models at sub-30ms and $0.04/M.
- Date
- Oct 9, 2026
- Reading time
- 8 min
- Result
- Sub-30ms Latency • 98% Token Savings • Zero Parsing Failures • $0 Local Cost
Translated from the Spanish original. The code, data and READMEs on GitHub are in Spanish.
In the 2026 automation and autonomous agent ecosystem, a common design pattern has quietly become engineering teams’ biggest black hole for budget and latency: using large generative language models (LLMs) as simple conditional routers.
When an agent receives a user request or an incoming webhook, the system needs to make discrete decisions:
- Does this query belong to technical support, billing or pre-sales?
- Should the MCP tool
query_database,fetch_apiorhuman_escalationbe run? - Does the agent’s output pass the safety guardrails before being sent to the customer?
In most implementations, the standard solution is to invoke a frontier reasoning model (Claude 3.5 Sonnet, GPT-4o or a 70B open-weights model) with an 800-token prompt that ends with an instruction like: “Choose between [A, B, C] and respond only in JSON format with the key ‘route’”.
This approach is a first-order architectural mistake. In this article from the trenches at YesWeLab (@Yeswelab_OU) we look at the emergence of Decision Models, how they radically transform our agents’ efficiency and how to apply the Dual Track strategy to operate at scale with minimal or zero cost.
1. Anatomy of the Failure: The Cost of Burning Generative Tokens
Treating a finite classification problem as a free-text generation task introduces four severe penalties into any production infrastructure:
[ TRADITIONAL FLOW WITH A GENERATIVE LLM ]
Input ──► Huge prompt (800 tok) ──► 70B LLM (autoregressive) ──► Generates JSON ──► JSON.parse()
• Latency: 1,200 - 2,500 ms
• Cost: $3.00 - $15.00 / 1M tokens
• Risk: truncated JSON, wrong keys, hallucination
- Unacceptable Latency (Autoregressive Overhead): A generative LLM produces text token by token through sequential probabilistic sampling. To return a simple
"route": "billing", the model has to process the context, activate massive attention layers and generate dozens of JSON wrapper tokens. That adds between 800 ms and 2,500 ms at every branch in the pipeline. - Economic Waste: Paying between $2.50 and $15.00 per million tokens on a frontier model to evaluate a decision that a classification tree or a linear classifier could solve is unsustainable when you’re processing hundreds of thousands of events a day.
- Parsing Fragility: Despite structured outputs, generative models can suffer parsing failures under load, output token saturation or unexpected inserted comments that break the workflow’s execution.
- No Mathematical Calibration: An LLM that answers
"billing"doesn’t natively tell you how sure it is. Temperature and top-p sampling mask the model’s real confidence, forcing extra calls to estimate uncertainty.
2. What Is a Decision Model and How Does It Work?
A Decision Model is an architecture optimised exclusively to project an input onto a probability distribution over a discrete, predefined set of classes or decisions.
[ FLOW WITH A DECISION MODEL (SUB-30MS) ]
Input ──► Embedding / Forward Pass ──► Classifier head / Softmax ──► Calibrated probabilities
• Latency: 15 - 30 ms
• Cost: $0.04 / 1M tokens (or $0 locally)
• Result: {"billing": 0.94, "tech": 0.04, "sales": 0.02}
Unlike chat models:
- It doesn’t generate text: There’s no token-by-token autoregressive decoding. The model performs a single forward pass through the weights.
- Calibrated Probability Output: Instead of returning text, it returns a vector of normalised confidence scores (softmax) for each of the available options.
- Confidence Evaluation: If the predicted class has 95% confidence, the system runs the branch immediately. If the maximum confidence doesn’t exceed a safety threshold (for example, 65%), the orchestrator can safely escalate the decision to a heavier frontier model or a human operator.
3. The October 2026 Avalanche: The Ecosystem Standardises
In recent days, the sector’s main players have consolidated this architecture through coordinated releases of open weights and dedicated APIs:
| Provider / Model | Architecture | Typical Latency | Cost per 1M Tokens | Licence / Deployment |
|---|---|---|---|---|
| AWS Strands Decider 2B | 2.1B specialised parameters | 18 – 28 ms (local GPU) | $0.00 (Homelab/vLLM) | Open Weights (Apache 2.0) |
| Cloudflare Clef / Clef-flash | Compact decision model | 25 – 45 ms (Edge) | Serverless Workers AI tier | Apache 2.0 / Hugging Face |
| Perplexity pplx-decider-v1-27b | Calibrated Qwen 27B fine-tune | 60 – 90 ms | $0.04 / 1M input tokens | Calibrated Commercial API |
| OpenAI Decisions API (Preview) | Discrete routing engine | 70 – 110 ms | Reduced pricing | Cloud Pro/Enterprise API |
The arrival of Strands Decider 2B from the AWS Strands Agents team and Clef from Cloudflare marks a milestone: there’s no longer any need to resort to prompting tricks or hand-made BERT micro-models. There are state-of-the-art weights ready to act as traffic controllers in any agent cluster.
4. The Dual Track Philosophy at YesWeLab
At YesWeLab we always apply our guiding principle, “Show, Don’t Sell”, through the Dual Track framework.
[ EVENT OR REQUEST ]
│
┌─────────────────────┴─────────────────────┐
▼ ▼
[ TRACK A: DIY / OPEN SOURCE ] [ TRACK B: FAST-TRACK SAAS ]
• Model: local Strands Decider 2B • Model: Cloudflare Clef (Workers AI)
• Engine: vLLM / llama.cpp in a homelab • Or Perplexity Decisions API ($0.04/M)
• Latency: ~22 ms • Latency: ~40 ms global edge
• Cost: $0 / month • Cost: cents for millions of hits
• Privacy: 100% on-premise • Zero infrastructure management
Track A (DIY / Open Source / $0 Cost)
For builders, sovereign environments and local homelabs:
- We download the Strands Decider 2B weights.
- We deploy the service on vLLM or llama.cpp, using less than 2.5 GB of VRAM (even on a modern CPU with FP8 or INT4 quantisation).
- We expose an ultra-light endpoint that n8n or our local Hermes agents call before every MCP tool call.
Track B (Fast-Track SaaS / Enterprise Scaling)
For companies that need high availability without managing servers:
- Deployment on Cloudflare Workers AI with Clef-flash, or integration with the Perplexity Decisions API.
- Classification at the network edge to filter spam, route webhooks to Kafka/SQS queues and protect the external API budget.
5. Practical Implementation: A Deterministic Router with a Safe Fallback
Below is a real example of a tool router for agents in Python, combining a local decision model with a confidence threshold (confidence gate):
import httpx
from typing import Dict, List, Tuple
DECIDER_ENDPOINT = "http://localhost:8000/v1/decide"
CONFIDENCE_THRESHOLD = 0.70
AVAILABLE_ROUTES = [
"route_sql_query", # Analytical database queries
"route_knowledge_mcp", # RAG documentation search
"route_code_sandbox", # Running scripts in a container
"route_escalate_human" # Ambiguous or high-risk cases
]
def route_agent_task(prompt: str) -> Tuple[str, float]:
"""
Evaluates intent with a discrete Decision Model.
Returns the selected route and its calibrated confidence score.
"""
payload = {
"input": prompt,
"options": AVAILABLE_ROUTES
}
# 1. Ultra-fast call to the decision model (typical latency: ~22ms)
response = httpx.post(DECIDER_ENDPOINT, json=payload, timeout=2.0)
data = response.json()
# data["probabilities"] contains { "route_sql_query": 0.92, ... }
probabilities: Dict[str, float] = data["probabilities"]
best_route = max(probabilities, key=probabilities.get)
confidence = probabilities[best_route]
# 2. Calibration-based safety gate
if confidence < CONFIDENCE_THRESHOLD:
print(f"⚠️ Low confidence ({confidence:.2f}). Escalating to a frontier model...")
return "route_escalate_human", confidence
return best_route, confidence
# Example from the trenches:
if __name__ == "__main__":
task = "How many new users signed up yesterday in the billing table?"
selected_route, score = route_agent_task(task)
print(f"✓ Route chosen: {selected_route} with {score*100:.1f}% confidence")
# Output: ✓ Route chosen: route_sql_query with 94.6% confidence (Time: 24ms)
6. Rules from the Trenches for Automation Architects
If you’re designing fleets of autonomous agents, n8n pipelines or MCP servers, apply these three rules from day one:
- Never use a generative model for a closed-answer question: If the output options fit in an enumerated list (
Enum), a Decision Model is always the right choice, technically and economically. - Make use of the Confidence Gate: Use the returned probability to build a pyramid architecture. Let the 2B model resolve the 90% of high-certainty decisions at zero cost, and reserve frontier model tokens exclusively for the 10% of ambiguous cases.
- Measure accumulated latency (Time to Action): In multi-agent fleets where a supervisor delegates to three sub-agents and they in turn choose tools, cutting 1,200 ms at each branch reduces total execution time from 6 seconds to under 500 ms.
The maturity of AI agents in production isn’t about throwing bigger models at simple problems, but about decoupling every link in the compute chain to use exactly the tool the problem calls for.