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:
- Lexical ranking: filter stop words and select ≤ 8 candidates.
- Decision request: send a POST request to the Laya endpoint to obtain
bestTooland theusablenull issue. - Confidence check: accept the selection only when
confidence >= 0.30andp(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: registersfind_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
pnpmon the host. find_toolregisters 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.