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
feat(mcp): forward Router lang_guess through the single-request tools
Aashishda4c527c4f2c
diff --git a/docs/cli-mcp.md b/docs/cli-mcp.mdindex c880bcf3..8228b311 100644--- a/docs/cli-mcp.md+++ b/docs/cli-mcp.md@@ -146,11 +146,11 @@ Laya does not open a network port.| Tool | What it does | Main inputs ||---|---|---|| `laya_status` | Reports the configured or actual device, CUDA availability, loaded checkpoints, preload state, readiness, and package versions. | none |-| `laya_route` | Selects a checkpoint and returns its model, repository, and reason without running a forward pass. | `state`, `questions` |-| `laya_predict` | Runs typed questions and returns answers, routing metadata, latency, and the answering device when readable. | `state`, `questions`, optional `model` (`auto`, `english`, `multilingual`, or `typed-decisions`) |-| `laya_shortlist` | Shortlists a many-option choice question, then answers it and returns the shortlist metadata. | `state`, `questions`, optional `model`, optional `k` (default `20`) |-| `laya_preset` | Runs a built-in workflow using its built-in question set. | `preset`, `state` |-| `laya_predict_batch` | Answers many requests in one call. Requests are routed first and grouped by checkpoint, so matching question schemas share forward passes; answers come back in input order. | `requests`, each `{state, questions, model?, task?, lang?}`, optional `batch_size` |+| `laya_route` | Selects a checkpoint and returns its model, repository, and reason without running a forward pass. | `state`, `questions`, optional `model`, `task`, `lang`, `lang_guess` |+| `laya_predict` | Runs typed questions and returns answers, routing metadata, latency, and the answering device when readable. | `state`, `questions`, optional `model` (`auto`, `english`, `multilingual`, or `typed-decisions`), `task`, `lang`, `lang_guess`, `max_len`, `head_max_len`, `min_confidence` |+| `laya_shortlist` | Shortlists a many-option choice question, then answers it and returns the shortlist metadata. | `state`, `questions`, optional `model`, `k` (default `20`), `task`, `lang`, `lang_guess`, `max_len`, `head_max_len`, `min_confidence` |+| `laya_preset` | Runs a built-in workflow using its built-in question set. | `preset`, `state`, optional `task`, `lang`, `lang_guess`, `max_len`, `head_max_len`, `min_confidence` |+| `laya_predict_batch` | Answers many requests in one call. Requests are routed first and grouped by checkpoint, so matching question schemas share forward passes; answers come back in input order. | `requests`, each `{state, questions, model?, task?, lang?, lang_guess?, max_len?, head_max_len?}`, optional `batch_size` || `laya_route_batch` | Decides which checkpoint would answer each request, with no forward pass and no checkpoint load. | `requests`, same shape as `laya_predict_batch` || `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` |@@ -174,6 +174,15 @@ exactly one string, `laya_preset` places it under the field that preset's questisame placement the CLI does, so a caller does not have to guess the key. Anything richer than onestring is the caller's own shape and is passed through untouched.+Every single-request tool takes the same per-call routing controls the batch requests do. Alongside+`model`, a request may set `task` (name a checkpoint by the work), `lang` (force a language code),+and `lang_guess` (a soft language hint that sits below `lang` and above the built-in detector, so a+probable-but-uncertain code can nudge which checkpoint is chosen without forcing it the way `lang`+does). `lang_guess` only participates in routing, so like `task` it is refused on a call that pins+`model` -- a pinned checkpoint has nothing left to route. `laya_predict` and `laya_shortlist` also+take `max_len`/`head_max_len` for the answering token budget and `min_confidence` for the abstention+gate.+A prediction call has the same shape as the SDK's typed call:```jsondiff --git a/laya/mcp/server.py b/laya/mcp/server.pyindex e7d362e6..d697535a 100644--- a/laya/mcp/server.py+++ b/laya/mcp/server.py@@ -99,6 +99,9 @@ _CONTROLS_DOC = ("refused on a call that also pins model, since the pin would win and the task would be ignored. ""lang: a language code ('de', 'en-US') -- routes non-English text to the multilingual ""checkpoint and selects that checkpoint's per-language calibration. "+ "lang_guess: a soft language code -- a probable-but-uncertain language that participates in "+ "routing (checked after lang, before built-in detection) rather than forcing the checkpoint the "+ "way lang does; like task it only routes, so it is refused on a call that pins model. ""max_len / head_max_len: positive integers overriding the answering token budget for this call ""only -- head_max_len is the option-and-instructions budget, so raise it when a choice question ""has many options and the answers look like the labels blur together. "@@ -204,7 +207,7 @@ def laya_status_tool() -> str:description=("Decide which Laya checkpoint would answer, without running a forward pass. ""Use this to explain routing (english vs multilingual vs typed-decisions) to the user. "- "Passing a laya_predict call's model/task/lang here reproduces the routing block it "+ "Passing a laya_predict call's model/task/lang/lang_guess here reproduces the routing block it ""reported, without paying for the forward pass; leaving model unset (or 'auto') routes as ""normal. "+ _GUARDRAILS@@ -217,6 +220,7 @@ def laya_route_tool(model: str | None = None,task: str | None = None,lang: str | None = None,+ lang_guess: str | None = None,) -> str:"""Decide which Laya checkpoint would answer, without running a forward pass."""router = _router_or_error()@@ -227,6 +231,7 @@ def laya_route_tool(model=model,task=task,lang=lang,+ lang_guess=lang_guess,router=router,)@@ -250,6 +255,7 @@ def laya_predict_tool(model: str = "auto",task: str | None = None,lang: str | None = None,+ lang_guess: str | None = None,max_len: int | None = None,head_max_len: int | None = None,min_confidence: float | None = None,@@ -263,6 +269,7 @@ def laya_predict_tool(model=model,task=task,lang=lang,+ lang_guess=lang_guess,max_len=max_len,head_max_len=head_max_len,min_confidence=min_confidence,@@ -339,6 +346,7 @@ def laya_shortlist_tool(k: int = 20,task: str | None = None,lang: str | None = None,+ lang_guess: str | None = None,max_len: int | None = None,head_max_len: int | None = None,min_confidence: float | None = None,@@ -357,6 +365,7 @@ def laya_shortlist_tool(k=k,task=task,lang=lang,+ lang_guess=lang_guess,max_len=max_len,head_max_len=head_max_len,min_confidence=min_confidence,@@ -396,6 +405,7 @@ def laya_preset_tool(state: dict,task: str | None = None,lang: str | None = None,+ lang_guess: str | None = None,max_len: int | None = None,head_max_len: int | None = None,min_confidence: float | None = None,@@ -408,6 +418,7 @@ def laya_preset_tool(state=state,task=task,lang=lang,+ lang_guess=lang_guess,max_len=max_len,head_max_len=head_max_len,min_confidence=min_confidence,diff --git a/laya/mcp/tools.py b/laya/mcp/tools.pyindex 1bf7f269..dba4b813 100644--- a/laya/mcp/tools.py+++ b/laya/mcp/tools.py@@ -280,6 +280,25 @@ def validate_lang(lang: Any) -> str | None:return lang+def validate_lang_guess(lang_guess: Any) -> str | None:+ """A soft routing hint for core's ``lang_guess`` override, or ``None`` for "not set".++ ``lang_guess`` sits between an explicit ``lang`` and the built-in detector: it names a probable+ language so routing can prefer the checkpoint that reads it, without forcing the answer the way+ ``lang`` does. Like ``lang`` only the type is checked here -- a code's meaning is core's business,+ and a blank or unknown code falls through to detection rather than failing. Core also accepts a+ callable for ``lang_guess``, but an MCP client carries JSON, not a function, so a non-string is+ refused rather than silently dropped. The batch surface already advertises this key+ (:data:`BATCH_ITEM_OVERRIDES`); the single-request tools forward it through here.+ """+ if lang_guess is None:+ return None+ if not isinstance(lang_guess, str):+ raise ToolError("invalid_lang_guess",+ "lang_guess must be a language code like 'en' or 'de', got %r" % (lang_guess,))+ return lang_guess++def validate_budget(value: Any, name: str) -> int | None:"""One of the two per-call token budgets (``max_len``, ``head_max_len``), or ``None``.@@ -360,6 +379,7 @@ def laya_predict(*,task: Any = None,lang: Any = None,+ lang_guess: Any = None,max_len: Any = None,head_max_len: Any = None,min_confidence: Any = None,@@ -371,10 +391,12 @@ def laya_predict(``router`` is used when model == "auto"; ``agent`` for a direct checkpoint.``task``/``lang`` are the router's own overrides (an explicit ``model`` outranks an explicit- ``task``, which outranks an explicit ``lang``); ``max_len``/``head_max_len`` override the token- budget the answering checkpoint was configured with; ``min_confidence`` flags any answer whose- calibrated confidence falls below it with ``low_confidence: true``. None of them is forwarded- unless set, so a router or agent that predates those keywords keeps working.+ ``task``, which outranks an explicit ``lang``); ``lang_guess`` is the router's soft hint that sits+ below ``lang`` and above built-in detection -- it only participates in routing, so like ``task``+ it is refused on a pinned model and never reaches a direct agent; ``max_len``/``head_max_len``+ override the token budget the answering checkpoint was configured with; ``min_confidence`` flags+ any answer whose calibrated confidence falls below it with ``low_confidence: true``. None of them+ is forwarded unless set, so a router or agent that predates those keywords keeps working."""state_d = validate_state(state)questions_d = validate_questions(questions)@@ -386,6 +408,11 @@ def laya_predict(validate_budget(max_len, "max_len"),validate_budget(head_max_len, "head_max_len"),)+ lang_guess_code = validate_lang_guess(lang_guess)+ if lang_guess_code is not None:+ # Only when set, so a call that passes no hint stays byte-identical to the one that made+ # no ``lang_guess`` keyword exist, and a deployment's ``Router(lang_guess=...)`` still answers.+ budget["lang_guess"] = lang_guess_codemin_conf = validate_min_confidence(min_confidence)if min_conf is not None:# Only when set, so a call that abstains over nothing stays byte-identical to the one@@ -400,6 +427,13 @@ def laya_predict("invalid_task","task routes between checkpoints; with a pinned model there is nothing to route",)+ # `lang_guess` is routing-only in the same way, and `Agent.predict` does not accept it, so a+ # pinned call that set it would either be ignored (router) or crash (direct agent).+ if model_name != AUTO and "lang_guess" in budget:+ raise ToolError(+ "invalid_lang_guess",+ "lang_guess routes between checkpoints; with a pinned model there is nothing to route",+ )def _run() -> Any:if model_name == "auto":@@ -407,12 +441,13 @@ def laya_predict(if agent is None:raise ToolError("models_not_ready", "Router is not loaded (auto mode)")# An Agent answers but does not route: run it directly and report- # a null model below, instead of echoing 'auto' (#444). `task` only- # chooses between checkpoints, so it has nothing to do here.+ # a null model below, instead of echoing 'auto' (#444). `task` and `lang_guess` only+ # choose between checkpoints, so they have nothing to do here.nonlocal auto_without_routerauto_without_router = Truereturn agent.predict(state_d, questions_d,- **{k: v for k, v in budget.items() if k != "task"})+ **{k: v for k, v in budget.items()+ if k not in ("task", "lang_guess")})return router.predict(state_d, questions_d, **budget)if agent is not None:return agent.predict(state_d, questions_d, **budget)@@ -470,12 +505,14 @@ def laya_route(model: Any = None,task: Any = None,lang: Any = None,+ lang_guess: Any = None,router: Any = None,) -> dict:"""Routing decision only: no forward pass.- Takes the three routing overrides :meth:`laya_predict` takes -- ``model``, ``task``, ``lang`` --- so "which checkpoint would this go to?" can be asked under a pin without running anything.+ Takes the routing overrides :meth:`laya_predict` takes -- ``model``, ``task``, ``lang``,+ ``lang_guess`` -- so "which checkpoint would this go to?" can be asked under a pin without+ running anything.Passing a predict call's controls here reproduces the ``routing`` block it returned, which iswhat makes a route a cheap explanation of a decision rather than a different decision."""@@ -485,6 +522,7 @@ def laya_route(# override rather than a ValueError from normalise_name.model_name = validate_model(model)task_name = validate_task(task)+ lang_guess_code = validate_lang_guess(lang_guess)# Same rule as the decision tools: `_route` checks an explicit model first and never reaches# the task, so a call that sets both is asking a question with two answers.if model_name != AUTO and task_name is not None:@@ -492,6 +530,12 @@ def laya_route("invalid_task","task routes between checkpoints; with a pinned model there is nothing to route",)+ # `lang_guess` routes in the same place, so it is equally meaningless once a checkpoint is pinned.+ if model_name != AUTO and lang_guess_code is not None:+ raise ToolError(+ "invalid_lang_guess",+ "lang_guess routes between checkpoints; with a pinned model there is nothing to route",+ )overrides: dict[str, Any] = {}if model_name != AUTO:overrides["model"] = model_name@@ -500,6 +544,8 @@ def laya_route(lang_code = validate_lang(lang)if lang_code is not None:overrides["lang"] = lang_code+ if lang_guess_code is not None:+ overrides["lang_guess"] = lang_guess_code# Everything the caller typed is checked before the server is asked for a checkpoint.if router is None:raise ToolError("models_not_ready", "Router is not loaded")@@ -583,6 +629,7 @@ def laya_shortlist(*,task: Any = None,lang: Any = None,+ lang_guess: Any = None,max_len: Any = None,head_max_len: Any = None,min_confidence: Any = None,@@ -605,8 +652,9 @@ def laya_shortlist(``head_max_len`` matters more here than anywhere else: shortlisting existsbecause a large label set shares that budget, and narrowing to ``k`` is onlyhalf of the fix. The budget override reaches the answering forward pass;- ``task``/``lang`` reach the route that chose the checkpoint; ``min_confidence``- flags a kept-label answer the checkpoint is unsure of.+ ``task``/``lang``/``lang_guess`` reach the route that chose the checkpoint+ (``lang_guess`` only routes, so like ``task`` it is stripped before the answering pass);+ ``min_confidence`` flags a kept-label answer the checkpoint is unsure of."""# Lazy: keeps numpy/shortlist out of module import for laya.mcp.tools.from laya.shortlist import (@@ -620,6 +668,9 @@ def laya_shortlist(questions_d = validate_questions(questions)model_name = validate_model(model)routing_overrides = _overrides(validate_task(task), validate_lang(lang), None, None)+ lang_guess_code = validate_lang_guess(lang_guess)+ if lang_guess_code is not None:+ routing_overrides["lang_guess"] = lang_guess_codebudget = _overrides(None, None, validate_budget(max_len, "max_len"),validate_budget(head_max_len, "head_max_len"))min_conf = validate_min_confidence(min_confidence)@@ -634,9 +685,16 @@ def laya_shortlist("invalid_task","task routes between checkpoints; with a pinned model there is nothing to route",)+ # `lang_guess` is routing-only in the same way, so a pinned call has nothing for it to choose.+ if model_name != AUTO and "lang_guess" in routing_overrides:+ raise ToolError(+ "invalid_lang_guess",+ "lang_guess routes between checkpoints; with a pinned model there is nothing to route",+ )# `lang` survives pinning because it means two things: it can route, and on the answering# checkpoint it selects the per-language temperature table.- forward_overrides = {name: value for name, value in routing_overrides.items() if name != "task"}+ forward_overrides = {name: value for name, value in routing_overrides.items()+ if name not in ("task", "lang_guess")}if k is None:k = DEFAULT_SHORTLIST_Kif isinstance(k, bool) or not isinstance(k, int) or k < 1:@@ -717,6 +775,7 @@ def laya_preset(*,task: Any = None,lang: Any = None,+ lang_guess: Any = None,max_len: Any = None,head_max_len: Any = None,min_confidence: Any = None,@@ -733,9 +792,9 @@ def laya_preset(shape and is passed through untouched.The preset fixes the questions, not the route or the budget, so the per-call controls a- hand-written :func:`laya_predict` takes -- ``task``/``lang``/``max_len``/``head_max_len`` and- ``min_confidence`` -- are available here too; most usefully ``lang``, since a preset's- instructions are English text whatever state they read.+ hand-written :func:`laya_predict` takes -- ``task``/``lang``/``lang_guess``/``max_len``/+ ``head_max_len`` and ``min_confidence`` -- are available here too; most usefully ``lang``, since a+ preset's instructions are English text whatever state they read."""preset_name = validate_preset(preset)state_d = validate_state(state)@@ -753,6 +812,7 @@ def laya_preset(model="auto",task=task,lang=lang,+ lang_guess=lang_guess,max_len=max_len,head_max_len=head_max_len,min_confidence=min_confidence,diff --git a/tests/test_mcp.py b/tests/test_mcp.pyindex d878d8c6..23e10b99 100644--- a/tests/test_mcp.py+++ b/tests/test_mcp.py@@ -47,6 +47,7 @@ from laya.mcp.tools import ( # noqa: E402validate_batch_requests,validate_budget,validate_lang,+ validate_lang_guess,validate_min_confidence,validate_model,validate_preset,@@ -1629,9 +1630,9 @@ def test_controls_signature_and_schema():"""import inspect- controls = ["task", "lang", "max_len", "head_max_len"]+ controls = ["task", "lang", "lang_guess", "max_len", "head_max_len"]for fn, want in ((laya_predict, controls), (laya_shortlist, controls),- (laya_preset, controls), (laya_route, ["model", "task", "lang"])):+ (laya_preset, controls), (laya_route, ["model", "task", "lang", "lang_guess"])):params = inspect.signature(fn).parametersfor name in want:ok("signature/%s_has_%s" % (fn.__name__, name), name in params, repr(sorted(params)))@@ -1664,6 +1665,132 @@ def test_controls_signature_and_schema():repr(required))+def test_lang_guess_control():+ """`lang_guess` -- core's soft routing hint (#489 family) -- reaches the single-request tools.++ The batch surface already forwards it (``BATCH_ITEM_OVERRIDES`` advertises the key, and+ ``laya_predict_batch``/``laya_route_batch`` hand it to ``Router.*_batch``), and ``laya-serve`` and+ the CLI forward it, so a client scoring one state over MCP could ask for a probable language to+ nudge the checkpoint only by sending a batch of one. `lang_guess` is routing-only, so it is+ treated like ``task``: forwarded to a router call, refused on a pinned model (a pinned call has+ nothing to route), and stripped on a direct agent (``Agent.predict`` does not accept it).+ """+ import inspect++ # The validator mirrors validate_lang: a code passes through verbatim, a non-string is refused in+ # this layer's words. A callable is core's other accepted form but an MCP client carries JSON.+ ok("langguess/none_is_unset", validate_lang_guess(None) is None)+ for code in ("de", "en-US", "pt", "", " ", "DE"):+ ok("langguess/verbatim_%r" % code, validate_lang_guess(code) == code)+ for bad in (5, ["de"], {"lang": "de"}, True):+ expect_tool_error("langguess/rejected_%r" % (bad,),+ lambda b=bad: validate_lang_guess(b), "invalid_lang_guess")+ # A callable is legal in core but not expressible over the wire; the MCP boundary refuses it+ # rather than silently dropping the hint.+ expect_tool_error("langguess/callable_rejected",+ lambda: validate_lang_guess(lambda state: "de"), "invalid_lang_guess")++ # laya_predict forwards lang_guess to core's predict, and only when set: a call with no hint+ # reaches core exactly as before the keyword was exposed here.+ router = ControlRouter()+ laya_predict(STATE, QUESTIONS, router=router)+ ok("predict/langguess_unset_absent", router.predict_calls == [{}], repr(router.predict_calls))+ router = ControlRouter()+ laya_predict(STATE, QUESTIONS, lang_guess="de", router=router)+ ok("predict/langguess_forwarded", router.predict_calls == [{"lang_guess": "de"}],+ repr(router.predict_calls))+ router = ControlRouter()+ laya_predict(STATE, QUESTIONS, lang_guess="de", task="typed_decisions", router=router)+ ok("predict/langguess_alongside_task",+ router.predict_calls == [{"task": "typed_decisions", "lang_guess": "de"}],+ repr(router.predict_calls))+ # An explicit lang and a soft hint are distinct keywords: both reach core, and core orders them.+ router = ControlRouter()+ laya_predict(STATE, QUESTIONS, lang="fr", lang_guess="de", router=router)+ ok("predict/lang_and_langguess_distinct",+ router.predict_calls == [{"lang": "fr", "lang_guess": "de"}], repr(router.predict_calls))++ # Pinned: refused before core, exactly like task -- there is nothing to route.+ for model in ("english", "laya", "ML"):+ router = ControlRouter()+ expect_tool_error("predict/model_plus_langguess_%s" % model,+ lambda m=model: laya_predict(STATE, QUESTIONS, model=m,+ lang_guess="de", router=router),+ "invalid_lang_guess")+ ok("predict/model_plus_langguess_no_call_%s" % model, router.predict_calls == [],+ repr(router.predict_calls))+ router = ControlRouter()+ expect_tool_error("predict/bad_langguess_before_core",+ lambda: laya_predict(STATE, QUESTIONS, lang_guess=["de"], router=router),+ "invalid_lang_guess")+ ok("predict/bad_langguess_no_call", router.predict_calls == [], repr(router.predict_calls))++ # The direct-agent branch: Agent.predict does not accept lang_guess, so it is stripped -- a+ # no-router auto call answers through the agent without ever naming the hint to core.+ agent = ControlAgent()+ laya_predict(STATE, QUESTIONS, lang_guess="de", agent=agent)+ ok("predict/agent_langguess_stripped", agent.calls == [{}], repr(agent.calls))+ agent = ControlAgent()+ laya_predict(STATE, QUESTIONS, lang="de", lang_guess="en", agent=agent)+ ok("predict/agent_keeps_lang_drops_langguess", agent.calls == [{"lang": "de"}],+ repr(agent.calls))++ # laya_route: a routing tool, so lang_guess reaches route and is refused on a pin.+ router = ControlRouter(routed="multilingual")+ out = laya_route(STATE, QUESTIONS, lang_guess="de", router=router)+ ok("route/langguess_forwarded", router.route_calls == [{"lang_guess": "de"}],+ repr(router.route_calls))+ ok("route/langguess_decision_shape", set(out) == {"model", "repo", "reason"}, repr(out))+ router = ControlRouter()+ expect_tool_error("route/model_plus_langguess",+ lambda: laya_route(STATE, QUESTIONS, model="english",+ lang_guess="de", router=router),+ "invalid_lang_guess")+ ok("route/refused_langguess_before_core", router.route_calls == [], repr(router.route_calls))++ # laya_shortlist: lang_guess reaches the route that chose the checkpoint, and is stripped from+ # the answering pass (which pins the routed model, so the hint has nothing left to decide).+ small = {"dept": {"type": "choice", "instructions": "pick",+ "criteria": {"a": "A", "b": "B", "c": "C", "d": "D", "e": "E"}}}+ router = ControlRouter(routed="multilingual")+ laya_shortlist(STATE, small, k=2, lang_guess="de", router=router, embed_fn=_tie_embed)+ ok("shortlist/route_sees_langguess", router.route_calls == [{"lang_guess": "de"}],+ repr(router.route_calls))+ ok("shortlist/predict_drops_langguess",+ router.predict_calls == [{"model": "multilingual"}], repr(router.predict_calls))+ router = ControlRouter()+ expect_tool_error("shortlist/pinned_plus_langguess",+ lambda: laya_shortlist(STATE, small, k=2, model="english",+ lang_guess="de", router=router,+ embed_fn=_tie_embed),+ "invalid_lang_guess")+ ok("shortlist/pinned_plus_langguess_no_call", router.predict_calls == [],+ repr(router.predict_calls))++ # laya_preset threads it through laya_predict (always auto, so never refused).+ def builder(attr):+ return {"probe": {"type": "noul", "instructions": "Does the `body` need a human?"}}+ router = ControlRouter()+ laya_preset("guard", STATE, lang_guess="de", router=router, preset_builder=builder)+ ok("preset/langguess_forwarded", router.predict_calls == [{"lang_guess": "de"}],+ repr(router.predict_calls))++ # Cross-surface drift guard: lang_guess is a real core routing control (serve forwards it as a+ # body control; the batch item overrides already name it) and Router.route/predict accept it, so+ # this layer can never advertise a keyword core would reject.+ from laya import serve as serve_mod++ ok("drift/langguess_in_body_controls", "lang_guess" in serve_mod.BODY_CONTROLS,+ repr(serve_mod.BODY_CONTROLS))+ ok("drift/langguess_in_batch_overrides", "lang_guess" in BATCH_ITEM_OVERRIDES,+ repr(BATCH_ITEM_OVERRIDES))+ for method in ("route", "predict"):+ params = inspect.signature(getattr(__import__("laya.router", fromlist=["Router"]).Router,+ method)).parameters+ ok("drift/router_%s_accepts_langguess" % method, "lang_guess" in params,+ repr(sorted(params)))++def test_min_confidence_control():"""`min_confidence` -- core's per-call abstention gate (#361) -- is reachable over MCP.@@ -2139,6 +2266,7 @@ test_controls_route()test_controls_shortlist()test_controls_preset()test_controls_signature_and_schema()+test_lang_guess_control()test_min_confidence_control()test_question_validation_matches_the_agent()test_a_bad_question_is_a_caller_error_not_a_server_fault()