Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
Merge dev into fix/serve-tool-call-arguments-non-object: keep both tool-call regressions
JustVugg5480ea572a22
diff --cc c/tests/test_openai_server.pyindex 3bea0a79,d85a00de..db401041--- a/c/tests/test_openai_server.py+++ b/c/tests/test_openai_server.py@@@ -1885,60 -1575,26 +1921,80 @@@ class HTTPTest(unittest.TestCase)self.addCleanup(caught.exception.close)self.assertEqual(caught.exception.code, 400)+ def test_tool_choice_with_a_non_object_function_is_a_client_error(self):+ """{"type": "function", "function": "search"} answered HTTP 500.++ generation_options() already has the 400 for a `tool_choice` function+ object with no name, but it -- and the five renderers that read the+ forced tool the same way -- did `(tool_choice.get("function") or {})+ .get("name")`, so a `function` that is not an object raised+ AttributeError first and do_POST answered 500 "The colibri engine failed+ to process the request." for a request the engine never saw. Every arch+ and both OpenAI endpoints, because the crash was on the read.+ """+ tools = [{"type": "function", "function": {"name": "search"}}]+ for arch in ("glm", "glm53", "kimi", "deepseek_v4", "deepseek_v41",+ "olmoe", "inkling", "qwen36", "qwen38"):+ for function in ("search", ["search"], 5):+ with self.subTest(arch=arch, function=function):+ with patch("openai_server.ARCH", arch):+ with self.assertRaises(HTTPError) as caught:+ self.request("/v1/chat/completions", {+ "model": "test-model",+ "messages": [{"role": "user", "content": "hi"}],+ "tools": tools,+ "tool_choice": {"type": "function", "function": function}})+ self.addCleanup(caught.exception.close)+ self.assertEqual(caught.exception.code, 400)+ # /v1/completions has no renderer in front of generation_options, so it+ # reached the same read directly.+ with self.assertRaises(HTTPError) as caught:+ self.request("/v1/completions", {+ "model": "test-model", "prompt": "hi", "tools": tools,+ "tool_choice": {"type": "function", "function": "search"}})+ self.addCleanup(caught.exception.close)+ self.assertEqual(caught.exception.code, 400)++ def test_a_well_formed_forced_tool_choice_still_runs(self):+ """The read above must not change the shape clients actually send."""+ with self.request("/v1/chat/completions", {+ "model": "test-model",+ "messages": [{"role": "user", "content": "hi"}],+ "tools": [{"type": "function", "function": {"name": "search"}}],+ "tool_choice": {"type": "function",+ "function": {"name": "search"}}}) as response:+ self.assertEqual(response.status, 200)+ self.assertIn("You must call the function `search`", self.engine.calls[-1][0])+ # The OpenAI-legacy spelling {"type": "function", "name": ...} still+ # forces the tool: _tool_choice_name keeps that fallback.+ with self.request("/v1/chat/completions", {+ "model": "test-model",+ "messages": [{"role": "user", "content": "hi"}],+ "tools": [{"type": "function", "function": {"name": "search"}}],+ "tool_choice": {"type": "function", "name": "search"}}) as response:+ self.assertEqual(response.status, 200)+ self.assertIn("You must call the function `search`", self.engine.calls[-1][0])++ def test_tool_call_arguments_that_are_not_an_object_do_not_fail_the_request(self):+ """A replayed tool call with `arguments: "[1, 2]"` answered HTTP 500.++ render_chat reached `(args or {}).items()` with a parsed list, and the+ AttributeError became do_POST's catch-all 500 "The colibri engine failed+ to process the request." -- which OpenAI SDKs retry, against an engine+ that was never asked anything.+ """+ body = {"model": "test-model", "messages": [+ {"role": "user", "content": "run it"},+ {"role": "assistant", "content": "", "tool_calls": [+ {"id": "x", "type": "function",+ "function": {"name": "fn", "arguments": "[1, 2]"}}]},+ {"role": "tool", "tool_call_id": "x", "content": "done"},+ {"role": "user", "content": "and now?"},+ ]}+ with self.request("/v1/chat/completions", body) as response:+ self.assertEqual(response.status, 200)+ self.assertEqual(json.load(response)["object"], "chat.completion")+class ClientHangupTest(unittest.TestCase):"""A client that disconnects mid-response must not print a traceback.