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 laya_predict_long up front in remote mode
Rishit Sharmaf173dd3270a5
diff --git a/laya/mcp/tools.py b/laya/mcp/tools.pyindex 6ad24482..b095bed9 100644--- a/laya/mcp/tools.py+++ b/laya/mcp/tools.py@@ -988,6 +988,14 @@ def laya_predict_long(Each answer carries the deciding window's ``window`` attribution (index and token offsetsinto the tokenized state), and ``windows`` counts the windows the model scored."""+ if router is not None and agent is None and hasattr(router, "base_url") and hasattr(router, "health"):+ raise ToolError(+ "unsupported_remote",+ "laya_predict_long scans the state window by window in-process; laya-serve has no "+ "long-state endpoint, so it is not available when LAYA_BASE_URL points at laya-serve. "+ "Run the MCP server without LAYA_BASE_URL to scan locally, or use laya_predict, which "+ "answers from the first window only.",+ )state_d = validate_state(state)questions_d = validate_questions(questions)model_name = validate_model(model)diff --git a/tests/test_mcp_remote.py b/tests/test_mcp_remote.pyindex a9c06e19..ed1f0004 100644--- a/tests/test_mcp_remote.py+++ b/tests/test_mcp_remote.py@@ -315,6 +315,19 @@ def test_tournament_is_refused_before_remote_requests(serve, n):assert FakeServe.requests == [][email protected]("model", ["auto", "english"])+def test_predict_long_is_refused_before_remote_requests(monkeypatch, serve, model):+ # laya-serve has no long-state endpoint, so the scan has nowhere to run. Without this refusal+ # the call reached Router.predict_long and came back as internal_error ("hooks are callables").+ monkeypatch.setattr(mcp_server, "_ROUTER", RemoteRouter(serve))+ with pytest.raises(Exception) as info:+ mcp_server.laya_predict_long_tool({"text": "x"}, _questions(), model=model)+ payload = json.loads(str(info.value))+ assert payload["error"] == "unsupported_remote", payload+ assert "laya_predict" in payload["message"] and "LAYA_BASE_URL" in payload["message"]+ assert FakeServe.requests == []++def test_server_builds_a_remote_router_from_the_environment(monkeypatch, serve):monkeypatch.setenv("LAYA_BASE_URL", serve + "/")monkeypatch.setenv("LAYA_API_KEY", "k")@@ -448,7 +461,7 @@ def test_remote_mcp_startup_and_every_tool_avoid_torch(serve):for call in calls:out = json.loads(call())assert "error" not in out, out- for tool in (server.laya_shortlist_tool, server.laya_tournament_tool):+ for tool in (server.laya_shortlist_tool, server.laya_tournament_tool, server.laya_predict_long_tool):try:tool(state, questions)except Exception as exc: