Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
fix: scope implicit stops to GLM chat
bill74326b9d9182
diff --git a/c/openai_server.py b/c/openai_server.pyindex fa336fcd..0080bd73 100644--- a/c/openai_server.py+++ b/c/openai_server.py@@ -862,10 +862,11 @@ def stop_policy(body, chat):if not isinstance(ignore_leading, bool):raise APIError(400, "`x_colibri_ignore_leading_stop` must be a boolean.","x_colibri_ignore_leading_stop", "invalid_value")- if chat and not sequences:- # The chat template owns these role boundaries, so generic OpenAI- # clients should not need model-specific stop knowledge. Treat an- # occasional leading marker patiently; client-provided stops remain+ if chat and ARCH == "glm" and not sequences:+ # The GLM chat template owns these role boundaries, so generic OpenAI+ # clients should not need model-specific stop knowledge. Inkling has a+ # different marker family and receives no implicit GLM stops. Treat an+ # occasional leading GLM marker patiently; client-provided stops remain# strict unless the extension is explicitly requested.return DEFAULT_CHAT_STOP_SEQUENCES, Truereturn sequences, ignore_leadingdiff --git a/c/tests/test_openai_server.py b/c/tests/test_openai_server.pyindex c3c999d1..a9a31e69 100644--- a/c/tests/test_openai_server.py+++ b/c/tests/test_openai_server.py@@ -12,8 +12,9 @@ from pathlib import Pathfrom openai_server import (APIError, APIHandler, APIServer, ClientCancelled,DEFAULT_CHAT_STOP_SEQUENCES, END, GenerationScheduler,- READY, Engine, StopFilter, _engine_error, generation_options,- parse_tool_calls, read_engine_turn, render_chat, serve, stop_policy)+ READY, Engine, InklingStreamSplit, StopFilter, _engine_error,+ generation_options, parse_tool_calls, read_engine_turn, render_chat,+ serve, stop_policy)class FakeEngine:@@ -123,18 +124,35 @@ class TemplateTest(unittest.TestCase):with self.subTest(value=value), self.assertRaises(APIError):generation_options({"stop": value}, 8)- def test_chat_defaults_role_stops_without_changing_client_or_completion_policy(self):- self.assertEqual(stop_policy({}, True), (DEFAULT_CHAT_STOP_SEQUENCES, True))- self.assertEqual(stop_policy({}, False), ((), False))- self.assertEqual(stop_policy({"stop": "END"}, True), (("END",), False))- self.assertEqual(stop_policy({- "stop": "END", "x_colibri_ignore_leading_stop": True,- }, True), (("END",), True))+ def test_glm_chat_defaults_role_stops_without_changing_other_policies(self):+ with patch("openai_server.ARCH", "glm"):+ self.assertEqual(stop_policy({}, True), (DEFAULT_CHAT_STOP_SEQUENCES, True))+ self.assertEqual(stop_policy({}, False), ((), False))+ self.assertEqual(stop_policy({"stop": "END"}, True), (("END",), False))+ self.assertEqual(stop_policy({+ "stop": "END", "x_colibri_ignore_leading_stop": True,+ }, True), (("END",), True))+ with patch("openai_server.ARCH", "inkling"):+ self.assertEqual(stop_policy({}, True), ((), False))+ self.assertEqual(stop_policy({"stop": "END"}, True), (("END",), False))with self.assertRaises(APIError):stop_policy({"x_colibri_ignore_leading_stop": "yes"}, True)class StopFilterTest(unittest.TestCase):+ def test_explicit_stop_composes_with_inkling_stream_split(self):+ content = []+ reasoning = []+ splitter = InklingStreamSplit(content.append, reasoning.append)+ stop_filter = StopFilter(("END",), splitter.feed)+ for chunk in ("<|content_thinking|>why<|content_text|>answer EN", "Dignored"):+ stop_filter.feed(chunk)+ stop_filter.finish()+ splitter.close()+ self.assertEqual("".join(reasoning), "why")+ self.assertEqual("".join(content), "answer ")+ self.assertEqual(stop_filter.matched, "END")+def test_hides_match_split_across_chunks(self):output = []stop_filter = StopFilter(("STOP",), output.append)diff --git a/docs/api.md b/docs/api.mdindex 8522f3be..3f5f86b8 100644--- a/docs/api.md+++ b/docs/api.md@@ -30,11 +30,12 @@ generation early in both JSON and streaming modes. The extension`x_colibri_ignore_leading_stop: true` discards leading stop sequences untilthe first non-whitespace response content, which is useful for local templatesthat occasionally emit a role marker before the answer; strict OpenAI stop-behavior remains the default for client-provided sequences. Chat requests with-no client `stop` automatically use the template's `<|user|>` and+behavior remains the default for client-provided sequences. GLM chat requests+with no client `stop` automatically use the template's `<|user|>` and`<|observation|>` role markers, patiently ignoring only leading markers; thisprevents a model-completed turn from silently generating a new user or tool-turn. Legacy completion requests receive no implicit stop sequences. The extension+turn. Inkling chat and legacy completion requests receive no implicit GLM stop+sequences. The extension`enable_thinking: true` enables GLM-5.2's reasoning block; the standard`reasoning_effort` field also enables it unless set to `none`.