Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

coli chat: MiMo starts with thinking off

JustVuggbe25e9a7511d
diff --git a/c/coli b/c/coli
index cee8fbed..a1cb4ead 100755
--- a/c/coli
+++ b/c/coli
@@ -1726,6 +1726,24 @@ def chat_brio(a, base, model_id, msgs, question, options, w):
print(f" {C.dim}{time.time()-t0:.2f}s · {usage.get('read_tokens',0)} tokens read · "
f"{usage.get('completion_tokens',0)} generated{C.r}\n")
+# Families whose template thinks by default but that coli chat starts with thinking
+# OFF. On a model that streams its experts from disk at about 1 tok/s, the default
+# reasoning of MiMo-V2.6's template is minutes of tokens before the first word of the
+# answer, and a terminal that shows a spinner for that long looks hung. The API and
+# the web keep the template's default; here `--think` turns it on.
+CHAT_THINK_OFF = {"mimo"}
+
+def server_arch(base, api_key=None, timeout=1.5):
+ """The family a coli serve runs, from /health; None when it does not say."""
+ import urllib.request
+ try:
+ req=urllib.request.Request(base.rstrip("/")+"/health")
+ if api_key: req.add_header("Authorization", f"Bearer {api_key}")
+ with urllib.request.urlopen(req, timeout=timeout) as r:
+ return json.loads(r.read().decode("utf-8","replace")).get("arch")
+ except Exception:
+ return None
+
def chat_attached(a, base, model_id):
"""The chat REPL over HTTP against a running `coli serve`.
@@ -1741,6 +1759,9 @@ def chat_attached(a, base, model_id):
print(f" {C.dim}type and press Enter · Ctrl-C stops the answer · :reset starts a new conversation · :q exits{C.r}")
print(f" {C.dim}/ for commands · TAB completes · /brio puts the SAME model in brio mode{C.r}\n")
install_chat_completer()
+ arch=server_arch(base, getattr(a,"api_key",None))
+ if arch in CHAT_THINK_OFF and getattr(a,"think",None) is None:
+ print(f" {C.dim}thinking is off here (--think turns it on){C.r}\n")
msgs=[]
brio_options=[] # non vuoto = modalita brio accesa
w=term_w()-4
@@ -1808,6 +1829,8 @@ def chat_attached(a, base, model_id):
"stream_options":{"include_usage":True}} # exact completion_tokens in the last chunk
if getattr(a,"effort",None): request["reasoning_effort"]=a.effort
if getattr(a,"think",None) is not None: request["enable_thinking"]=a.think
+ elif arch in CHAT_THINK_OFF:
+ request["enable_thinking"]=False # --think turns it back on
body=json.dumps(request).encode()
req=urllib.request.Request(base.rstrip("/")+"/v1/chat/completions", data=body,
headers={"Content-Type":"application/json"})
diff --git a/c/openai_server.py b/c/openai_server.py
index 9b74cd47..ed4a761a 100644
--- a/c/openai_server.py
+++ b/c/openai_server.py
@@ -5726,6 +5726,7 @@ class APIHandler(BaseHTTPRequestHandler):
# past a bare 200 to an unauthenticated probe. (#SEC-8)
payload = {"status": "ok"}
if self._is_authed():
+ payload["arch"] = ARCH # which family answers: coli chat reads it
payload["scheduler"] = self.server.scheduler.snapshot()
payload["kv_slots"] = self.server.kv_slots
payload["continue_assistant"] = os.environ.get("COLI_CONTINUE_ASSISTANT", "1") != "0" and ARCH in CONTINUATION_FAMILIES
diff --git a/c/tests/test_chat_thinking.py b/c/tests/test_chat_thinking.py
index e642f2c2..f14d2110 100644
--- a/c/tests/test_chat_thinking.py
+++ b/c/tests/test_chat_thinking.py
@@ -33,6 +33,8 @@ from types import SimpleNamespace
CLI = Path(__file__).resolve().parent.parent / "coli"
SEEN_MESSAGES = []
+SEEN_BODIES = []
+SERVER_ARCH = {"value": None} # what the fake /health reports as the family
# The child is spawned with fork+EXEC, never bare fork: this test process is
# multi-threaded (the fake SSE server runs in a thread), and pty.fork() from a
@@ -50,7 +52,8 @@ try:
loader.exec_module(module)
except SystemExit:
pass
-module.chat_attached(SimpleNamespace(ngen=32, api_key=None),
+think = {"1": True, "0": False}.get(os.environ.get("COLI_TEST_THINK", ""))
+module.chat_attached(SimpleNamespace(ngen=32, api_key=None, think=think),
os.environ["COLI_TEST_BASE"], "fake-model")
"""
@@ -59,9 +62,21 @@ class FakeSSE(BaseHTTPRequestHandler):
def log_message(self, *args):
pass
+ def do_GET(self):
+ payload = {"status": "ok"}
+ if SERVER_ARCH["value"]:
+ payload["arch"] = SERVER_ARCH["value"]
+ data = json.dumps(payload).encode()
+ self.send_response(200)
+ self.send_header("Content-Type", "application/json")
+ self.send_header("Content-Length", str(len(data)))
+ self.end_headers()
+ self.wfile.write(data)
+
def do_POST(self):
body = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
SEEN_MESSAGES.append(body["messages"])
+ SEEN_BODIES.append(body)
self.send_response(200)
self.send_header("Content-Type", "text/event-stream")
self.end_headers()
@@ -156,6 +171,27 @@ class ChatThinkingTest(unittest.TestCase):
def setUp(self):
SEEN_MESSAGES.clear()
+ SEEN_BODIES.clear()
+ SERVER_ARCH["value"] = None
+
+ def test_mimo_starts_with_thinking_off(self):
+ """MiMo's template thinks by default; at ~1 tok/s that is minutes of
+ reasoning before the answer, so coli chat asks for it off unless --think."""
+ SERVER_ARCH["value"] = "mimo"
+ out = run_chat(self.base, {"COLI_SHOW_THINK": "1"})
+ self.assertIn("thinking is off here", out)
+ self.assertTrue(SEEN_BODIES)
+ self.assertIs(SEEN_BODIES[0].get("enable_thinking"), False)
+
+ def test_mimo_think_flag_turns_it_on(self):
+ SERVER_ARCH["value"] = "mimo"
+ run_chat(self.base, {"COLI_SHOW_THINK": "1", "COLI_TEST_THINK": "1"})
+ self.assertIs(SEEN_BODIES[0].get("enable_thinking"), True)
+
+ def test_other_families_keep_the_server_default(self):
+ SERVER_ARCH["value"] = "glm"
+ run_chat(self.base, {"COLI_SHOW_THINK": "1"})
+ self.assertNotIn("enable_thinking", SEEN_BODIES[0])
def test_thinking_is_shown_by_default(self):
out = run_chat(self.base, {"COLI_SHOW_THINK": "1"})
diff --git a/c/tests/test_openai_server.py b/c/tests/test_openai_server.py
index 72eaf450..a2993542 100644
--- a/c/tests/test_openai_server.py
+++ b/c/tests/test_openai_server.py
@@ -2786,6 +2786,8 @@ class HTTPTest(unittest.TestCase):
with self.request("/health") as response:
health = json.load(response)
scheduler = health["scheduler"]
+ # the family, for coli chat's per-family defaults (authed probes only)
+ self.assertEqual(health["arch"], openai_server.ARCH)
self.assertEqual(scheduler["max_queue"], 8)
self.assertIn("queued", scheduler)
self.assertEqual(health["kv_slots"], 2)
diff --git a/docs/mimo.md b/docs/mimo.md
index 0a6bf1b6..cb82fa5f 100644
--- a/docs/mimo.md
+++ b/docs/mimo.md
@@ -77,9 +77,12 @@ real template by `tests/test_mimo_chat_template.py`): ChatML with no newline aft
`<|im_end|>`, every assistant turn carrying its `<think>` block, tools in their own
system turn, calls written inline as
`<tool_call><function=NAME><parameter=KEY>VALUE</parameter></function></tool_call>`,
-tool results as a `tool` turn. Thinking is on unless the request turns it off
-(`enable_thinking: false`, or `reasoning_effort: "none"`), as in the template; with
-thinking on the cue ends in `<think>`, the token the model writes first.
+tool results as a `tool` turn. Through the API, thinking is on unless the request
+turns it off (`enable_thinking: false`, or `reasoning_effort: "none"`), as in the
+template; with thinking on the cue ends in `<think>`, the token the model writes
+first. `coli chat` starts with thinking off, because at about 1 tok/s the template's
+default reasoning is minutes of tokens before the answer; `coli chat --think` turns it
+on (the web has its own reasoning toggle).
## Correctness