MTCLAW Intelligent Scheduling Architecture Documentation

MTCLAW Intelligent Scheduling Architecture Documentation

I. Zuobang Youbi × MTClaw Implementation Plan

1.1 Architecture Mapping: Why Zuobang Youbi Naturally Aligns with MTClaw

The core design of MTClaw is to add a "Front Desk Assistant" role in front of the backend large language model, achieving task distribution through a Function Router routing mechanism. Behind a single Provider interface, MTClaw combines multiple specialized subagents, achieving a 6.85x speedup on 50 real desktop control tasks with a 100% success rate in robust mode.

The existing architecture of Zuobang Youbi forms an isomorphic mapping with MTClaw:

| MTClaw Component | Zuobang Youbi Corresponding Capability | Mapping Relationship |

|---|---|---|

| Function Router | SmartLLMRouter Intent Recognition Engine | User natural language → Recognize intent → Route to corresponding digital employee |

| Front Desk Assistant | Intent Recognition + Rule Engine Front-end | Light tasks(

| Lightweight Model | Rule Engine (2,306 rules) | Zero inference cost for deterministic tasks, response

| Subagent | 34 Digital Employees | Each digital employee is a vertical domain expert Subagent |

| Completion Check | Rule Engine Result Validation | Determine if the tool/process can answer directly |

| Upstream LLM | On-device Model / General LLM | Called only for complex reasoning tasks |

1.2 Overall Architecture

┌─────────────────────────────────────────────────────────────────────────────┐
│                    左帮右臂 × MTClaw 整体架构                               │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  用户输入(自然语言)                                                        │
│       ↓                                                                     │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │              SmartLLMRouter 意图路由决策引擎                         │   │
│  │  (封装为MTClaw Function Router)                                   │   │
│  │                                                                     │   │
│  │  ┌─────────────────────────────────────────────────────────────┐   │   │
│  │  │  意图分类:判断"用户要做什么" → 匹配到对应数字员工             │   │   │
│  │  │  关键词匹配 → 路由到16种数字员工能力                           │   │   │
│  │  └─────────────────────────────────────────────────────────────┘   │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│       ↓                                                                     │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │                    Subagent层(34位数字员工)                        │   │
│  │                                                                     │   │
│  │  IT部: 系统运维师 | 数据导入员 | 数据巡检员 | 数据修复员             │   │
│  │  采购部: 采购助手 | 库存预警员 | 价格监控员 | 库存管家 | 供应商管家   │   │
│  │  市场部: 内容生成师 | 营销助手                                       │   │
│  │  财务部: 成本优化师 | 经营大脑                                       │   │
│  │  工程部: 变更分析师 | ECR审核员 | SCSAI工程师                         │   │
│  │  数据部: 报告分析师 | 数据估值师 | 数据书记员 | 数据管家             │   │
│  │  项目部: 目标追踪员 | 供应链管家                                     │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│       ↓                                                                     │
│  ┌─────────────────────────────────────────────────────────────────────┐   │
│  │                    执行层                                            │   │
│  │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐              │   │
│  │  │ 规则引擎     │  │ 端侧模型     │  │ SQLite私有库 │              │   │
│  │  │ (2,306条)  │  │ (Ollama)   │  │ (数据不出厂)│              │   │
│  │  └──────────────┘  └──────────────┘  └──────────────┘              │   │
│  └─────────────────────────────────────────────────────────────────────┘   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

1.3 Subagent设计与Function Router集成

MTClaw的Function Router通过functions.jsonl定义工具。左帮右臂将34位数字员工的核心能力封装为17个工具定义:

Tool Definition Example (System Health Check):

{"name":"system_health_check","description":"系统健康检查与运维巡检。检查数据库连接、SCSAI连接状态、模板覆盖率、规则一致性。","parameters":{"type":"object","properties":{"action":{"type":"string","enum":["status","full_check","database","SCSAI","templates","rules"]}},"required":["action"]}}

17个工具完整列表(对应数字员工能力):

| Tool Name | Corresponding Digital Employee | Employee ID | Trigger Scenario | Key Actions |

|---|---|---|---|---|

| system_health_check | Xiao Zhi - System Operations Engineer | DS-SYS-001 | System Health, Operations Inspection | status/full_check/database/SCSAI |

| inventory_monitor | Zhi-Inventory Monitor | DS-LOOP-001 | Inventory Level, Shortage Alert | check/low_stock/replenish/stats |

| price_monitor | Zhi-Price Monitor | DS-LOOP-001 | Price Fluctuation, Price Increase Alert | check/trend/alert/summary |

| vendor_review | Zhi-Vendor Steward | DS-VEN-001 | Vendor Performance Review | list/review/detail/stats |

| data_analysis_report | Zhi-Report Analyst | DS-REPORT-001 | Data Analysis, Visualization Report | generate/inventory/supplier/project |

| cost_optimizer | Zhi-Cost Optimizer | DS-COST-001 | BOM Cost Optimization | analyze/alternatives/report |

| procurement_assistant | Zhi-Procurement Assistant | DS-PROC-001 | Intelligent End-to-End Procurement | search/inquiry/compare/decision/order |

| document_agent | Zhi-Document Digital Employee | DS-DOC-001 | Document Generation and Q&A | generate/query/chat/inspect |

| business_dashboard | Zhi-Business Brain | DS-BUSINESS-001 | Daily Business Report, Executive Dashboard | daily/summary/customers/orders |

| data_inspection | Xiao Zhi - Data Inspector | DS-STAT-001 | Data Health Checkup | check/score/repair/report |

| supply_chain_manager | Xiao Zhi - Supply Chain Steward | DS-PROC-001 | Supply Chain Self-Healing | identify/repair/alert/status |

| content_generator | Xiao Zhi - Content Generator | DS-CONTENT-001 | Intelligent Content Creation | plan/create/optimize/publish |

| goal_tracker | Xiao Zhi - Goal Tracker | DS-LOOP-001 | Sales Goal Tracking | status/track/report/celebrate |

| change_analyst | Xiao Zhi - Change Analyst | DS-ECR-001 | Change Impact Analysis | identify/analyze/impact/sync |

| data_valuation | Xiao Zhi - Data Valuator | DS-COST-001 | Data Asset Valuation | valuate/cost/income/market/report |

| ecr_reviewer | Xiao Zhi - ECR Reviewer | DS-ECR-001 | ECR Change Review | list/detail/review/daily |

| data_import | Xiao Zhi - Data Importer | DS-SCSAI-001 | Data Import | import/preview/mapping/execute |

1.4 Four-Layer Task Distribution Mechanism

MTClaw's Function Router operates through a four-step process: "Front-end Assistant Judgment → Tool Execution → Completion Check → Upstream LLM". Left-Hand Right-Arm maps this as:

用户输入 → SmartLLMRouter意图识别引擎
    ↓
意图分类(关键词匹配)
    ↓
匹配对应数字员工能力
    ↓
┌─────────────────────────────────────────────────────────────┐
│  数字员工能力可用                 │  数字员工能力不可用         │
│  ↓                              │  ↓                        │
│  BossScheduler.runStaffOnce()   │  降级到CapabilityRuntime  │
│  ↓                              │  ↓                        │
│  规则引擎执行(轻任务<100ms)    │  规则引擎/LLM处理          │
│      ↓                          │                           │
│  执行成功?                      │                           │
│  ├─ 是 → 返回结果              │                           │
│  └─ 否 → 降级到CapabilityRuntime │                           │
│         ↓                       │                           │
│         返回结果                │                           │
└─────────────────────────────────────────────────────────────┘

"轻任务走轻链路"策略:

| Task Type | Execution Path | Response Time | Typical Scenarios |

|---|---|---|---|

| Deterministic Tasks | Direct execution by Digital Employee rule engine | | System health check, inventory alerts, supplier review |

| Semi-structured Tasks | CapabilityRuntime rule engine | | BOM cost analysis, data import, document generation |

| Complex Reasoning Tasks | MTCLAW/Ollama/DeepSeek | 5-30s | Code generation, complex Q&A, creative writing |


II. SmartLLMRouter Intelligent Dispatcher

2.1 Core Functions

FunctionDescription
Intent RoutingAutomatically routes user intents to 16 types of Digital Employee capabilities
Multi-level Fallback ChainDigital Employee → CapabilityRuntime → MTCLAW → Ollama → DeepSeek
Model Health CheckTracks consecutive failures, success rate for each model
Circuit BreakerAutomatically trips after 5 consecutive failures, auto-recovery after 60 seconds
Intelligent RetryExponential backoff retry on timeout/rate limit (max 3 times)
Response CachingCaches simple task results for 60 seconds to avoid duplicate calls
Auto DetectionAutomatically probes MTCLAW, Ollama, DeepSeek availability on startup
Remote ModeDisables all local models, uses only remote models

2.2 Intent Classification Mechanism

Intent Types and Keyword Mapping:

| Intent Type | Keyword Examples | Routing Target | Response Time |

|---|---|---|---|

| SYSTEM_HEALTH | system, operations, inspection, health, status, connection | XiaoZhi - System Operations Engineer |

| INVENTORY | inventory, shortage, replenishment, stock, inventory alert | XiaoZhi - Inventory Alert Specialist |

| PRICE | price monitoring, price increase, inquiry, quotation, cost | XiaoZhi - Price Monitoring Specialist |

| VENDOR | supplier, evaluation, performance, rating, supply | XiaoZhi - Supplier Steward |

| ANALYSIS | report, analysis, data, visualization, chart | XiaoZhi - Report Analyst |

| COST | cost, optimization, BOM, substitute material, cost reduction | XiaoZhi - Cost Optimization Specialist |

| PROCUREMENT | procurement, supplier, inquiry, quotation, order | XiaoZhi - Procurement Assistant |

| DOCUMENT | document, manual, help document, operation guide | XiaoZhi - Document Digital Employee |

| CONTENT | article, content, generation, official account, WeChat | XiaoZhi - Content Generator |

| GOAL | goal, sales tracking, achievement rate, progress tracking | XiaoZhi - Goal Tracker |

| CHANGE | change impact, BOM change, process linkage, ECO | XiaoZhi - Change Analyst |

| VALUATION | valuation, data valuation, asset valuation, capitalization | XiaoZhi - Data Valuation Specialist |

| ECR | ECR, change, review, change request | XiaoZhi - ECR Reviewer |

| DATA_IMPORT | import, upload, EXCEL, CSV | XiaoZhi - Data Import Specialist |

| DATA_INSPECTION | data inspection, health check, five-dimensional scoring | XiaoZhi - Data Inspector |

| SUPPLY_CHAIN | Supply Chain, Repair, Alert, Supply Chain Management | XiaoZhi - Supply Chain Assistant |

| TOOL | Open, Close, Settings, Volume, Brightness, WiFi | MTCLAW Tool Invocation | ~5-20s |

| GENERAL | Explain, What is, Why, Other General Questions | MTCLAW/Ollama/DeepSeek | ~5-30s |

2.3 Routing Priority

请求进入 SmartLLMRouter
    │
    ├─ 意图分类(关键词匹配)
    │       │
    │       ├─ SYSTEM_HEALTH → 小智-系统运维师 (BossScheduler)
    │       ├─ INVENTORY → 小智-库存预警员 (BossScheduler)
    │       ├─ PRICE → 小智-价格监控员 (BossScheduler)
    │       ├─ VENDOR → 小智-供应商管家 (BossScheduler)
    │       ├─ ANALYSIS → 小智-报告分析师 (BossScheduler)
    │       ├─ ... (其他12种数字员工能力)
    │       │       │
    │       │       └─ BossScheduler失败 → 降级到CapabilityRuntime
    │       │
    │       └─ TOOL/GENERAL → 通用路由(MTCLAW/Ollama/DeepSeek)
    │
    └─ 通用路由降级链路
            ├─ MTCLAW 可用?→ YES → MTCLAW 智能调度
            ├─ Ollama 健康?→ YES → Ollama 本地模型
            └─ DeepSeek 可用?→ YES → DeepSeek 云端模型

2.4 API 端点

| 端点 | 说明 |

|---|---|

| POST /api/llm/smart-chat | Intelligent Scheduling Invocation (Includes Intent Routing) |

| GET /api/llm/stats | Get Scheduling Statistics |

| POST /api/llm/router-config | Dynamically Update Routing Configuration (Remote Mode/Hybrid Mode) |

| GET /api/llm/detect | Probe for Available Services |


三、Model Fallback Mechanism

3.1 Complete Fallback Chain

┌─────────────────────────────────────────────────────────────────┐
│                    模型降级链路                                  │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌──────────────┐    不可用     ┌──────────────┐    不可用     │
│  │ 数字员工能力  │ ───────────→ │ Capability   │ ───────────→ │
│  │ (BossScheduler)│             │   Runtime    │               │
│  └──────────────┘               └──────────────┘               │
│         │                              │                       │
│         ↓                              ↓                       │
│  ┌──────────────────────────────────────────────────────────┐  │
│  │              MTCLAW → Ollama → DeepSeek(LLM降级链路)    │  │
│  │  端侧模型不可用时自动降级到云端API                           │  │
│  └──────────────────────────────────────────────────────────┘  │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

3.2 无本地模型场景处理

场景 1:无 GPU / CPU 机器

# local.yaml 配置
llm_router:
  enabled: true
  worker:
    enabled: false    # 禁用 Worker(端侧模型不可用)
  solver:
    enabled: true     # 启用 Solver(云端模型)
    model: "deepseek-chat"

场景 2:Ollama 服务未启动

  • MTCLAW request fails → Automatically fall back to Ollama
  • Ollama request fails → Automatically fall back to DeepSeek (if API Key is configured)

Scenario 3: No Models Available

  • SmartLLMRouter returns an error message, prompting the user to configure models

3.3 Automatic Probing Mechanism

// 启动时自动探测
this._autoDetectServices();

// 探测逻辑:
// 1. 尝试连接 MTCLAW(http://localhost:18790)
// 2. 尝试连接 Ollama(http://localhost:11434)
// 3. 尝试连接 DeepSeek(https://api.deepseek.com)
// 4. 根据探测结果自动构建降级链路

四、MTCLAW Function Router 配置

4.1 .function-router-config.json

{
  "listen_host": "0.0.0.0",
  "listen_port": 18790,
  "tools_base_dir": "~/.function-router/scripts",
  "fr_completion_check": {
    "enabled": true,
    "mode": "permissive"
  },
  "routing": {
    "base_url": "http://localhost:11434/v1",
    "model": "deepseek-r1:8b",
    "api_key": null
  },
  "upstream": {
    "base_url": "http://localhost:11434/v1",
    "model": "deepseek-r1:8b",
    "api_key": null
  },
  "functions_file": "functions.jsonl",
  "routing_timeout_s": 60.0,
  "debug_logging": {
    "enabled": true
  }
}

| 配置项 | 说明 |

|---|---|

| routing.model | Routing Decision Model (Lightweight Model) |

| upstream.model | Complex Task Processing Model (On-device Large Model) |

| api_key | Set to null for no authentication |

| functions_file | Tool Definition File Path |

4.2 Startup Method

# 启动 MTCLAW Function Router
python -m function_router --config .function-router-config.json

# 验证服务
curl -X POST http://127.0.0.1:18790/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"auto","messages":[{"role":"user","content":"hello"}]}'

五、环境变量配置(.env)

| 配置项 | 默认值 | 说明 |

|---|---|---|

| MTCLAW_ENABLED | true | Enable MTCLAW Acceleration |

| MTCLAW_BASE_URL | http://127.0.0.1:18790/v1 | MTCLAW Service Address |

| OLLAMA_ENDPOINT | http://localhost:11434/v1/chat/completions | Ollama Local Model Endpoint |

| OLLAMA_MODEL | deepseek-r1:8b | Local On-Device Model Name |

| LLM_REMOTE_ONLY | false | Use Remote Models Only |

| LLM_API_KEY | - | Solver Cloud API Key |


6. Typical Application Scenarios

Scenario 1: System Health Check

用户输入:"检查系统健康状态"
    │
    ├─ SmartLLMRouter 意图分类 → SYSTEM_HEALTH
    ├─ 路由到 小智-系统运维师 (DS-SYS-001)
    ├─ BossScheduler.runStaffOnce() 执行
    └─ 返回结果(<500ms)

场景 2:库存预警查询

用户输入:"查看库存预警"
    │
    ├─ SmartLLMRouter 意图分类 → INVENTORY
    ├─ 路由到 小智-库存预警员 (DS-LOOP-001)
    ├─ BossScheduler.runStaffOnce() 执行
    └─ 返回结果(<500ms)

场景 3:供应商绩效分析

用户输入:"分析供应商绩效"
    │
    ├─ SmartLLMRouter 意图分类 → VENDOR
    ├─ 路由到 小智-供应商管家 (DS-VEN-001)
    ├─ BossScheduler.runStaffOnce() 执行
    └─ 返回结果(<500ms)

场景 4:复杂代码生成

用户输入:"写一个Python函数来解析JSON数据"
    │
    ├─ SmartLLMRouter 意图分类 → GENERAL(无匹配数字员工)
    ├─ 通用路由 → MTCLAW 智能调度
    ├─ MTCLAW 判断任务复杂度 → 复杂任务
    ├─ 转发到 Ollama deepseek-r1:8b
    └─ 返回结果(~10-30s)

场景 5:无 GPU 环境运行

CPU 机器启动系统
    │
    ├─ SmartLLMRouter 检测 Ollama 不可用
    ├─ 自动禁用端侧模型
    ├─ 数字员工能力仍可正常使用(规则引擎)
    ├─ 复杂推理任务直接使用 DeepSeek
    └─ 系统正常运行

七、关键文件清单

| 文件路径 | 作用 |

|---|---|

| .env | Global Environment Variable Configuration |

| server/routes/llm.js | LLM API Route Handler |

| server/digital-staff/smart-llm-router.js | Intelligent Router (Core) |

| server/digital-staff/llm-router.js | LLM Router Base Logic |

| server/boss-scheduler/lite-scheduler.js | Digital Staff Scheduler |

| server/boss-scheduler/profiles/local.yaml | Digital Staff Configuration File |

| server/core/capability-runtime.js | Capability Runtime |

| server/core/capability-dispatcher.js | Capability Dispatcher |

| functions.jsonl | MTCLAW Tool Definitions |

| .function-router-config.json | MTCLAW Routing Configuration |


VIII. HICOOL Competition Demo Script

Demo Scenario:

  1. ✅ System Health Check → XiaoZhi - System Operations Engineer (
  2. ✅ Inventory Alert Query → XiaoZhi - Inventory Alert Officer (
  3. ✅ Supplier Performance Analysis → XiaoZhi - Supplier Steward (
  4. ✅ BOM Cost Optimization → XiaoZhi - Cost Optimization Specialist (
  5. ✅ Code Generation → MTCLAW/Ollama (~10-30s)

Running the Demo:

# 启动 MTCLAW
python -m function_router --config .function-router-config.json

# 启动服务器
node server.js

# 测试智能调度
curl -X POST https://ylxt.chat/api/llm/smart-chat \
  -H "Content-Type: application/json" \
  -d '{"prompt":"检查系统健康状态"}'

九、总结

当前系统已经实现了完整的 MTCLAW 智能调度架构,基于已有34位数字员工体系构建,而非生硬添加独立Subagent:

✅ Intent Routing - Automatically routes user intents to 16 types of digital employee capabilities

✅ Digital Employee Invocation - Invokes real digital employees via BossScheduler.runStaffOnce()

✅ Fallback Mechanism - Falls back to CapabilityRuntime when BossScheduler fails

✅ LLM Fallback Chain - MTCLAW → Ollama → DeepSeek

✅ Auto-Detection - Automatically probes available services on startup

✅ Remote Mode - Operates normally in GPU-less environments

✅ Tool Integration - 17 digital employee capabilities registered in functions.jsonl

✅ Response Speed - Digital employee task response

HICOOL Competition Highlights:

  • Fast: Digital employee task response
  • Accurate: 100% intent routing accuracy, automatically distributes to the most suitable digital employee
  • Comprehensive: Covers 16 major scenarios: system operations, inventory monitoring, price monitoring, supplier management, data analysis, cost optimization, procurement, documentation, content creation, goal tracking, change analysis, data valuation, ECR review, data import, data health check, supply chain management
  • Productized: Based on existing digital employee system, ready-to-use, can be packaged and installed directly
← 返回案例列表

Try 左帮右臂 Industrial Agent — your digital workforce

Available as a WeChat mini program, web app (ylxt.chat) and desktop client. Start from whichever fits your workflow.

🌐 Web App 💻 Desktop Download 📞 Call 189-8606-6876
WeChat mini program QR
Scan for the WeChat mini program
Share:
🤖 Try Now →
🤖
🎁