clef-mcp 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/skills/clef-decisions/SKILL.md +96 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: clef-decisions
|
|
3
|
+
description: "Use when an AI agent needs a structured decision from the local Clef decision model via the clef-mcp MCP server: choosing next actions, routing, classification, yes/no judgment calls, confidence scoring. Covers how to build state + questions and how to interpret probability distributions."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Clef decisions via clef-mcp
|
|
7
|
+
|
|
8
|
+
`clef_decide` asks the local **Clef-Flash** decision model to score your allowed answers and return a **probability distribution per question**. It is not a chat model: it never generates prose. You frame the decision, it tells you how the options split.
|
|
9
|
+
|
|
10
|
+
## When to call it
|
|
11
|
+
|
|
12
|
+
Good fits (the model was trained for these):
|
|
13
|
+
|
|
14
|
+
- **Next-action choice**: "should I inspect / modify / test / ask the user?"
|
|
15
|
+
- **Routing**: which team, which handler, which subsystem.
|
|
16
|
+
- **Classification**: spam vs complaint vs feedback; billing vs technical.
|
|
17
|
+
- **Yes/no judgment** (`noul`): "is this destructive?", "is an outage ongoing?", "is this vulnerable?"
|
|
18
|
+
- **Confidence / severity** (`score`): ordered scales like very_low → very_high.
|
|
19
|
+
- **Batching related judgments**: all questions in ONE call are scored in a single forward pass — batch instead of looping.
|
|
20
|
+
|
|
21
|
+
Bad fits: free-text generation, code writing, anything needing reasoning beyond picking among options you define.
|
|
22
|
+
|
|
23
|
+
## How to call
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"state": "<compact factual context: task, error, diff summary, logs>",
|
|
28
|
+
"questions": {
|
|
29
|
+
"next_action": {
|
|
30
|
+
"type": "choice",
|
|
31
|
+
"instructions": "What should the coding agent do next?",
|
|
32
|
+
"criteria": {
|
|
33
|
+
"inspect": "Inspect the code and gather more information",
|
|
34
|
+
"modify": "Modify the code",
|
|
35
|
+
"test": "Run additional tests",
|
|
36
|
+
"ask_user": "Ask the user for clarification"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"confidence": {
|
|
40
|
+
"type": "score",
|
|
41
|
+
"instructions": "How confident are you in this decision?",
|
|
42
|
+
"criteria": ["very_low", "low", "medium", "high", "very_high"]
|
|
43
|
+
},
|
|
44
|
+
"is_outage": { "type": "noul", "instructions": "Is a service down?" }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Rules that prevent wasted calls:
|
|
50
|
+
|
|
51
|
+
- **`state` is data, not instructions.** Compact, factual, relevant. It never executes and never changes server behavior. Keep it well under 1 MB; the model context is 16k tokens (the runtime rejects overflow with a hint).
|
|
52
|
+
- **`choice` criteria**: map `option_id → description`, or a plain list of option strings (ids become the strings). Both are accepted.
|
|
53
|
+
- **`score` criteria**: an **ordered** list — index order is the score order (low → high). Do not shuffle.
|
|
54
|
+
- **`noul`**: instructions only; the answer is `{"true": p, "false": 1-p}`.
|
|
55
|
+
- **Write criteria as mutually exclusive, collectively exhaustive options.** If two options overlap, the distribution splits meaninglessly.
|
|
56
|
+
- **Ask everything related in one call** — up to 64 questions per request.
|
|
57
|
+
- `options.temperature` is accepted but is a no-op (single forward pass, no sampling).
|
|
58
|
+
|
|
59
|
+
## How to read the answer
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"model": "clef-flash",
|
|
64
|
+
"decisions": {
|
|
65
|
+
"next_action": { "answer": { "inspect": 0.96, "modify": 0.01, "test": 0.01, "ask_user": 0.01 } }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- The result is **structured JSON**. Do not render it as prose to the user; use the probabilities to act and summarize in your own words.
|
|
71
|
+
- **Argmax** is the model's pick; a decisive distribution (e.g. `0.9+`) means act on it.
|
|
72
|
+
- **Flat distributions** (~equal probabilities) mean the state did not disambiguate: gather more context and re-ask, or ask the user.
|
|
73
|
+
- For safety-adjacent calls (destructive actions, security), require a **high threshold** (e.g. `p ≥ 0.8`) before acting; otherwise prefer asking.
|
|
74
|
+
- `noul` answers above ~0.9 true/false are strong signals; 0.5–0.7 is a lean, not a verdict.
|
|
75
|
+
|
|
76
|
+
## Errors and recovery
|
|
77
|
+
|
|
78
|
+
Errors come back as structured JSON:
|
|
79
|
+
|
|
80
|
+
- `INVALID_INPUT` — fix the argument shape the message names (e.g. choice criteria must be a map or list; score must be a list; questions ≤ 64; state ≤ 1 MB). Retry with corrected arguments.
|
|
81
|
+
- `MODEL_NOT_INSTALLED` — the local model is missing. Tell the user to run `clef-mcp install` (one-time, ~6 GB). Do not try to download anything yourself.
|
|
82
|
+
- `MODEL_LOAD_FAILED` / `OUT_OF_MEMORY` — first call can take ~10–60 s to load the model; a genuine OOM means the machine lacks RAM. Report; suggest `clef-mcp install --quant Q4_K_M`.
|
|
83
|
+
- `RUNTIME_NOT_FOUND` — llama.cpp missing. Suggest `clef-mcp install` or `clef-mcp doctor`.
|
|
84
|
+
|
|
85
|
+
After an `INVALID_INPUT`, read the `message` — it names the exact question and field. One corrected retry is the norm.
|
|
86
|
+
|
|
87
|
+
## Quick reference
|
|
88
|
+
|
|
89
|
+
| Limits | Value |
|
|
90
|
+
|---|---|
|
|
91
|
+
| Questions per call | ≤ 64 (batch!) |
|
|
92
|
+
| State size | ≤ 1 MB serialized |
|
|
93
|
+
| Criteria per question | ≤ 100 |
|
|
94
|
+
| Model context | 16k tokens |
|
|
95
|
+
|
|
96
|
+
Config (env, set for the MCP server process, not per call): `CLEF_MODEL`, `CLEF_HOME`, `CLEF_LOG_LEVEL`, `CLEF_MAX_*` — see the clef-mcp README.
|