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): handle auto model in routing fallback

soumojit-D48d7eea12a8938
diff --git a/laya/mcp/tools.py b/laya/mcp/tools.py
index b3fc6b74..0f9bea6c 100644
--- a/laya/mcp/tools.py
+++ b/laya/mcp/tools.py
@@ -151,7 +151,15 @@ def laya_predict(
# 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"])
- routing = result.get("routing") or {"model": model_name, "repo": None, "reason": "explicit model"}
+ routing = result.get("routing")
+ if not routing:
+ # Agent.predict() doesn't return routing info; Router.predict() always does.
+ # When model_name is "auto" (routing directive, not a checkpoint), we cannot
+ # use it as the model name in the fallback.
+ 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.