Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
test(mcp): pin the batch tool's controls in the API contract suite; keep booleans out of "unset"
ahmedandaloes32d262bd3dc4
diff --git a/laya/mcp/server.py b/laya/mcp/server.pyindex d837d4d8..d4f608d5 100644--- a/laya/mcp/server.py+++ b/laya/mcp/server.py@@ -333,25 +333,28 @@ def laya_predict_tool(+ _GUARDRAILS),)-def laya_predict_batch_tool(requests: list, batch_size: int = 0, hooks_timeout: float = 0,+def laya_predict_batch_tool(requests: list, batch_size: int = 0, hooks_timeout: float | None = 0,min_confidence: float | None = None,sort_by_length: bool = False) -> str:"""Answer many typed-question requests in one batched call."""router = _router_or_error()# batch_size=0 means "unset": MCP clients send defaults eagerly, and- # None is what Router.predict_batch takes as "no forward-pass cap".- # hooks_timeout follows the same rule, and only the unset value is collapsed:- # `or None` folds an eager 0 into "unset" while leaving anything else alone.- # min_confidence is unset as None, like every sibling tool, so a value out of- # range reaches the tools layer, which owns validation and answers with a- # ToolError naming it. Collapsing those here instead turned an invalid deadline- # into "no deadline" and an invalid gate into "no gate": the caller got a clean- # response and no way to tell the control it asked for had been dropped.+ # None is what Router.predict_batch takes as "no forward-pass cap". hooks_timeout reads+ # a numeric 0 the same way -- and deliberately only a numeric 0, because `False == 0`+ # would otherwise fold a boolean, which `_validate_hooks_timeout` refuses by contract+ # ("would silently turn True into a one-second deadline").+ # Everything else -- negatives and booleans included -- goes to the tools layer, which+ # owns validation and answers with a ToolError naming the value. Collapsing those here+ # instead turned an invalid deadline into "no deadline" and an invalid gate into+ # "no gate": the caller got a clean response and no way to tell the control it asked+ # for had been dropped.+ if not isinstance(hooks_timeout, bool) and hooks_timeout == 0:+ hooks_timeout = Nonereturn _wrap(laya_predict_batch,requests=requests,batch_size=batch_size or None,- hooks_timeout=hooks_timeout or None,+ hooks_timeout=hooks_timeout,min_confidence=min_confidence,sort_by_length=sort_by_length,router=router,diff --git a/tests/test_hooks_api.py b/tests/test_hooks_api.pyindex 9b4b0c6d..a582c2f9 100644--- a/tests/test_hooks_api.py+++ b/tests/test_hooks_api.py@@ -91,6 +91,20 @@ check_param("Router.__init__", Router.__init__, "sha256_digests", None)check_true("Router/resolve", callable(getattr(Router, "resolve", None)))check_param("Router.unregister", Router.unregister, "name", inspect.Parameter.empty)+# The MCP batch tool's controls are public too, so they are pinned here rather than only in the+# forwarding test: `min_confidence` is unset as None (not the old -1) so a value out of range+# reaches the tools layer's validator instead of being folded into "unset" (#707), and+# `hooks_timeout` keeps 0 as the unset marker an eager MCP client sends for the default.+try:+ from laya.mcp.server import laya_predict_batch_tool as _mcp_batch_tool+except ImportError: # the mcp extra is optional; the core install skips this+ _mcp_batch_tool = None+if _mcp_batch_tool is not None:+ check_param("laya_predict_batch_tool", _mcp_batch_tool, "batch_size", 0)+ check_param("laya_predict_batch_tool", _mcp_batch_tool, "hooks_timeout", 0)+ check_param("laya_predict_batch_tool", _mcp_batch_tool, "min_confidence", None)+ check_param("laya_predict_batch_tool", _mcp_batch_tool, "sort_by_length", False)+# What the constructor does NOT raise over is part of its contract too: a shared# `agent_kwargs["expected_sha256"]` overlapping a per-checkpoint `sha256_digests` entry on one file# name is the ordinary shape, not a contradiction -- `model.safetensors` is the one name everydiff --git a/tests/test_mcp.py b/tests/test_mcp.pyindex cc1c6f11..9c675bf5 100644--- a/tests/test_mcp.py+++ b/tests/test_mcp.py@@ -1176,6 +1176,13 @@ def test_batch_tool_control_forwarding():ok("batch_tool/min_confidence_forwarded", seen["kwargs"]["min_confidence"] == 0.75,repr(seen["kwargs"]["min_confidence"]))+ # A bool is never an unset marker: `False == 0` in Python, so a plain equality or+ # `or None` fold would hide the tools layer's explicit refusal of booleans.+ for bad in (True, False):+ server_mod.laya_predict_batch_tool(requests=BATCH_REQUESTS, hooks_timeout=bad)+ ok("batch_tool/hooks_timeout_%r_reaches_tools" % (bad,),+ seen["kwargs"]["hooks_timeout"] is bad, repr(seen["kwargs"]["hooks_timeout"]))+# Out of range reaches the tools layer untouched instead of being folded into "unset".for bad in (-1.0, -0.5):server_mod.laya_predict_batch_tool(requests=BATCH_REQUESTS, hooks_timeout=bad)@@ -1192,6 +1199,10 @@ def test_batch_tool_control_forwarding():lambda: laya_predict_batch(BATCH_REQUESTS, hooks_timeout=-0.5,router=BatchRouter()),"invalid_hooks_timeout")+ expect_tool_error("batch_tool/hooks_timeout_false_rejected_downstream",+ lambda: laya_predict_batch(BATCH_REQUESTS, hooks_timeout=False,+ router=BatchRouter()),+ "invalid_hooks_timeout")expect_tool_error("batch_tool/min_confidence_rejected_downstream",lambda: laya_predict_batch(BATCH_REQUESTS, min_confidence=-0.5,router=BatchRouter()),