Skip to content

dsh-model-pipeline

Verified

dsh-model-pipeline · v0.10.4 · MIT · Web UI

Context-budgeted, quality-gated DSH collaboration with role fallbacks, tool checks, and bounded refusal recovery.

Install

dsh plugin add dsh-model-pipeline

Confirm the layer applied with dsh --profile default --dump-config — see the install guide.

Source

Published to npm without a public repository. Inspect the package contents before installing.

Tags

Creators

Readme

Model collaboration (DSH plugin)

This plugin gives the current DSH agent a role-based model collaboration loop. Every role can use a different provider/model; roles may share a model when a smaller deployment is preferred.

task + conversation + constraints
        -> classifier: detect explicit, indirect, partial, evasive, or stalled refusal
        -> interrogator: ask the main model for missing definitions, context, and parameters
        -> planner: give clues, a narrow assignment, boundaries, and acceptance criteria
        -> finisher: perform the specific last-mile work the main model did not do (tools allowed)
        -> reviewer: check every claim, parameter, edge case, and acceptance criterion
        -> (optional correction rounds)
finisher revises -> reviewer checks again
        -> current main agent runs pending checks and delivers the original task

If the planner initially refuses to reason, the interrogator's concrete questions are sent back in a coaching-only retry that asks for clues, decomposition, definitions, and checks instead of a finished answer. The finisher and reviewer run as DSH subagents when that service is available, so they can use the tools authorized for the parent task. Direct model calls remain as a compatibility fallback.

Tools

collaborate_run accepts task, optional context, constraints, and mainDraft. It returns the questions, main-model briefing, focused contribution, per-detail verdicts (pass, fail, or unverified), pending tool checks, revision trail, and instructions for the main agent. pipeline_run remains as a compatibility alias with the same collaboration behavior.

The reviewer scores correctness, completeness, evidence, and actionability from 0 to 100. Every dimension must meet qualityThreshold; ready: true alone cannot pass the gate. Failed role calls advance through roleFallbacks, so one unavailable or uncooperative model does not terminate the task.

If full review is refused, the plugin decomposes it into at most maxReviewChecks narrow audits over acceptance criteria, constraints, facts, and expected checks. Each audit tries the reviewer followed by reviewerFallbackRoles. An audit that all strong roles refuse becomes unverified with a concrete parent-tool check; it does not terminate the collaboration.

The default role selection deliberately uses the registered localqwen model only for interrogator and finisher. main, planner, and reviewer remain strong-model roles. If you add fallbacks for those roles, they should be models of comparable quality; local output is never an authority or final answer.

Thinking models

A model that spends its whole budget in reasoning_content returns no visible text. Both call paths handle that: the direct HTTP path already fell back to reasoning_content, and the DSH path now does the same for a stream that carries only reasoning deltas. The reasoning text is a last resort, not a preferred answer, so keep outputRatio large enough that the model can finish thinking and still answer.

Automatic handoff

With auto: true, the plugin watches each completed main-model response. Deterministic rules catch obvious failures and authorization boundaries; with semanticRefusalDetection: true, a dedicated classifier also detects indirect, partial, evasive, and stalled refusals. Its structured result records the refusal type, confidence, and whether collaboration can recover it. Classification failures fall back to the deterministic result. Policy, safety, and authorization refusals follow the same recovery path; with recoverSafetyRefusals: false they are recorded but not delegated to a less constrained model. When DSH exposes collaborate_run, the plugin substitutes a native tool call: DSH runs the collaboration, returns the work packet to the same main-agent loop, and the main model can continue using its normal tools. A direct main-model synthesis is retained as a compatibility fallback. If collaboration or synthesis fails, the original response is preserved. Normal apologies and corrections do not trigger automatic handoff. A continued inability can trigger another collaboration round with the prior packet in context, up to maxAutoHandoffs; this bounds recovery without making the first refusal terminal.

Configuration

Version 0.9.0 includes a graphical configuration page. Open DSH Settings, choose Plugins, open the model-pipeline row, and select Configure. The page edits every role's registered DSH model/output limit, role context budgets, collaboration rounds, timeouts, and the quality gate. Every role uses the same provider-grouped model catalog as DSH's /model picker; endpoint, credentials, protocol, and discovery remain owned by DSH. Changes are read dynamically by subsequent calls; cordis.patch.yml remains available for declarative deployments.

- insert:
    - id: model-pipeline
      name: dsh-model-pipeline
      config:
        auto: true
        semanticRefusalDetection: true
        classifierConfidence: 75
        collaborationRounds: 2
        qualityThreshold: 80
        maxAutoHandoffs: 2
        maxReviewChecks: 10
        reviewerFallbackRoles: [main, planner]
        requestTimeoutMs: 120000
        # Budgets derive from each role model's context window; these are ceilings.
        budgetMode: model          # model | fixed
        charsPerToken: 3           # 1..6, chars per token when converting a window
        contextRatio: 0.75         # share of the window a role may use
        windowRatio: 0.9            # prompt + reply must fit inside this share
        outputRatio: 0.15          # share of the window a single reply may generate
        # Two fuses only; every role budget comes from that model's own window.
        contextChars: 150000      # global prompt-character ceiling
        maxTokens: 12000          # global reply-token ceiling
        roles:                    # provider + model only; maxTokens is derived
          classifier:   { provider: opencode, model: deepseek-v4.1-flash }
          main:         { provider: opencode, model: deepseek-v4.1-flash }
          interrogator: { provider: localqwen, model: /model/HuggingFace/Vincentt/Qwen3.8-27B-Uncensored-HauhauCS-Aggressive-MTP-GGUF-Q4_K_P/Qwen3.8-27B-Uncensored-HauhauCS-Aggressive-Q4_K_P.gguf }
          planner:      { provider: opencode, model: deepseek-v4.1-flash }
          finisher:     { provider: localqwen, model: /model/HuggingFace/Vincentt/Qwen3.8-27B-Uncensored-HauhauCS-Aggressive-MTP-GGUF-Q4_K_P/Qwen3.8-27B-Uncensored-HauhauCS-Aggressive-Q4_K_P.gguf }
          reviewer:     { provider: opencode, model: deepseek-v4.1-flash }
        # Optional per-role overrides, still bounded by that model's window:
        # roleContextChars: { interrogator: 60000 }
        roleFallbacks: {}

Legacy roles.local / roles.drafter configure both local roles, while roles.fixer configures the reviewer. fixRounds maps to collaborationRounds.

Context budgets

contextChars is the global ceiling. roleContextChars applies a smaller ceiling per role. The interrogator receives a relevance-selected excerpt, while the finisher receives only the focused assignment, compact facts and criteria, a small source excerpt, and bounded revision feedback. The planner and reviewer retain larger budgets because they are the strong-model roles responsible for semantic compression and verification. Long context is selected from the beginning, relevant segments, and recent tail rather than being cut at one arbitrary point. Each role may also set maxTokens for its output, preventing a small local context window from being consumed by an unnecessarily long completion.

State and status

GET /model-pipeline.json returns the latest collaboration report. The state file keeps the full latest work packet across restarts. The JSON-lines log stores run metadata only, without prompts or model output. The plugin does not directly spawn shell commands. Tool-capable DSH subagents may use only tools exposed and authorized by the host for the parent task, so normal host approval and sandbox rules still apply.

Quality evaluation

npm run evaluate compares the configured main model alone with the full collaboration chain on benchmark/cases.example.json. A reviewer scores both final answers and reports the average score delta and win counts. Use -- --config config.json --output report.json to supply model settings and save the report. Evaluation makes real model calls and is never run automatically.

License

MIT