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

Merge pull request #1497 from basil-k-aji-dev/feat/tool-fallback-olmoe-qwen36

Vincenzo Fornaro739e89912884
diff --cc c/openai_server.py
index 42fe3635,b43eb7cd..b319b314
--- a/c/openai_server.py
+++ b/c/openai_server.py
@@@ -258,23 -315,16 +315,32 @@@ _PARTIAL_END_RE = re.compile(r"<(?:/(?:
# <arg_key>K</arg_key><arg_value> structure. Default OFF (never rewrites well-formed output).
_SALVAGE = os.environ.get("COLI_TOOL_SALVAGE", "0") == "1"
+ # Families whose chat template has no tool syntax at all (OLMoE, Qwen3.6) refuse
+ # tools[] and role:"tool" rather than invent a format. COLI_TOOL_FALLBACK=1 opts
+ # into a prompt-injected translation for them: the declaration block, the prior
+ # assistant calls and the tool results are written as ordinary turns, in the
+ # same wire format parse_tool_calls() already reads back (#1378). Default OFF --
+ # these models were never trained on tool syntax, so this trades a clean 400 for
+ # output the parser may or may not recognise.
+ _TOOL_FALLBACK = os.environ.get("COLI_TOOL_FALLBACK", "0") == "1"
+
+def _tool_choice_name(tool_choice):
+ """The tool name a dict `tool_choice` forces, or None.
+
+ `.get` is taken only from a dict. Writing the name where the object goes --
+ {"type": "function", "function": "search"} instead of
+ {"function": {"name": "search"}} -- raised AttributeError in the five
+ renderers that read this and in generation_options() itself, and do_POST
+ answered HTTP 500 "The colibri engine failed to process the request." for a
+ payload generation_options() already has a 400 for. Same shape as the
+ json_schema fix (#1587): read the member, then check it.
+ """
+ function = tool_choice.get("function")
+ return ((function if isinstance(function, dict) else {}).get("name")
+ or tool_choice.get("name"))
+
+
def _tool_param_order(tools):
"""name -> ordered param names (required first) from the request schema, for de-mangling."""
out = {}