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): refuse a non-string noul label before stringifying it
Bruce-Yii8d1db1f243c0
diff --git a/laya/mcp/tools.py b/laya/mcp/tools.pyindex f6cec666..ee2d3dfc 100644--- a/laya/mcp/tools.py+++ b/laya/mcp/tools.py@@ -46,7 +46,18 @@ def _check_noul_labels(name: str, labels: Any) -> None:f"questions[{name}].labels must map exactly 'false' and 'true' to distinct "f"non-empty strings",)- texts = [str(labels[k]).strip() for k in ("false", "true")]+ values = [labels["false"], labels["true"]]+ # The agent requires a str here, and it is checked before the text is used: a number or a+ # bool is not a label, it is a type mistake. Stringifying first would quietly accept what+ # the agent rejects, and the rejection would then arrive too late to be reported as a+ # caller error.+ if not all(isinstance(value, str) for value in values):+ raise ToolError(+ "invalid_questions",+ f"questions[{name}].labels must give 'false' and 'true' string values, got "+ f"{[type(v).__name__ for v in values]}",+ )+ texts = [value.strip() for value in values]if not texts[0] or not texts[1] or texts[0] == texts[1]:raise ToolError("invalid_questions",diff --git a/tests/test_mcp.py b/tests/test_mcp.pyindex 693e8b73..9a28cb8b 100644--- a/tests/test_mcp.py+++ b/tests/test_mcp.py@@ -557,6 +557,21 @@ def test_question_validation_matches_the_agent():{"type": "noul", "instructions": "is true?", "labels": {"false": "", "true": "yes"}}),("noul_labels_not_object",{"type": "noul", "instructions": "is true?", "labels": ["yes", "no"]}),+ # A label is text, not a value. The agent checks the type before using it, so these+ # have to be refused here too -- stringifying them would accept exactly what the agent+ # rejects, and the failure would surface as an internal_error instead.+ ("noul_labels_numeric",+ {"type": "noul", "instructions": "is true?", "labels": {"false": 0, "true": 1}}),+ ("noul_labels_mixed_types",+ {"type": "noul", "instructions": "is true?", "labels": {"false": "no", "true": 1}}),+ ("noul_labels_bool",+ {"type": "noul", "instructions": "is true?", "labels": {"false": False, "true": True}}),+ ("noul_labels_null",+ {"type": "noul", "instructions": "is true?", "labels": {"false": None, "true": "yes"}}),+ ("noul_labels_list",+ {"type": "noul", "instructions": "is true?", "labels": {"false": ["no"], "true": "yes"}}),+ ("noul_labels_whitespace_equal",+ {"type": "noul", "instructions": "is true?", "labels": {"false": " same ", "true": "same"}}),("score_level_null",{"type": "score", "instructions": "how bad", "criteria": ["fine", None]}),("score_level_null_first",@@ -616,6 +631,10 @@ def test_a_bad_question_is_a_caller_error_not_a_server_fault():"criteria": {"yes": "affirmative", "no": "negative"}}),("noul_labels_wrong_names", {"type": "noul", "instructions": "is true?","labels": {"A": "yes", "B": "no"}}),+ ("noul_labels_numeric", {"type": "noul", "instructions": "is true?",+ "labels": {"false": 0, "true": 1}}),+ ("noul_labels_mixed_types", {"type": "noul", "instructions": "is true?",+ "labels": {"false": "no", "true": 1}}),("score_level_null", {"type": "score", "instructions": "how bad","criteria": ["fine", None]}),):