All done — the latency bug is root-caused, fixed, and proven with live measurements on Qwen3.5-0.8B, and vLLM + llama.cpp are now first-class providers. Everything is on PR #13 (branch cursor/ollama-latency-vllm-llamacpp-095e).
Why it was slow (found by measuring, not guessing)
Your chat traffic to Ollama went through the fable-compat /v1/chat/completions endpoint, and that endpoint silently ignores keep_alive, options.num_ctx, and all other options (verified live against Ollama 0.31, and confirmed by open upstream issues #16814/#3645). Three compounding consequences:
- The model unloaded every 5 idle minutes (our 24h keep_alive never applied) — each message after a gap paid a full model load.
- Requests ran at the daemon-default 4096-token window — the ~10k-token harness payload was silently truncated (losing its instructions), and the shifting truncation window meant the prompt cache never matched, so every message re-prefilled from scratch. That's the "2 minutes per message".
- The goal planner and main turn sent different
num_ctx values, and Ollama reloads the entire model on any options change — two model reloads before your first token. agent-code sends one consistent request shape, which is why it never hit any of this.
What changed, with the measured effect
| Metric (Qwen3.5-0.8B, 20k-char system prompt, 4-core CPU VM) | Before | After |
|---|
| Turn 2 wall time | 10.1s (full re-prefill, prompt truncated) | 6.0s, prefix-cache hit, nothing truncated |
| First message after boot+idle warm | ~25–30s | 2.3s |
| Planner call between turns | full model reload | no reload |
| Model residency | 5 min | 24h |
| MTP decode (llama-server) | 41.5 tok/s | 53.9 tok/s |
The mechanics: Ollama chat is now native-first (/api/chat, with a silent /v1 fallback for fable-only servers); a sticky num_ctx ladder (1k→1M rungs, NAXIL_NUM_CTX to hard-pin) makes every request carry the same window so the runner never reload-flaps; the model preloads at TUI boot/model switch/exec start; and fresh sessions get an idle prefix warm so the big system-prompt prefill happens while you're still typing.
The rest of your asks
- VRAM/RAM overflow prevention, all sizes: a new memory-fit module estimates KV bytes/token from real model metadata (validated byte-exact against llama-server, hybrid-attention and KV-quant aware), probes VRAM (
nvidia-smi/rocm-smi) or RAM, and clamps the window to what actually fits — no more layer-offload crawl or swap. /doctor shows the math: Memory fit — weights 988MB · KV 48KB/token · RAM 8.6GB — fits ~137k tokens.
- MTP improved: the old
mtp/options.speculative fields were never real Ollama API (the daemon logs invalid option) — removed; Ollama speculates automatically when MTP weights exist, detection now catches qwen3.5/3.6 and -MTP GGUFs, llama.cpp gets a per-request draft hint, and /doctor reports MTP status.
- vLLM + llama.cpp:
provider: vllm and provider: llamacpp with correct defaults, prompt-caching behavior per backend, optional API keys, and friendly errors that print the exact launch command.
- Qwen3.5-0.8B testing: pulled
qwen3.5:0.8b on Ollama and the unsloth GGUFs (including the MTP one) on a real llama-server b9892 — the full exec CLI ran end-to-end green on both providers, and scripts/bench-local-latency.ts reproduces every number above.
Gates: 2,698 tests pass, typecheck clean across all 5 packages, offline smoke 11/11.