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.

Merge pull request #516 from aashish254/feat-mcp-decide

Nandakishor921915a0958f
diff --cc laya/mcp/tools.py
index 87efd2d5,2f4c3ad0..36e57ae0
--- a/laya/mcp/tools.py
+++ b/laya/mcp/tools.py
@@@ -155,36 -173,10 +180,21 @@@ def laya_predict
result = _run()
latency_ms = (time.perf_counter() - started) * 1000.0
- if not isinstance(result, dict):
- raise ToolError("internal_error", "predict returned non-object")
- # Router.predict and Agent.system_one both return the system_one payload,
- # which always carries an "answers" object (empty for empty questions).
- answers = _normalize_answers(result["answers"])
+ norm = _normalize_result(result)
+ answers = norm["answers"]
- routing = norm["routing"] or {"model": model_name, "repo": None, "reason": "explicit model"}
- device = _reading_device(router, agent, model_name, norm["routing"])
+ if auto_without_router:
+ routing = {"model": None, "repo": None, "reason": "auto routing without router"}
++ elif norm["routing"]:
++ routing = norm["routing"]
++ elif model_name == "auto":
++ # Agent.predict() returns the system_one payload, which carries no 'routing' key
++ # because the Agent itself does no routing. 'auto' is a routing directive, not a
++ # checkpoint name, so it must never be echoed back as the answering model (#444).
++ routing = {"model": None, "repo": None, "reason": "auto routing without router"}
+ else:
- routing = result.get("routing")
- if not routing:
- # Agent.predict() returns the system_one payload, which carries no
- # 'routing' key because the Agent itself does no routing. 'auto' is a
- # routing directive, not a checkpoint name, so it must never be echoed
- # back as the answering model (#444).
- if model_name == "auto":
- routing = {"model": None, "repo": None, "reason": "auto routing without router"}
- else:
- routing = {"model": model_name, "repo": None, "reason": "explicit model"}
- # Real device of the checkpoint that answered: Agent.device reflects a
- # silent GPU -> CPU fallback. Omitted when it cannot be read, rather than
- # guessed. With no routing decision there is no checkpoint to read it from.
- device = None
- if auto_without_router:
- pass
- elif model_name != "auto" and agent is not None:
- device = agent_device(agent)
- else:
- model_used = routing.get("model")
- if isinstance(model_used, str) and model_used:
- device = agent_device(router_agent(router, model_used))
++ routing = {"model": model_name, "repo": None, "reason": "explicit model"}
++ # With no routing decision there is no checkpoint to read the device from.
++ device = None if auto_without_router else _reading_device(router, agent, model_name, norm["routing"])
out: dict[str, Any] = {
"answers": answers,
"routing": routing,