router: enforce cloud-first direct path for top-level and monitor agents

This commit is contained in:
Apple
2026-02-18 10:26:29 -08:00
parent 5bca7fb79d
commit ef59cb0950

View File

@@ -48,6 +48,14 @@ except ImportError:
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
_CLOUD_FIRST_AGENT_SET = {
x.strip().lower()
for x in os.getenv(
"CLOUD_FIRST_AGENTS",
"daarwizz,helion,alateya,druid,nutra,agromatrix,greenfood,clan,eonarch,yaromir,soul,senpai,oneok,sofiia,monitor",
).split(",")
if x.strip()
}
TRUSTED_DOMAINS_CONFIG_PATH = os.getenv("TRUSTED_DOMAINS_CONFIG_PATH", "./trusted_domains.yml")
_trusted_domains_cache: Dict[str, Any] = {"mtime": None, "data": {}}
@@ -1451,6 +1459,8 @@ async def agent_infer(agent_id: str, request: InferRequest):
logger.exception(f"❌ CrewAI error: {e}, falling back to direct LLM")
default_llm = agent_config.get("default_llm", "qwen3:8b")
if agent_id.lower() in _CLOUD_FIRST_AGENT_SET and not (metadata or {}).get("force_local_model"):
default_llm = "cloud_deepseek"
routing_rules = router_config.get("routing", [])
default_llm = _select_default_llm(agent_id, metadata, default_llm, routing_rules)