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.

fix(mcp): align model schema nullability

Ha1baraA11b259749ae468
diff --git a/docs/cli-mcp.md b/docs/cli-mcp.md
index 736436be..bcdb1f87 100644
--- a/docs/cli-mcp.md
+++ b/docs/cli-mcp.md
@@ -166,6 +166,8 @@ Laya does not open a network port.
| `laya_route_batch` | Decides which checkpoint would answer each request, with no forward pass and no checkpoint load. | `requests`, each `{state, questions, model?, task?, lang?, lang_guess?}`, optional `hooks_timeout` |
| `laya_decide` | Answers a JSON-schema-shaped decision in one forward pass and returns the decided values with per-field confidence, instead of an answer map to parse. Schema properties may be enum choices, booleans, or integers with a minimum and maximum; free strings, arrays, and nested objects are rejected by path. | `state`, `schema`, optional `model`, `min_confidence` |
+On `laya_route`, `laya_predict`, `laya_shortlist`, and `laya_decide`, `model` may be omitted or set to `null`; either form resolves to `auto`.
+
The three batch and schema tools exist because the same operations are available on the SDK and
`laya-serve`: handling many requests, or serving a caller that already knows the answer shape,
does not require dropping to Python. For the schema-driven form in more depth, see
diff --git a/laya/mcp/server.py b/laya/mcp/server.py
index 41a57990..89b56cac 100644
--- a/laya/mcp/server.py
+++ b/laya/mcp/server.py
@@ -293,7 +293,7 @@ def laya_route_tool(
def laya_predict_tool(
state: dict,
questions: dict,
- model: str = "auto",
+ model: str | None = None,
task: str | None = None,
lang: str | None = None,
lang_guess: str | None = None,
@@ -397,7 +397,7 @@ def laya_route_batch_tool(requests: list, hooks_timeout: float = 0) -> str:
def laya_shortlist_tool(
state: dict,
questions: dict,
- model: str = "auto",
+ model: str | None = None,
k: int = 20,
task: str | None = None,
lang: str | None = None,
@@ -498,7 +498,7 @@ def laya_preset_tool(
+ _GUARDRAILS
),
)
-def laya_decide_tool(state: dict, schema: dict, model: str = "auto",
+def laya_decide_tool(state: dict, schema: dict, model: str | None = None,
min_confidence: float | None = None) -> str:
"""Answer a JSON-schema-shaped decision and return the decided values."""
router = _router_or_error()
diff --git a/tests/test_mcp.py b/tests/test_mcp.py
index a0611990..5ded2a28 100644
--- a/tests/test_mcp.py
+++ b/tests/test_mcp.py
@@ -1831,6 +1831,21 @@ def test_controls_signature_and_schema():
required == (["preset", "state"] if name == "laya_preset" else ["state", "questions"]),
repr(required))
+ from laya.mcp import server as server_mod
+
+ model_schemas = []
+ for name in ("laya_predict", "laya_shortlist", "laya_decide", "laya_route"):
+ parameter = inspect.signature(getattr(server_mod, name + "_tool")).parameters["model"]
+ ok("signature/%s_model_default_none" % name, parameter.default is None, repr(parameter.default))
+ tool = by_name[name]
+ schema = tool.input_schema if hasattr(tool, "input_schema") else tool.inputSchema
+ model_schema = schema.get("properties", {}).get("model", {})
+ ok("schema/%s_model_nullable" % name,
+ {"type": "null"} in (model_schema.get("anyOf") or []), repr(model_schema))
+ model_schemas.append(model_schema)
+ ok("schema/model_specs_consistent", all(model_schema == model_schemas[0] for model_schema in model_schemas),
+ repr(model_schemas))
+
def test_lang_guess_control():
"""`lang_guess` -- core's soft routing hint (#489 family) -- reaches the single-request tools.