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): laya_predict_batch validates min_confidence and hooks_timeout up front
AlKor13364de78a4948
diff --git a/laya/mcp/tools.py b/laya/mcp/tools.pyindex 761a27f9..ed99aa42 100644--- a/laya/mcp/tools.py+++ b/laya/mcp/tools.py@@ -1011,6 +1011,12 @@ def laya_predict_batch("""items = validate_batch_requests(requests)size = _validate_batch_size(batch_size)+ # Validate the call-level controls up front, the way every sibling tool does, so a bad value is+ # a clean ToolError the client can read -- not an `internal_error: ValueError` that escapes the+ # TypeError-only handler below (min_confidence), and not a silent 1-second hook deadline from+ # core's `float(True) == 1.0` (hooks_timeout).+ mc = validate_min_confidence(min_confidence)+ ht = _validate_hooks_timeout(hooks_timeout)if router is None:raise ToolError("models_not_ready", "Router is not loaded")if not hasattr(router, "predict_batch"):@@ -1021,10 +1027,10 @@ def laya_predict_batch(kwargs = {}if size is not None:kwargs["batch_size"] = size- if hooks_timeout is not None:- kwargs["hooks_timeout"] = hooks_timeout- if min_confidence is not None:- kwargs["min_confidence"] = min_confidence+ if ht is not None:+ kwargs["hooks_timeout"] = ht+ if mc is not None:+ kwargs["min_confidence"] = mcif sort_by_length:kwargs["sort_by_length"] = Trueresults = router.predict_batch(items, **kwargs)diff --git a/tests/test_mcp.py b/tests/test_mcp.pyindex af5a4dd6..0d7972d4 100644--- a/tests/test_mcp.py+++ b/tests/test_mcp.py@@ -1046,6 +1046,21 @@ def test_batch_predict():ok("batch/defaults_not_in_kwargs", "hooks_timeout" not in kwargs and"min_confidence" not in kwargs and "sort_by_length" not in kwargs, repr(kwargs))+ # Call-level controls are validated up front like every sibling tool: a bad value is a clean+ # ToolError, not an internal_error that escaped the TypeError-only handler, and not a silent+ # 1-second hook deadline from core's float(True) == 1.0.+ expect_tool_error("batch/min_confidence_out_of_range",+ lambda: laya_predict_batch(BATCH_REQUESTS, min_confidence=1.5, router=BatchRouter()),+ "invalid_min_confidence")+ expect_tool_error("batch/hooks_timeout_bool_rejected",+ lambda: laya_predict_batch(BATCH_REQUESTS, hooks_timeout=True, router=BatchRouter()),+ "invalid_hooks_timeout")+ # min_confidence=0.0 is a real gate (abstain over nothing) and must still be forwarded.+ router = BatchRouter()+ laya_predict_batch(BATCH_REQUESTS, min_confidence=0.0, router=router)+ _, kwargs = router.predict_batch_calls[0][1], router.predict_batch_calls[0][2]+ ok("batch/min_confidence_zero_forwarded", kwargs.get("min_confidence") == 0.0, repr(kwargs))+expect_tool_error("batch/predict_count_mismatch",lambda: laya_predict_batch(BATCH_REQUESTS, router=ShortRouter()),"internal_error")