Skip to content

armgit / laya

Public Imported from GitHub
0

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.

test(mcp): verify tournament refusal stays local in remote mode

Rishit Sharma58922a0d0f33
diff --git a/tests/test_mcp_remote.py b/tests/test_mcp_remote.py
index 41ba49b8..21d86a5e 100644
--- a/tests/test_mcp_remote.py
+++ b/tests/test_mcp_remote.py
@@ -15,7 +15,7 @@ pytest.importorskip("mcp")
from laya.mcp import server as mcp_server # noqa: E402
from laya.mcp.tools import ( # noqa: E402
ToolError, laya_decide, laya_predict, laya_predict_batch, laya_preset, laya_route, laya_route_batch,
- laya_shortlist, laya_status,
+ laya_shortlist, laya_status, laya_tournament,
)
from laya.mcp.remote import DEFAULT_TIMEOUT_S, RemoteError, RemoteRouter # noqa: E402
@@ -219,6 +219,17 @@ def test_shortlist_is_refused_in_remote_mode(serve):
assert info.value.code == "unsupported_remote"
[email protected]("n", [2, 40])
+def test_tournament_is_refused_before_remote_requests(serve, n):
+ questions = {"pick": {"type": "choice", "instructions": "pick",
+ "criteria": {"opt%d" % i: None for i in range(n)}}}
+ with pytest.raises(ToolError) as info:
+ laya_tournament({"text": "x"}, questions, router=RemoteRouter(serve))
+ assert info.value.code == "unsupported_remote"
+ assert "laya_predict" in info.value.message and "LAYA_TOURNAMENT_GROUP" in info.value.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")
@@ -332,13 +343,16 @@ 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
- try:
- server.laya_shortlist_tool(state, questions)
- except Exception as exc:
- assert "unsupported_remote" in str(exc), exc
- else:
- raise AssertionError("remote shortlist did not refuse the call")
+ for tool in (server.laya_shortlist_tool, server.laya_tournament_tool):
+ try:
+ tool(state, questions)
+ except Exception as exc:
+ payload = json.loads(str(exc))
+ assert payload["error"] == "unsupported_remote", payload
+ else:
+ raise AssertionError("remote in-process tool did not refuse the call")
assert "torch" not in sys.modules
+ assert "laya.shortlist" not in sys.modules
assert not server._ROUTER._agents
''')
env = dict(os.environ, LAYA_BASE_URL=serve, LAYA_THREADS="2", LAYA_PRELOAD="1")