Skip to content

feat: add Token Overdrive local inference provider (llama.cpp DMR router) - #498

Closed
jecruz wants to merge 1 commit into
NVIDIA:mainfrom
jecruz:feat/yama-local-provider
Closed

feat: add Token Overdrive local inference provider (llama.cpp DMR router)#498
jecruz wants to merge 1 commit into
NVIDIA:mainfrom
jecruz:feat/yama-local-provider

Conversation

@jecruz

@jecruz jecruz commented Mar 20, 2026

Copy link
Copy Markdown

Summary

Adds Token Overdrive as a fourth local inference provider alongside nim-local, ollama-local, and vllm-local.

Token Overdrive is backed by a custom llama.cpp fork with a Dynamic Model Router that enables hot-swapping GGUF models without server restart. It runs Metal-accelerated on Apple Silicon and exposes a standard OpenAI-compatible API on port 8101.

  • Provider ID: token-overdrive
  • Port: 8101
  • API: OpenAI-compatible (/v1/models, /v1/chat/completions)
  • Default model: qwen35-35b-a3b (60 tps on Apple Silicon)
  • Health check: GET /v1/models
  • Model discovery: live query of running router's /v1/models endpoint

Changes

File What changed
bin/lib/local-inference.js token-overdrive case in all provider switch blocks; getYamaModelOptions, getDefaultYamaModel, getYamaProbeCommand, validateYamaModel
bin/lib/inference-config.js token-overdrive provider config with label "Token Overdrive (llama.cpp DMR)"; correct default model in getOpenClawPrimaryModel
bin/lib/token-overdrive-models.json Local model catalog (two tuned models with observed tps)

Test plan

  • getLocalProviderHealthCheck("token-overdrive") returns correct curl command for port 8101
  • validateLocalProvider("token-overdrive", ...) returns descriptive error when router not running
  • getYamaModelOptions returns ["qwen35-35b-a3b"] fallback when router unreachable
  • getProviderSelectionConfig("token-overdrive") returns correct providerLabel
  • getOpenClawPrimaryModel("token-overdrive", null) resolves to inference/qwen35-35b-a3b
  • npm test passes

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced Token Overdrive as a new local inference provider option
    • Added Qwen3.5-35B-A3B and Qwen3.5-27B model support for local inference
    • Enhanced model discovery and validation capabilities for local providers

Token Overdrive is a new local inference provider backed by a custom
llama.cpp fork (yama.cpp) with a Dynamic Model Router that hot-swaps
GGUF models without server restart. Metal-accelerated on Apple Silicon.

Changes:
- local-inference.js: add token-overdrive case to getLocalProviderBaseUrl,
  getLocalProviderHealthCheck, getLocalProviderContainerReachabilityCheck,
  and validateLocalProvider (port 8101, OpenAI-compatible /v1/models health)
- local-inference.js: add getYamaModelOptions, getDefaultYamaModel,
  getYamaProbeCommand, validateYamaModel — queries live /v1/models endpoint
  to enumerate router-loaded models; falls back to DEFAULT_YAMA_MODEL
- inference-config.js: add token-overdrive provider case with label
  "Token Overdrive (llama.cpp DMR)"; default model qwen35-35b-a3b (60 tps)
- token-overdrive-models.json: local model catalog with tuned defaults
  (qwen35-35b-a3b at 60 tps, qwen35-27b at 17 tps, both via Docker Model Runner)

Provider ID: "token-overdrive"
Port: 8101
Health: GET /v1/models (OpenAI-compatible)
Probe: POST /v1/chat/completions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The pull request introduces support for a new local inference provider called "Token Overdrive" (llama.cpp DMR). This involves adding provider configuration, model discovery utilities, validation helpers, and a model catalog file that defines available Qwen models with their performance characteristics and recommendations.

Changes

Cohort / File(s) Summary
Configuration and Provider Registration
bin/lib/inference-config.js
Added DEFAULT_YAMA_MODEL export and new "token-overdrive" provider case with custom endpoint configuration. Updated getOpenClawPrimaryModel to select fallback models based on provider type (ollama-local, token-overdrive, or cloud).
Local Inference Provider Utilities
bin/lib/local-inference.js
Extended provider URL and health check functions to support "token-overdrive" via YAMA_PORT. Added model discovery functions (getYamaModelOptions, getDefaultYamaModel) and validation utilities (validateYamaModel, getYamaProbeCommand) that probe endpoints and fall back to default model. Exported new constants and functions.
Token Overdrive Model Catalog
bin/lib/token-overdrive-models.json
New JSON catalog defining versioned metadata for Token Overdrive models, including two Qwen3.5 model variants with performance metrics, recommended context sizes, and usage notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A new provider hops into view,
Token Overdrive, shiny and new,
With Qwen models prancing about,
Local inference, without a doubt,
Fast inference speeds, what a delight! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding Token Overdrive as a new local inference provider. It is specific, clear, and directly reflects the core objective of the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
bin/lib/inference-config.js (1)

71-75: Consider a lookup map if more local providers are added.

The nested ternary works for two special cases, but could become unwieldy if more local providers with distinct defaults are introduced. A simple object lookup would improve readability:

♻️ Optional refactor for maintainability
 function getOpenClawPrimaryModel(provider, model) {
-  const localDefault =
-    provider === "ollama-local" ? DEFAULT_OLLAMA_MODEL :
-    provider === "token-overdrive" ? DEFAULT_YAMA_MODEL :
-    DEFAULT_CLOUD_MODEL;
+  const LOCAL_DEFAULTS = {
+    "ollama-local": DEFAULT_OLLAMA_MODEL,
+    "token-overdrive": DEFAULT_YAMA_MODEL,
+  };
+  const localDefault = LOCAL_DEFAULTS[provider] || DEFAULT_CLOUD_MODEL;
   const resolvedModel = model || localDefault;
   return resolvedModel ? `${MANAGED_PROVIDER_ID}/${resolvedModel}` : null;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/lib/inference-config.js` around lines 71 - 75, Replace the nested ternary
that computes localDefault with a lookup map keyed by provider to improve
readability and maintainability: create a map (e.g., providerDefaultMap) that
maps "ollama-local" to DEFAULT_OLLAMA_MODEL and "token-overdrive" to
DEFAULT_YAMA_MODEL, then set localDefault = providerDefaultMap[provider] ||
DEFAULT_CLOUD_MODEL and keep resolvedModel = model || localDefault; update
references to localDefault, provider, DEFAULT_OLLAMA_MODEL, DEFAULT_YAMA_MODEL,
DEFAULT_CLOUD_MODEL, and resolvedModel accordingly.
bin/lib/token-overdrive-models.json (1)

7-14: Clarify the discrepancy between id and canonical_id naming.

The id uses qwen35-35b-a3b while canonical_id uses qwen3.5-35b-a3b (note 35 vs 3.5). This inconsistency could cause confusion when mapping models. If id is used for API calls and canonical_id is for display/documentation purposes, this is fine—but consider documenting the convention.

Also, the provider field is "docker-model-runner" here, while the PR describes the provider ID as "token-overdrive". Verify whether this field represents the underlying engine vs. the user-facing provider selection.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/lib/token-overdrive-models.json` around lines 7 - 14, The id/canonical_id
mismatch should be resolved: pick the canonical naming convention (e.g., use dot
notation like "qwen3.5-35b-a3b" or remove the dot to "qwen35-35b-a3b") and make
both "id" and "canonical_id" identical, updating the "id" or "canonical_id"
field in the JSON to match the chosen convention; additionally verify the
"provider" field and set it to the intended provider ID ("token-overdrive") if
this entry represents the user-facing provider, or keep "docker-model-runner"
only if it intentionally denotes the underlying engine, and add a brief inline
comment or documentation entry describing the convention for id vs canonical_id
and provider semantics.
bin/lib/local-inference.js (2)

70-74: Consider consistent terminology in error messages.

The error messages reference "yama" and "yama router" while the user-facing provider is "token-overdrive" with label "Token Overdrive (llama.cpp DMR)". This could confuse users who selected "token-overdrive" but see "yama" in errors.

♻️ Proposed terminology alignment
       case "token-overdrive":
         return {
           ok: false,
-          message: `Local yama (llama.cpp DMR router) was selected, but nothing is responding on http://localhost:${YAMA_PORT}. Start the router with: python3 scripts/run_dmr_router_workflow.py --model <model-id>`,
+          message: `Token Overdrive (llama.cpp DMR router) was selected, but nothing is responding on http://localhost:${YAMA_PORT}. Start the router with: python3 scripts/run_dmr_router_workflow.py --model <model-id>`,
         };
     case "token-overdrive":
       return {
         ok: false,
         message:
-          `Local yama router is responding on localhost, but containers cannot reach http://host.openshell.internal:${YAMA_PORT}. Ensure llama-server binds to 0.0.0.0:${YAMA_PORT} (add --host 0.0.0.0 to the router preset).`,
+          `Token Overdrive router is responding on localhost, but containers cannot reach http://host.openshell.internal:${YAMA_PORT}. Ensure llama-server binds to 0.0.0.0:${YAMA_PORT} (add --host 0.0.0.0 to the router preset).`,
       };

Also applies to: 103-108

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/lib/local-inference.js` around lines 70 - 74, The error messages in the
case "token-overdrive" branch reference "yama"/“yama router”, which is
inconsistent with the provider label "Token Overdrive (llama.cpp DMR)"; update
the user-facing strings in the case "token-overdrive" return objects (the
message that mentions http://localhost:${YAMA_PORT} and the similar message
later in the file) to use consistent terminology such as "Token Overdrive
(llama.cpp DMR)" or "Token Overdrive router" (and keep the YAMA_PORT variable)
so users who selected "token-overdrive" see matching names.

141-158: Consider surfacing HTTP/connection errors distinctly from model errors.

When output is falsy (line 143), it could mean the router is down, the model isn't loaded, or a timeout occurred. The current message assumes the model needs loading, but a connection failure would give the same symptom. This is a minor UX consideration—the existing behavior is acceptable.

Additionally, for consistency with the terminology point above:

♻️ Optional: align "yama model" with "Token Overdrive"
   if (!output) {
     return {
       ok: false,
       message:
-        `yama model '${model}' did not answer the probe. The DMR router may need to load it first. ` +
+        `Token Overdrive model '${model}' did not answer the probe. The DMR router may need to load it first. ` +
         `Run: python3 scripts/run_dmr_router_workflow.py --model ${model}`,
     };
   }
   try {
     const parsed = JSON.parse(output);
     if (parsed && typeof parsed.error === "string" && parsed.error.trim()) {
-      return { ok: false, message: `yama model '${model}' probe failed: ${parsed.error.trim()}` };
+      return { ok: false, message: `Token Overdrive model '${model}' probe failed: ${parsed.error.trim()}` };
     }
   } catch {}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/lib/local-inference.js` around lines 141 - 158, The validateYamaModel
function treats any falsy runCapture output as "model not loaded"; update
validateYamaModel to distinguish connection/HTTP/timeout failures from model
probe failures by checking runCapture error/exit status (or capturing stderr)
when calling runCapture(getYamaProbeCommand(model)), and produce distinct
messages: one indicating router/connection issues (include the underlying error
or status) and another indicating the model probe returned no/empty response or
returned parsed.error; also keep the existing parsed JSON handling for
parsed.error (parsed.error) and adjust wording to consistently use the preferred
"Token Overdrive" terminology if desired.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@bin/lib/inference-config.js`:
- Around line 71-75: Replace the nested ternary that computes localDefault with
a lookup map keyed by provider to improve readability and maintainability:
create a map (e.g., providerDefaultMap) that maps "ollama-local" to
DEFAULT_OLLAMA_MODEL and "token-overdrive" to DEFAULT_YAMA_MODEL, then set
localDefault = providerDefaultMap[provider] || DEFAULT_CLOUD_MODEL and keep
resolvedModel = model || localDefault; update references to localDefault,
provider, DEFAULT_OLLAMA_MODEL, DEFAULT_YAMA_MODEL, DEFAULT_CLOUD_MODEL, and
resolvedModel accordingly.

In `@bin/lib/local-inference.js`:
- Around line 70-74: The error messages in the case "token-overdrive" branch
reference "yama"/“yama router”, which is inconsistent with the provider label
"Token Overdrive (llama.cpp DMR)"; update the user-facing strings in the case
"token-overdrive" return objects (the message that mentions
http://localhost:${YAMA_PORT} and the similar message later in the file) to use
consistent terminology such as "Token Overdrive (llama.cpp DMR)" or "Token
Overdrive router" (and keep the YAMA_PORT variable) so users who selected
"token-overdrive" see matching names.
- Around line 141-158: The validateYamaModel function treats any falsy
runCapture output as "model not loaded"; update validateYamaModel to distinguish
connection/HTTP/timeout failures from model probe failures by checking
runCapture error/exit status (or capturing stderr) when calling
runCapture(getYamaProbeCommand(model)), and produce distinct messages: one
indicating router/connection issues (include the underlying error or status) and
another indicating the model probe returned no/empty response or returned
parsed.error; also keep the existing parsed JSON handling for parsed.error
(parsed.error) and adjust wording to consistently use the preferred "Token
Overdrive" terminology if desired.

In `@bin/lib/token-overdrive-models.json`:
- Around line 7-14: The id/canonical_id mismatch should be resolved: pick the
canonical naming convention (e.g., use dot notation like "qwen3.5-35b-a3b" or
remove the dot to "qwen35-35b-a3b") and make both "id" and "canonical_id"
identical, updating the "id" or "canonical_id" field in the JSON to match the
chosen convention; additionally verify the "provider" field and set it to the
intended provider ID ("token-overdrive") if this entry represents the
user-facing provider, or keep "docker-model-runner" only if it intentionally
denotes the underlying engine, and add a brief inline comment or documentation
entry describing the convention for id vs canonical_id and provider semantics.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 085fdec0-b214-4184-b51f-84368cb75921

📥 Commits

Reviewing files that changed from the base of the PR and between f56be8e and 4300bea.

📒 Files selected for processing (3)
  • bin/lib/inference-config.js
  • bin/lib/local-inference.js
  • bin/lib/token-overdrive-models.json

@jecruz

jecruz commented Mar 20, 2026

Copy link
Copy Markdown
Author

Closing — not ready for upstream review yet. Will reopen when complete.

@jecruz jecruz closed this Mar 20, 2026
@jecruz
jecruz deleted the feat/yama-local-provider branch March 20, 2026 18:03
@wscurran wscurran added the feature PR adds or expands user-visible functionality label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature PR adds or expands user-visible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants