How to shape the chat model's answers with a decision model
This guide shows how to have a decision model read each question before the chat model does, and put next to the question the instructions that fit it — explain simply to a beginner, be brief with someone in a hurry, reassure someone who panics — with configuration only, no hook. It assumes you have a decider agent file with a decision: block (see How to write the questions of a decider). The finished files are in demos/decision-chat-new/; demos/decision-dnd-new/ is a second example (one choice question, minConfidence: 0, display: answers).
Steps
-
Give the decider the questions you want answered about each message, in its own file (
agent.decider.yaml):provider: llamacpp model: LiquidAI/d1-3B-GGUF:Q4_K_M decision: timeout: 60s questions: level: type: choice instructions: How familiar is the person with git? criteria: beginner: New to git, unsure of the basic words such as commit, branch or staging intermediate: Uses git every day, but not its less common commands expert: Knows git well and asks about a precise command or option hurry: type: noul instructions: The message contains a word asking for speed, such as quick, fast, asap or now. mood: type: score instructions: How worried is the person about their work? criteria: [calm, worried, panicking] -
In the chat agent's file, add a
decisionContextblock that names the decider and says, underthen:, what each answer adds — an option key for a choice,yesornofor a noul, a level name for a score:decisionContext: decider: agent.decider.yaml # relative to this file minConfidence: 0.3 then: level: beginner: Explain every command you give in plain words, avoid jargon. expert: Give the command alone, then one line at most. hurry: yes: Answer in three lines at most, the command first. mood: worried: Start with one short, calm sentence that reassures the person, then help. panicking: Start by saying that the work can very likely be recovered, then give the first safe command. -
Tell the chat model, in its
system, that the block exists and that it should follow it without mentioning it:system: | You are a git helper. Under some questions you find a block "[context added by a decider]": what a decision model read in the question about the person asking, and how to shape your answer for them. Follow it, and never mention the block. -
Start the agent. The banner ends with the decision-context column:
… | decision context: llamacpp/LiquidAI/d1-3B-GGUF:Q4_K_M, 3 question(s), 5 instruction(s)A
then:entry that names a question the decider does not ask, or an answer it cannot give, stops the start with the list of valid ones. -
Ask a question. Before the answer, a
🧭line shows every answer and how many instructions were added:> I did a git reset --hard and I think I lost my whole afternoon of work, I'm panicking, please help 🧭 level: beginner (0.05 < 0.30) · hurry: no (0.65) · mood: panicking (0.98) → 1 instruction
Variants
- See what the model reads: add
display: true. The injected text is shown before the answer. See the decider's whole answer (every probability):display: answers. Keep a record of every decider call: run withAGENT_TRACE=true—.mm/traces/then holds a request and a response file per call, named…-<acp.name>-decision-context-<n>…. - Instructions only, without the answer lines:
answers: none. All the answers, with their probabilities:answers: json(not filtered byminConfidence). - Too many answers left out: lower
minConfidence. A choice's confidence is lower than the probability of the option chosen (expertat 0.38 for a probability of 0.59 in the demo); start from the🧭lines of a few real questions. - A decider on the same llama-server: with
llamacpp.autoStart: true, mm lists the decider's model in the router's preset and loads it at start-up. A server you start yourself must list both models. - A decider that loads slowly: past
timeout(by default the decider'sdecision.timeout), the turn shows🧭 decision context skipped: …and the question goes on alone. - Act on the answer instead — stop the turn, answer without the chat model: a
preGenerationhook does that; seedemos/decision-chat/and How to ask a decision model.
See also
- Every
decisionContextkey, notice and error: Configuration reference - How an answer selects an instruction, and why a score selects its likeliest level: Decision models
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|