Per-routing-class system_prompts (constrain small-model output) #86
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivation
A 7B local model (qwen-coder-7b-snappy-8k etc.) has a much narrower probability distribution than cloud models. It follows precise structured instructions reliably; it drifts on natural-language tasks. Today aish routes via class (
code/reasoning/default) but the SAME system prompt goes to all routes — the small model gets no help compensating for its weaker output-format adherence.The pattern that fixes this: per-class system prompt overlays that EXPLICITLY constrain the small model.
Proposal
Extend
cfg.routingwith asystem_promptsmap keyed by class:When
router.classify_modelselects a class with asystem_prompts[class]entry, broker.lua substitutes/extends the system prompt for THAT request. The active model's regular system_prompt stays the default fallback.Where it lands
router.luaalready exposesclassify_model(text, cfg)→ (model, class). Return the class so the caller knows which overlay applies.broker.luareadsopts.system_prompt_override(set by repl.lua based oncfg.routing.system_prompts[class]) and replaces the system message before send.repl.luawires it at the call_broker invocation in ask_ai.safety.norris_step) can opt out (planner has its own system prompt; mixing is confusing).Estimate
~1 hour (small surface; mostly config schema + 5-line wiring change). User report estimates the ROI as "high" — reduces small-model output drift substantially.
Source
Architecture analysis (2026-05-16) summarizing why small local models underperform on aish-style tasks and which leverage points compensate.