Laya Tool Router

In DSH’s Standard preset, the model must process a system prompt containing 26 tool schemas before emitting the first word, causing prefill tokens to reach 6,559. This consumes a large portion of the context budget and increases time-to-first-token latency. Laya Tool Router solves this by hiding all tool schemas and revealing only one tool when needed through the Laya decision endpoint.

Core Features

This plugin implements lazy tool discovery, reducing prefill tokens from 6,559 to 283. It uses a 3-stage decision process:

  1. Lexical ranking: filter stop words and select ≤ 8 candidates.
  2. Decision request: send a POST request to the Laya endpoint to obtain bestTool and the usable null issue.
  3. Confidence check: accept the selection only when confidence >= 0.30 and p(noul) <= 0.30.

For exact tool-name requests, the plugin skips Laya and immediately reveals the tool.

Install and Enable

Install using the CLI:

dsh plugin --profile <profile> add git+https://github.com/residenthiago2011/DSH-Laya-Tool-Router.git

After installation, select this bundle on the Plugins page and use the no-prefill preset.

Configuration

A Laya endpoint running at http://127.0.0.1:8081/v1/systemone is required. Configure LAYA_BASE in index.js to change the address.

Files

  • index.js: registers find_tool, hides the other tools, and runs the 3-stage decision process.
  • cordis.patch.yml: preset declaration and host tool enablement.
  • tool-registry.json: Stage-0 labels and Stage-1 criteria.

Notes

  • Requires DSH 0.2.0-rc.2.
  • Requires pnpm on the host.
  • find_tool registers a standard JSON Schema and must always be compiled.
  • It includes empty-request directory prompts and an exact-name fast path, suitable for small models.
羽毛球分组比赛记分
小程序二维码

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

Xiaoye