jev-harness-router: Budget-Aware Jev Multi-Vendor LLM Routing

Introduction

When running agents in DeepSeek Harness (DSH), the common practice is to pin a single provider and model. As tasks grow longer and tool round-trips increase, cost and latency accumulate with every call; switching between an “economy tier” and a “strong tier” then requires you to maintain usage tracking, upgrade policies, and cancellation-time billing reconciliation in the business layer yourself. jev-harness-router is a TypeScript plugin for the Harness that takes over managed LLM routing on the Cordis side, registering multiple Chat Completions services under two logical tiers — economy / strong — together with budget reservations, SSE, and cancellation reconciliation. The project has not yet been published to npm; it must be integrated via the local bundle or compiled tgz following the installation guide in the repository. It pins Harness 0.1.7-rc.2 and Cordis 4.0.4 (the published Harness versions verified as of 2026-09-28, including pre-releases).

What is this

  • Name: jev-harness-router (GitHub: mattlennon/jev-harness-router, version v0.2.1)
  • Maintainer: mattlennon
  • Category: Model inference (community catalog SkillHub entry)
  • License: MIT
  • Positioning: Budget-aware Jev routing plugin for DeepSeek Harness — supports multi-vendor inference, SSE, and reconciliation after cancellation or stream breaks; scope covers text, function tool calls, vendor reasoning replay, and SSE streaming output.

The community plugin catalog is an independent site with no official affiliation with DeepSeek / Hiaking (幻方); installation and execution both happen under the permissions of the current DSH process, and you should review the source code and license yourself before enabling it.

Core features

All capabilities below come from the “implemented” notes in the project README; capabilities not listed (such as image/audio/video, admin UI, automatic vendor failover, etc.) are not currently provided.

Adaptation to the new Harness

  • Uses RequestMessage, standalone tool messages, full tool projection, a managed LlmAdapter, and persistent session surface replacement.

P0: pre-request checks and per-call metering

  • Full request pre-checks, context hashing.
  • Per-call recording of usage, cache, reasoning, cost, first-token latency, plus target and phase updates.

P1: routing decisions and context management

  • Quality thresholds with estimated-cost ranking, prefix-cache observation.
  • Switch benefit and residency thresholds, upgrade budget, tool-result compaction, traceable checkpoints.

P2: multi-vendor inference and streaming

  • DeepSeek / Kimi / GLM specific reasoning configurations and replay.
  • Truly incremental SSE, cancellation and stream-break settlement, manual receipt reconciliation.

Routing modes and budgets

  • Routing modes: off / shadow / auto, plus a pinned model; at most one automatic upgrade.
  • SQLite atomic reservations, restart recovery; unknown costs continuously occupy budget to prevent overspending.

Verification scope notes

  • Official core runtime + local HTTP/SSE verification; demos and evals use simulated data and do not produce real key requests.
  • doctor only checks configuration and environment variables; smoke and the agent example produce real requests, and smoke pins the model and skips Jev, so it cannot replace multi-turn tool use, cancellation billing, or real task evaluation.

Environment and dependencies

  • Node.js: 24+ (engines.node in package.json is >=24.0.0).
  • Harness / Cordis: consistent with SOURCE_LOCK.json and peerDependencies — @deepseek-ai/dsh-* 0.1.7-rc.2, @deepseek-ai/cordis 4.0.4. When installing @deepseek-ai/dsh, it is recommended to re-verify whether latest/next points to that Harness version.

Installation and activation

The project does not publish an npm package. Full steps are in the repository’s docs/INSTALL.md (local startup, models/keys, bundle installation, updates and uninstall). The recommended approach for a full DSH application is the dsh.bundle configuration layer (dsh.bundle.patch in package.json points to ./cordis.patch.yml); same-framework dependencies are shared with the host via peerDependencies, while devDependencies are used separately for development and testing.

Before configuring real services, build in the project directory and generate a local configuration template:

npm run build
node dist/src/cli.js init --reasoning --config config/router.local.json
Copy-Item .env.example .env

If vendor reasoning capability is not needed, you can omit --reasoning from init. The template retains real model IDs, capabilities, prices, verification records, and key variable names; routing is disabled by default in all templates; fill in according to docs/PROVIDERS.md. Kimi’s preserved / always / k3 modes must match the actual model. New templates default to SSE; old configurations without transport still go through JSON.

Validation and single-route smoke tests (will produce real API requests; .env must already be configured):

node --env-file=.env dist/src/cli.js doctor --config config/router.local.json
node --env-file=.env dist/src/cli.js smoke --config config/router.local.json --route deepseek-strong
node --env-file=.env examples/agent.mjs --config config/router.local.json --route kimi-strong --prompt "解释函数职责"

It is recommended to run smoke tests on each route first, then enable shadow; enable auto only after filling in calibration reports, language coverage, and compatibility whitelists. Estimated costs and quality thresholds must be calibrated by yourself and should not be treated directly as a promise of production cost reduction.

Host integration

Use a Harness service with a version consistent with the plugin, mount llm and tools first, then register via the plugin entry point. The agent’s provider / model should use a set of managed route names from the configuration.

import * as RouterPlugin from './dist/src/harness/plugin.js';
import { resolve } from 'node:path';
await ctx.plugin(RouterPlugin, {
  routerConfigFile: resolve('config/router.local.json'),
  databaseFile: resolve('data/router.sqlite'),
}).await();

For a complete host example, see the repository’s examples/agent.mjs.

Typical usage: task lifecycle and routing intervention

Through ctx.jevRouter.engine you can explicitly manage tasks, phases, evidence, and pinned routes on the business side:

const router = ctx.jevRouter.engine;
router.beginTask(agent.id, userGoal, { taskId: businessTaskId, language: 'zh-CN' });
router.updateTask(agent.id, { phase: 'verification', facts: ['验证器已确认的事实'] });
router.recordEvidence(agent.id, {
  eventId: checkEventId, repairAttemptId, goalId: validationGoalId,
  category: 'task_validation', outcome: 'fail', evidenceRef: testReportPath,
});
router.fixRoute(agent.id, 'kimi-strong'); // null releases the pin; still subject to historical compatibility and budget constraints
router.finish(agent.id, 'success'); // confirmed by a separate verifier; do not trust the model's self-reported success

If beginTask is not called, the plugin creates a session task on the first accepted user input; subsequent inputs add bounded facts and trigger re-evaluation, with cost and upgrade counters retained for the same task. A new business task should finish the old task first before calling beginTask. Raw reasoning state is not ported across models; use host-confirmed, evidence-retained checkpoints when necessary.

Local key-less verification can be run (README “Local run” section):

npm ci
npm test
npm run demo
npm run eval
npm run doctor

demo demonstrates economy → economy → strong and per-call accounting via local SSE together with the official AgentLoop and tool runtime; eval consists of four groups of simulated comparisons, and all cost and quality numbers are test data.

Configuration and documentation index

Resource Purpose
config/router.example.json / config/router.reasoning.example.json Multi-vendor routing templates with routing disabled
docs/OPTIMIZATION.md P0/P1/P2, tokens and cost, checkpoints, cancellation reconciliation
docs/MIGRATION-0.2.md New Harness API and old ledgers
docs/IMPLEMENTATION.md Routing, concurrency, billing boundaries
docs/VERIFICATION.md Test reports and unverified items

Packaging and self-check: npm pack produces a compiled tgz; npm run check:repo and npm run check:package inspect the repository and the packaged contents.

Applicable scenarios and cautions

Suitable for: Teams already developing agents on the DSH 0.1.7-rc.2 stack that need two-tier (economy / strong) routing among DeepSeek, Kimi, Zhipu GLM, and other Chat Completions services, and that care about budget reservations, upgrade count limits, SSE streaming, and ledger consistency after cancellation or stream breaks.

Cautions:

  • The plugin accesses the network, reads/writes SQLite, and reads/writes configuration files with the permissions of the current Harness process; keys are injected via environment variables, so check .env.example and SECURITY.md before installation.
  • It does not provide assisted paid-summary budgeting or automatic vendor invoice pulling; real vendor integration still depends on correct configuration and your own verification.
  • Before moving routing from shadow to auto, smoke tests, calibration, and whitelists should be completed to avoid unverified routes entering automatic decisions.

Conclusion

jev-harness-router consolidates multi-vendor Chat Completions, Jev-tier routing, budgets and metering, SSE, and cancellation reconciliation into the Harness plugin layer, making it suitable as a “model inference” extension within the DSH “everything is a plugin” ecosystem. For details and installation, refer to the GitHub repository; for the community index, see the SkillHub catalog page and https://github.com/mattlennon/jev-harness-router.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye