← All projects
AI Infrastructure

llama-router

Adaptive reasoning-budget control for hybrid reasoning models

Year
2026–present
Our role
Design & engineering
Stack
Gollama.cppDARTKubernetes

The Problem

Generic LLM proxies often fail to forward backend-specific request properties, silently dropping critical parameters like reasoning budgets or grammar constraints. More importantly, most applications are tightly coupled to a specific server or model version, making it difficult to rotate backends or upgrade hardware without rewriting client code.

Without an abstraction layer, developers must choose between a fixed reasoning budget—which leads to "overthinking" on simple queries and insufficient depth on complex ones—or risking empty responses when models exhaust their token budgets entirely on invisible reasoning content.

About llama-router

llama-router is a purpose-built adapter and proxy for llama.cpp backends. It serves as a unified frontend that decouples applications from their underlying models, providing a robust interface that makes self-hosted Llama models a viable, near drop-in replacement for proprietary APIs like GPT-4 or Claude.

By implementing Draft-Agreement Routing (DART), the router optimizes the trade-off between latency and accuracy—dynamically deciding how much "thinking" a model should perform for any given query. This ensures a high-performance experience while maintaining the flexibility to switch backends or models without changing a single line of application code.

The DART Mechanism

The router implements a high-efficiency routing pipeline based on Draft-Agreement Routing (DART) to maximize throughput:

Stage 1: Parallel Draft Agreement

The router fires two independent requests to the backend with reasoning explicitly disabled. These 'drafts' are extremely cheap, fast, and run in parallel to minimize latency.

A task-specific equivalence function checks if the two drafts agree on the answer. If they do, the router accepts the result immediately, bypassing the expensive reasoning process entirely.

Stage 2: Intelligent Escalation

If the drafts disagree, or if the model attempts a tool call, the router automatically escalates the query to a full reasoning session.

This ensures that simple queries are answered instantly while complex problems receive the full depth of the model's thinking capabilities.

Key Features

Adaptive Thinking Gate

Bypasses reasoning for simple queries through parallel draft agreement, significantly reducing latency and total token spend.

Full Param Passthrough

Every llama.cpp specific parameter is forwarded untouched to the backend, ensuring a transparent and lossless proxy layer.

Tool-Call Awareness

Automatically detects tool-call intentions during the draft phase to ensure structured outputs are always escalated for maximum precision.

Empty-Response Mitigation

Prevents silent failures by strictly managing reasoning flags, ensuring models never burn their entire budget on invisible content.

Agent & CLI Compatibility

llama-router is specifically engineered to support the high-reliability requirements of autonomous AI agents and developer tools, such as Claude Code.

Stable Loop Execution

By eliminating the 'empty-response' bug through strict budget capping, llama-router ensures that agentic loops never hang or crash due to silent failures in long-context reasoning.

Tool-Call Precision

Full passthrough of grammar and schema constraints allows agents to enforce strict JSON or tool-call formats, ensuring that the model's output is always programmatically parseable.

Dynamic Depth

Agents can shift between 'fast' mode for simple file reads and 'deep' mode for complex architectural refactoring, with the router automatically optimizing the compute cost for each.

Latency Optimization

DART's ability to bypass reasoning on trivial queries reduces the time-to-first-token for agentic interactions, making CLI tools feel snappier and more responsive.

Have a project like this one?

We'd be glad to talk through your goals, your constraints, and whether we're the right team for the work.