dfj 57b52df17f Mirror server output into the WSL console window
The run_ wrappers now tee the server's stdout/stderr into the launching console (the window the plugin opens) in addition to the log file, and title the window per model. Closing the window kills only tee; Python raises BrokenPipeError on the dead pipe and the logging module contains it, so the server keeps running. pipefail keeps the EXIT= line reporting the launcher's exit code.
2026-11-11 18:30:24 +01:00

opencode-vllm-autostart

OpenCode Desktop plugin and launcher set for local vLLM models running in WSL2, tuned for a single RTX 5090 (32 GB).

The plugin starts the model you pick the moment you send a request, stops the previous one first, and adds an Eject button that unloads the model and frees the GPU. It also keeps prompt media within each model's image/video budget so a long session does not get stuck on vLLM's per-prompt limits.

What it does

  • Auto-start — before a request to a vllm model, the plugin stops the running server, waits for VRAM to be released, and launches the selected model through its launcher script.
  • Eject — a titlebar pill and the command-palette action vLLM: Eject loaded model. It only stops a server this plugin started (tracked through ~/.vllm-autostart-owner).
  • Media budgets — old images/videos are replaced with text in the outgoing request only (history is untouched) to stay under --limit-mm-per-prompt. This prevents the "At most N image(s) may be provided" hard lock in long sessions.
  • WSL twin — Desktop runs a second OpenCode server for WSL projects that cannot invoke Windows launchers. wsl-plugin/ is a native Linux variant that starts the same models directly.

Layout

plugin/                 OpenCode Desktop plugin (server + GUI)
  src/index.ts          auto-start hook, media trimming, RPC, ownership
  src/rpc.ts            RPC contract shared by server and GUI
  src/gui.tsx           titlebar pill + command-palette action
  dist/                 built GUI bundle (gui-experimental.cjs)
wsl-plugin/index.ts     WSL-native server plugin (fetch-based, no GUI)
launchers/
  launch_*.sh           vLLM commands (model path, flags, VRAM heuristic)
  run_*.sh              logging wrappers used by the plugins
  kill_vllm.sh          stop the server and report free VRAM
  video_preprocessor_config.json
config/
  opencode.windows.example.json
  opencode.wsl.example.json
scripts/
  quickcheck.py         is the API up, and which model is served?
  bench_generic.py      chat / code / JSON throughput check
  check-syntax.sh       bash -n over every launcher

Requirements

  • Windows 10/11 with OpenCode Desktop (V2)
  • WSL2 Ubuntu with an NVIDIA driver that exposes nvidia-smi
  • A Python venv with vLLM (VLLM_ENV, default /home/dfj/vllm-env)
  • Models in HF format under MODELS (default /home/dfj/models)
  • The launch scripts must be reachable from WSL through /mnt/c/...

The defaults in this repo match /home/dfj; override them when your layout is different:

Variable Default Used by
VLLM_ENV /home/dfj/vllm-env launchers
MODELS /home/dfj/models launchers
VLLM_LAUNCHER_DIR /mnt/c/Users/dfj/projects/vllm-autostart/launchers plugins
MODEL_DIR $MODELS/THe-Plague/... launch_qwen36_unc.sh only

Install

  1. Clone this repository next to your home directory, e.g. C:\Users\dfj\projects\vllm-autostart.

  2. Build the plugin once (or use the committed dist/):

    cd C:\Users\dfj\projects\vllm-autostart\plugin
    npm ci
    npm run build
    
  3. Merge config/opencode.windows.example.json into %USERPROFILE%\.config\opencode\opencode.json. Point plugins at the absolute plugin directory:

    "plugins": ["C:/Users/dfj/projects/vllm-autostart/plugin"]
    
  4. In the WSL sidecar config (~/.config/opencode/opencode.json), point plugins at the WSL plugin directory:

    "plugins": ["/mnt/c/Users/dfj/projects/vllm-autostart/wsl-plugin"]
    
  5. Make the launchers executable (WSL usually mounts /mnt/c as 0777, so this is normally unnecessary):

    chmod +x /mnt/c/Users/dfj/projects/vllm-autostart/launchers/*.sh
    

OpenCode reloads configuration and plugins on save. If the GUI bundle changed, restart the Desktop app.

Models

Served name Hugging Face repo Context Notes
qwen3.6-35b-uncensored THe-Plague/Qwen3.6-35B-A3B-abliterated-NVFP4-MTP 262,144 Primary. Abliterated, NVFP4, vision + video. ~117–137 tok/s. MTP disabled.
qwen3.8-uncensored preetpatel/Qwen3.8-27B-Uncensored-NVFP4 163,840 Uncensored 27B. 8 images, 2 MP each.
qwen3.8-fast unsloth/Qwen3.8-27B-NVFP4 65,536 Speculative MTP=3, no media. Fastest 27B.
agents-a1 protoLabsAI/Agents-A1-NVFP4 131,072 35B-A3B agent model. ~139 tok/s.

Only one model can be resident at a time. The plugins enforce this by stopping the current server before starting the next one.

Qwen3.6 video fix

vLLM 0.27.x was built against an older transformers where the video-processor mapping stores a class-name string. transformers 5.x stores a dict per backend, which vLLM feeds into a dict lookup and crashes with unhashable type: 'dict' on every video request.

launch_qwen36_unc.sh writes a local video_preprocessor_config.json into the model directory:

{ "video_processor_type": "Qwen3VLVideoProcessor" }

This makes vLLM resolve the processor name itself. The file is recreated on start if missing.

MTP on Qwen3.6

The checkpoint ships an MTP draft layer. With the BF16 draft on Triton it accepted 2.5–3.5 tokens/step but measured ~50 tok/s versus 117–137 tok/s without speculative decoding on this stack, so it stays off. MTP is enabled for qwen3.8-fast, where it is a net win.

VRAM behavior

Launchers that need a large model compute utilization from current free VRAM:

util = min(0.92, (free - 1024 MiB) / total)

The floor is 0.62 so a busy desktop does not make the model unloadable. The Qwen3.6 launcher uses this adaptive value; smaller models use a fixed value.

Media support

Model Images/prompt Videos/prompt Plugin budget
qwen3.6-35b-uncensored 8 1 8 images, 1 video
qwen3.8-uncensored 8 0 6 images
qwen3.8-fast, agents-a1 0 0 0

Image resolution is capped with --mm-processor-kwargs '{"max_pixels": ...}' (1 MP for Qwen3.6, 2 MP for the 27B).

Notes:

  • The OpenCode server/API forwards video attachments correctly; the model sees the frames (verified with a blue test clip). Desktop drag-and-drop uses the same path.
  • The OpenCode CLI (opencode run --file) has a hardcoded extension allowlist without video types, so it silently drops .mp4. Use the Desktop UI or the HTTP API for video.
  • vLLM counts every image/video in the prompt, including tool results from the session history. The plugin trims the oldest ones per request.

Troubleshooting

  • Model does not start: check the log named in run_*.sh (/home/dfj/qwen36_unc.log, etc.) and nvidia-smi.
  • Stale "running" state: the plugin polls http://127.0.0.1:8000/v1/models; a server started manually is treated as not owned and will not be ejected.
  • Plugin not loading: verify the plugins path is absolute, contains package.json (Windows plugin) or index.ts (WSL plugin), and check ~/.local/share/opencode/log/opencode.log.
  • Video returns unhashable type: 'dict': the per-model video_preprocessor_config.json is missing; restart the Qwen3.6 launcher.

License

Private repository. No license granted unless added explicitly.

S
Description
OpenCode Desktop plugin and WSL launchers for on-demand local vLLM models
Readme
104 KiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 66.5%
Shell 27.8%
Python 5.7%