bots-garden/mini-mepublic Fork
⑂ fc3d5e4
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

♻️ Quality: skills/create-agent/model_facts.py without smells (3 → 0)

- tool_format as an ordered TOOL_FORMATS table (same tests, same order)
- notes as reasoning_notes (+ effort_note), tool_notes and setup_notes,
  in the same order
- template_facts.py: thinking and tool_format, imported by
  model_facts.py (run by its path, so its folder is on sys.path)

Checked: facts() and text_report() byte-identical old vs new on 18
synthetic /api/show answers (the 7 tool-call formats, reasoning
switches and effort values, with and without architecture facts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agent committed 2026-11-28T13:01:59+01:00 Browse files
fc3d5e4 parent: e6108b0
modified skills/create-agent/model_facts.py +29 -47
@@ -22,6 +22,8 @@ import re
2222 import sys
2323 import urllib.request
2424
25+from template_facts import thinking, tool_format
26+
2527 BASES = ["http://127.0.0.1:17434", "http://host.docker.internal:17434"]
2628
2729
@@ -42,46 +44,6 @@ def find_base(explicit):
4244 sys.exit("llmman does not answer on " + ", ".join([explicit] if explicit else BASES) + " — start it: llmman serve")
4345
4446
45-def thinking(template):
46- """How the template switches reasoning, and what it does by default."""
47- t = template
48- out = {"variable": None, "default": None, "effort": None, "effort_values": [], "preserve_thinking": "preserve_thinking" in t}
49- if "enable_thinking" in t:
50- out["variable"] = "enable_thinking"
51- if re.search(r"enable_thinking\s*\|\s*default\(\s*false", t) or re.search(r"enable_thinking is defined and enable_thinking is true", t):
52- out["default"] = "off"
53- elif re.search(r"enable_thinking is defined and enable_thinking is false", t) or re.search(r"enable_thinking is undefined or enable_thinking is true", t):
54- out["default"] = "on"
55- if "reasoning_effort" in t:
56- out["effort"] = "reasoning_effort"
57- m = re.search(r"reasoning_effort\|default\(['\"](\w+)['\"]\)|set reasoning_effort = ['\"](\w+)['\"]", t)
58- if m:
59- out["effort_default"] = m.group(1) or m.group(2)
60- out["effort_values"] = sorted({v for v in re.findall(r"['\"](low|medium|high|xhigh|minimal|none)['\"]", t)})
61- if out["variable"] is None:
62- out["default"] = "always on (graded by reasoning_effort)"
63- if out["variable"] is None and out["effort"] is None:
64- out["default"] = "reasons, no switch" if ("<think>" in t or "thought" in t) else "no reasoning"
65- return out
66-
67-
68-def tool_format(template):
69- t = template
70- if "<function=" in t:
71- return "xml", "Qwen3-Coder XML: <tool_call><function=name><parameter=key>value</parameter>…"
72- if "<|tool_call>call:" in t:
73- return "gemma", "Gemma 4 DSL: <|tool_call>call:name{key:<|\"|>value<|\"|>}<tool_call|>"
74- if "to=functions." in t or "to=\" }}" in t or "functions." in t and "<|channel|>commentary" in t:
75- return "harmony", "harmony: assistant to=functions.name <|channel|>commentary json<|message|>{…}<|call|>"
76- if "<tool_call>" in t and '"name"' in t:
77- return "json", "Hermes JSON: <tool_call>{\"name\": …, \"arguments\": {…}}</tool_call>"
78- if "[TOOL_CALLS]" in t:
79- return "mistral", "Mistral: [TOOL_CALLS]name[ARGS]{…}"
80- if "tools" in t:
81- return "other", "the template handles tools; read it with --template"
82- return "none", "the template has no tool support"
83-
84-
8547 def facts(base, model):
8648 show = call(base, "/api/show", {"model": model}, timeout=30)
8749 tags = call(base, "/api/tags").get("models", [])
@@ -122,25 +84,45 @@ def facts(base, model):
12284
12385 def notes(f):
12486 """What the facts mean for an mm configuration — the lessons measured in this repository."""
87+ fmt = f["tool_calls"]["format"]
88+ return reasoning_notes(f["thinking"]) + tool_notes(fmt) + setup_notes(f, fmt)
89+
90+
91+def reasoning_notes(th):
92+ """The notes on the reasoning switches: enable_thinking, reasoning_effort, always on."""
12593 n = []
126- th, fmt = f["thinking"], f["tool_calls"]["format"]
12794 if th["variable"] == "enable_thinking":
12895 n.append(f"Reasoning: set sampling.chat_template_kwargs.enable_thinking explicitly (template default: {th['default']}).")
12996 if th["effort"]:
130- values = th["effort_values"]
131- if len(values) > 1:
132- n.append(f"Reasoning effort: chat_template_kwargs.reasoning_effort, one of {', '.join(values)}; a value the template does not know may make every request fail (Qwen3.8's raises).")
133- else:
134- n.append("Reasoning effort: chat_template_kwargs.reasoning_effort — the template names only its default"
135- + (f" ({values[0]})" if values else "") + "; take the other values from the model card (gpt-oss: low, medium, high).")
97+ n.append(effort_note(th["effort_values"]))
13698 if th["default"] and "always" in str(th["default"]):
13799 n.append("The model always reasons: give max_tokens room for the reasoning plus a whole tool call (16384+).")
138100 if th["default"] in ("on",) or th["effort"]:
139101 n.append("With reasoning on, never use temperature 0.0 (thinking models loop); showThinking: true helps while tuning.")
102+ return n
103+
104+
105+def effort_note(values):
106+ """The reasoning_effort note: the values the template knows, or only its default."""
107+ if len(values) > 1:
108+ return f"Reasoning effort: chat_template_kwargs.reasoning_effort, one of {', '.join(values)}; a value the template does not know may make every request fail (Qwen3.8's raises)."
109+ return ("Reasoning effort: chat_template_kwargs.reasoning_effort — the template names only its default"
110+ + (f" ({values[0]})" if values else "") + "; take the other values from the model card (gpt-oss: low, medium, high).")
111+
112+
113+def tool_notes(fmt):
114+ """The notes on the tool-call format."""
115+ n = []
140116 if fmt == "xml":
141117 n.append("XML tool calls: llama.cpp builds a grammar from each tool schema and imposes NESTED object properties in alphabetical order — keep a custom/MCP tool's nested objects without `properties` (describe them in words) or the model loses fields.")
142118 if fmt in ("json", "gemma", "harmony", "xml"):
143119 n.append("parallel_tool_calls: false — one call per reply; small models run tests before the edit lands otherwise.")
120+ return n
121+
122+
123+def setup_notes(f, fmt):
124+ """The notes on sampling, the window, the identity line and the system message."""
125+ n = []
144126 if not f["sampling_in_gguf"]:
145127 n.append("No sampling in the GGUF: use the model author's published recommendation.")
146128 ctx = f["architecture"]["context_length"]
@@ -22,6 +22,8 @@ import re
22 import sys22 import sys
23 import urllib.request23 import urllib.request
24 24
25+from template_facts import thinking, tool_format
26+
25 BASES = ["http://127.0.0.1:17434", "http://host.docker.internal:17434"]27 BASES = ["http://127.0.0.1:17434", "http://host.docker.internal:17434"]
26 28
27 29
@@ -42,46 +44,6 @@ def find_base(explicit):
42 sys.exit("llmman does not answer on " + ", ".join([explicit] if explicit else BASES) + " — start it: llmman serve")44 sys.exit("llmman does not answer on " + ", ".join([explicit] if explicit else BASES) + " — start it: llmman serve")
43 45
44 46
45-def thinking(template):
46- """How the template switches reasoning, and what it does by default."""
47- t = template
48- out = {"variable": None, "default": None, "effort": None, "effort_values": [], "preserve_thinking": "preserve_thinking" in t}
49- if "enable_thinking" in t:
50- out["variable"] = "enable_thinking"
51- if re.search(r"enable_thinking\s*\|\s*default\(\s*false", t) or re.search(r"enable_thinking is defined and enable_thinking is true", t):
52- out["default"] = "off"
53- elif re.search(r"enable_thinking is defined and enable_thinking is false", t) or re.search(r"enable_thinking is undefined or enable_thinking is true", t):
54- out["default"] = "on"
55- if "reasoning_effort" in t:
56- out["effort"] = "reasoning_effort"
57- m = re.search(r"reasoning_effort\|default\(['\"](\w+)['\"]\)|set reasoning_effort = ['\"](\w+)['\"]", t)
58- if m:
59- out["effort_default"] = m.group(1) or m.group(2)
60- out["effort_values"] = sorted({v for v in re.findall(r"['\"](low|medium|high|xhigh|minimal|none)['\"]", t)})
61- if out["variable"] is None:
62- out["default"] = "always on (graded by reasoning_effort)"
63- if out["variable"] is None and out["effort"] is None:
64- out["default"] = "reasons, no switch" if ("<think>" in t or "thought" in t) else "no reasoning"
65- return out
66-
67-
68-def tool_format(template):
69- t = template
70- if "<function=" in t:
71- return "xml", "Qwen3-Coder XML: <tool_call><function=name><parameter=key>value</parameter>…"
72- if "<|tool_call>call:" in t:
73- return "gemma", "Gemma 4 DSL: <|tool_call>call:name{key:<|\"|>value<|\"|>}<tool_call|>"
74- if "to=functions." in t or "to=\" }}" in t or "functions." in t and "<|channel|>commentary" in t:
75- return "harmony", "harmony: assistant to=functions.name <|channel|>commentary json<|message|>{…}<|call|>"
76- if "<tool_call>" in t and '"name"' in t:
77- return "json", "Hermes JSON: <tool_call>{\"name\": …, \"arguments\": {…}}</tool_call>"
78- if "[TOOL_CALLS]" in t:
79- return "mistral", "Mistral: [TOOL_CALLS]name[ARGS]{…}"
80- if "tools" in t:
81- return "other", "the template handles tools; read it with --template"
82- return "none", "the template has no tool support"
83-
84-
85 def facts(base, model):47 def facts(base, model):
86 show = call(base, "/api/show", {"model": model}, timeout=30)48 show = call(base, "/api/show", {"model": model}, timeout=30)
87 tags = call(base, "/api/tags").get("models", [])49 tags = call(base, "/api/tags").get("models", [])
@@ -122,25 +84,45 @@ def facts(base, model):
122 84
123 def notes(f):85 def notes(f):
124 """What the facts mean for an mm configuration — the lessons measured in this repository."""86 """What the facts mean for an mm configuration — the lessons measured in this repository."""
87+ fmt = f["tool_calls"]["format"]
88+ return reasoning_notes(f["thinking"]) + tool_notes(fmt) + setup_notes(f, fmt)
89+
90+
91+def reasoning_notes(th):
92+ """The notes on the reasoning switches: enable_thinking, reasoning_effort, always on."""
125 n = []93 n = []
126- th, fmt = f["thinking"], f["tool_calls"]["format"]
127 if th["variable"] == "enable_thinking":94 if th["variable"] == "enable_thinking":
128 n.append(f"Reasoning: set sampling.chat_template_kwargs.enable_thinking explicitly (template default: {th['default']}).")95 n.append(f"Reasoning: set sampling.chat_template_kwargs.enable_thinking explicitly (template default: {th['default']}).")
129 if th["effort"]:96 if th["effort"]:
130- values = th["effort_values"]97+ n.append(effort_note(th["effort_values"]))
131- if len(values) > 1:
132- n.append(f"Reasoning effort: chat_template_kwargs.reasoning_effort, one of {', '.join(values)}; a value the template does not know may make every request fail (Qwen3.8's raises).")
133- else:
134- n.append("Reasoning effort: chat_template_kwargs.reasoning_effort — the template names only its default"
135- + (f" ({values[0]})" if values else "") + "; take the other values from the model card (gpt-oss: low, medium, high).")
136 if th["default"] and "always" in str(th["default"]):98 if th["default"] and "always" in str(th["default"]):
137 n.append("The model always reasons: give max_tokens room for the reasoning plus a whole tool call (16384+).")99 n.append("The model always reasons: give max_tokens room for the reasoning plus a whole tool call (16384+).")
138 if th["default"] in ("on",) or th["effort"]:100 if th["default"] in ("on",) or th["effort"]:
139 n.append("With reasoning on, never use temperature 0.0 (thinking models loop); showThinking: true helps while tuning.")101 n.append("With reasoning on, never use temperature 0.0 (thinking models loop); showThinking: true helps while tuning.")
102+ return n
103+
104+
105+def effort_note(values):
106+ """The reasoning_effort note: the values the template knows, or only its default."""
107+ if len(values) > 1:
108+ return f"Reasoning effort: chat_template_kwargs.reasoning_effort, one of {', '.join(values)}; a value the template does not know may make every request fail (Qwen3.8's raises)."
109+ return ("Reasoning effort: chat_template_kwargs.reasoning_effort — the template names only its default"
110+ + (f" ({values[0]})" if values else "") + "; take the other values from the model card (gpt-oss: low, medium, high).")
111+
112+
113+def tool_notes(fmt):
114+ """The notes on the tool-call format."""
115+ n = []
140 if fmt == "xml":116 if fmt == "xml":
141 n.append("XML tool calls: llama.cpp builds a grammar from each tool schema and imposes NESTED object properties in alphabetical order — keep a custom/MCP tool's nested objects without `properties` (describe them in words) or the model loses fields.")117 n.append("XML tool calls: llama.cpp builds a grammar from each tool schema and imposes NESTED object properties in alphabetical order — keep a custom/MCP tool's nested objects without `properties` (describe them in words) or the model loses fields.")
142 if fmt in ("json", "gemma", "harmony", "xml"):118 if fmt in ("json", "gemma", "harmony", "xml"):
143 n.append("parallel_tool_calls: false — one call per reply; small models run tests before the edit lands otherwise.")119 n.append("parallel_tool_calls: false — one call per reply; small models run tests before the edit lands otherwise.")
120+ return n
121+
122+
123+def setup_notes(f, fmt):
124+ """The notes on sampling, the window, the identity line and the system message."""
125+ n = []
144 if not f["sampling_in_gguf"]:126 if not f["sampling_in_gguf"]:
145 n.append("No sampling in the GGUF: use the model author's published recommendation.")127 n.append("No sampling in the GGUF: use the model author's published recommendation.")
146 ctx = f["architecture"]["context_length"]128 ctx = f["architecture"]["context_length"]
added skills/create-agent/template_facts.py +52 -0
new file mode 100644
@@ -0,0 +1,52 @@
1+"""What a chat template says about a model: its reasoning switches and how it writes a
2+tool call. Read by model_facts.py, from the template llmman's /api/show returns."""
3+
4+import re
5+
6+
7+def thinking(template):
8+ """How the template switches reasoning, and what it does by default."""
9+ t = template
10+ out = {"variable": None, "default": None, "effort": None, "effort_values": [], "preserve_thinking": "preserve_thinking" in t}
11+ if "enable_thinking" in t:
12+ out["variable"] = "enable_thinking"
13+ if re.search(r"enable_thinking\s*\|\s*default\(\s*false", t) or re.search(r"enable_thinking is defined and enable_thinking is true", t):
14+ out["default"] = "off"
15+ elif re.search(r"enable_thinking is defined and enable_thinking is false", t) or re.search(r"enable_thinking is undefined or enable_thinking is true", t):
16+ out["default"] = "on"
17+ if "reasoning_effort" in t:
18+ out["effort"] = "reasoning_effort"
19+ m = re.search(r"reasoning_effort\|default\(['\"](\w+)['\"]\)|set reasoning_effort = ['\"](\w+)['\"]", t)
20+ if m:
21+ out["effort_default"] = m.group(1) or m.group(2)
22+ out["effort_values"] = sorted({v for v in re.findall(r"['\"](low|medium|high|xhigh|minimal|none)['\"]", t)})
23+ if out["variable"] is None:
24+ out["default"] = "always on (graded by reasoning_effort)"
25+ if out["variable"] is None and out["effort"] is None:
26+ out["default"] = "reasons, no switch" if ("<think>" in t or "thought" in t) else "no reasoning"
27+ return out
28+
29+
30+# How a chat template writes a tool call, checked in this order: the first
31+# test that holds names the format.
32+TOOL_FORMATS = [
33+ (lambda t: "<function=" in t,
34+ ("xml", "Qwen3-Coder XML: <tool_call><function=name><parameter=key>value</parameter>…")),
35+ (lambda t: "<|tool_call>call:" in t,
36+ ("gemma", "Gemma 4 DSL: <|tool_call>call:name{key:<|\"|>value<|\"|>}<tool_call|>")),
37+ (lambda t: "to=functions." in t or "to=\" }}" in t or "functions." in t and "<|channel|>commentary" in t,
38+ ("harmony", "harmony: assistant to=functions.name <|channel|>commentary json<|message|>{…}<|call|>")),
39+ (lambda t: "<tool_call>" in t and '"name"' in t,
40+ ("json", "Hermes JSON: <tool_call>{\"name\": …, \"arguments\": {…}}</tool_call>")),
41+ (lambda t: "[TOOL_CALLS]" in t,
42+ ("mistral", "Mistral: [TOOL_CALLS]name[ARGS]{…}")),
43+ (lambda t: "tools" in t,
44+ ("other", "the template handles tools; read it with --template")),
45+]
46+
47+
48+def tool_format(template):
49+ for matches, found in TOOL_FORMATS:
50+ if matches(template):
51+ return found
52+ return "none", "the template has no tool support"
new file mode 100644
@@ -0,0 +1,52 @@
1+"""What a chat template says about a model: its reasoning switches and how it writes a
2+tool call. Read by model_facts.py, from the template llmman's /api/show returns."""
3+
4+import re
5+
6+
7+def thinking(template):
8+ """How the template switches reasoning, and what it does by default."""
9+ t = template
10+ out = {"variable": None, "default": None, "effort": None, "effort_values": [], "preserve_thinking": "preserve_thinking" in t}
11+ if "enable_thinking" in t:
12+ out["variable"] = "enable_thinking"
13+ if re.search(r"enable_thinking\s*\|\s*default\(\s*false", t) or re.search(r"enable_thinking is defined and enable_thinking is true", t):
14+ out["default"] = "off"
15+ elif re.search(r"enable_thinking is defined and enable_thinking is false", t) or re.search(r"enable_thinking is undefined or enable_thinking is true", t):
16+ out["default"] = "on"
17+ if "reasoning_effort" in t:
18+ out["effort"] = "reasoning_effort"
19+ m = re.search(r"reasoning_effort\|default\(['\"](\w+)['\"]\)|set reasoning_effort = ['\"](\w+)['\"]", t)
20+ if m:
21+ out["effort_default"] = m.group(1) or m.group(2)
22+ out["effort_values"] = sorted({v for v in re.findall(r"['\"](low|medium|high|xhigh|minimal|none)['\"]", t)})
23+ if out["variable"] is None:
24+ out["default"] = "always on (graded by reasoning_effort)"
25+ if out["variable"] is None and out["effort"] is None:
26+ out["default"] = "reasons, no switch" if ("<think>" in t or "thought" in t) else "no reasoning"
27+ return out
28+
29+
30+# How a chat template writes a tool call, checked in this order: the first
31+# test that holds names the format.
32+TOOL_FORMATS = [
33+ (lambda t: "<function=" in t,
34+ ("xml", "Qwen3-Coder XML: <tool_call><function=name><parameter=key>value</parameter>…")),
35+ (lambda t: "<|tool_call>call:" in t,
36+ ("gemma", "Gemma 4 DSL: <|tool_call>call:name{key:<|\"|>value<|\"|>}<tool_call|>")),
37+ (lambda t: "to=functions." in t or "to=\" }}" in t or "functions." in t and "<|channel|>commentary" in t,
38+ ("harmony", "harmony: assistant to=functions.name <|channel|>commentary json<|message|>{…}<|call|>")),
39+ (lambda t: "<tool_call>" in t and '"name"' in t,
40+ ("json", "Hermes JSON: <tool_call>{\"name\": …, \"arguments\": {…}}</tool_call>")),
41+ (lambda t: "[TOOL_CALLS]" in t,
42+ ("mistral", "Mistral: [TOOL_CALLS]name[ARGS]{…}")),
43+ (lambda t: "tools" in t,
44+ ("other", "the template handles tools; read it with --template")),
45+]
46+
47+
48+def tool_format(template):
49+ for matches, found in TOOL_FORMATS:
50+ if matches(template):
51+ return found
52+ return "none", "the template has no tool support"