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
fix(mcp): send an out-of-range batch control to the validator instead of dropping it
ahmedandaloes1454580991f9
diff --git a/laya/mcp/server.py b/laya/mcp/server.pyindex 41a57990..d837d4d8 100644--- a/laya/mcp/server.py+++ b/laya/mcp/server.py@@ -334,17 +334,25 @@ def laya_predict_tool(),)def laya_predict_batch_tool(requests: list, batch_size: int = 0, hooks_timeout: float = 0,- min_confidence: float = -1, sort_by_length: bool = False) -> str:+ 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.return _wrap(laya_predict_batch,requests=requests,batch_size=batch_size or None,- hooks_timeout=hooks_timeout if hooks_timeout > 0 else None,- min_confidence=min_confidence if min_confidence >= 0 else None,+ hooks_timeout=hooks_timeout or None,+ min_confidence=min_confidence,sort_by_length=sort_by_length,router=router,)diff --git a/tests/test_mcp.py b/tests/test_mcp.pyindex a0611990..cc1c6f11 100644--- a/tests/test_mcp.py+++ b/tests/test_mcp.py@@ -1133,6 +1133,71 @@ def test_batch_predict():"internal_error")+def test_batch_tool_control_forwarding():+ """A control the tool cannot honour must reach the layer that rejects it, not vanish.++ `laya_predict_batch` owns validation and answers an out-of-range `hooks_timeout` or+ `min_confidence` with a ToolError naming the value. Collapsing those to None before the call+ turned an invalid deadline into "no deadline" and an invalid gate into "no gate": the client+ got a clean response and no way to tell the control it asked for had been dropped (#707).+ """+ import laya.mcp.server as server_mod++ seen = {}++ def fake_wrap(fn, **kwargs):+ seen["kwargs"] = kwargs+ return "{}"++ real_router_or_error, real_wrap = server_mod._router_or_error, server_mod._wrap++ def fake_router_or_error():+ return BatchRouter()++ server_mod._router_or_error = fake_router_or_error+ server_mod._wrap = fake_wrap+ try:+ # Unset stays unset: 0 is what an eager MCP client sends for a default, and the+ # declaration defaults are unset too.+ server_mod.laya_predict_batch_tool(requests=BATCH_REQUESTS, hooks_timeout=0)+ ok("batch_tool/hooks_timeout_zero_is_unset", seen["kwargs"]["hooks_timeout"] is None,+ repr(seen["kwargs"]["hooks_timeout"]))+ server_mod.laya_predict_batch_tool(requests=BATCH_REQUESTS)+ ok("batch_tool/hooks_timeout_default_is_unset", seen["kwargs"]["hooks_timeout"] is None,+ repr(seen["kwargs"]["hooks_timeout"]))+ ok("batch_tool/min_confidence_default_is_unset", seen["kwargs"]["min_confidence"] is None,+ repr(seen["kwargs"]["min_confidence"]))++ # A value in range is forwarded as given.+ server_mod.laya_predict_batch_tool(requests=BATCH_REQUESTS, hooks_timeout=1.5,+ min_confidence=0.75)+ ok("batch_tool/hooks_timeout_forwarded", seen["kwargs"]["hooks_timeout"] == 1.5,+ repr(seen["kwargs"]["hooks_timeout"]))+ ok("batch_tool/min_confidence_forwarded", seen["kwargs"]["min_confidence"] == 0.75,+ repr(seen["kwargs"]["min_confidence"]))++ # 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)+ ok("batch_tool/hooks_timeout_%r_reaches_tools" % (bad,),+ seen["kwargs"]["hooks_timeout"] == bad, repr(seen["kwargs"]["hooks_timeout"]))+ server_mod.laya_predict_batch_tool(requests=BATCH_REQUESTS, min_confidence=bad)+ ok("batch_tool/min_confidence_%r_reaches_tools" % (bad,),+ seen["kwargs"]["min_confidence"] == bad, repr(seen["kwargs"]["min_confidence"]))+ finally:+ server_mod._router_or_error, server_mod._wrap = real_router_or_error, real_wrap++ # And the tools layer does refuse them, which is what makes the forwarding observable.+ expect_tool_error("batch_tool/hooks_timeout_rejected_downstream",+ lambda: laya_predict_batch(BATCH_REQUESTS, hooks_timeout=-0.5,+ 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()),+ "invalid_min_confidence")++def test_batch_route():expect_tool_error("batch/route_no_router",lambda: laya_route_batch(BATCH_REQUESTS, router=None), "models_not_ready")@@ -2765,6 +2830,7 @@ test_option_order_forwarding()test_shortlist()test_batch_validation()test_batch_predict()+test_batch_tool_control_forwarding()test_batch_route()test_decide()test_shortlist_lang_parity()