用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/majiayu000/claude-skill-registry --skill model-fallback命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
LLM token logprobs and calibration. Per-decision confidence, ECE, Brier, reliability diagrams, low-confidence triage.
Analyze LLM token logprobs and calibration. Use for per-decision confidence, ECE, Brier scores, reliability diagrams, and low-confidence triage.
回顾最近 N 天的 Claude Code 使用记录——扫描原始会话数据,按主题分组汇总"我都做了什么",并从个人操作系统视角输出模式、风险与增删建议。当用户说 /recap、"看看我这几天做了什么"、"回顾一下我最近的会话"、"这两天我用 claude 干了啥"、"活动回顾" 时使用。
基于 SOC 职业分类
正在显示 SKILL.md
| name | model-fallback |
| description | 模型自动降级与故障切换。当主模型请求失败、超时、达到速率限制或配额耗尽时,自动切换到备用模型,确保服务连续性。支持多供应商、多优先级的智能模型选择,提供健康监控、自动重试和错误恢复机制。 |
| allowed-tools | Bash, Read, Write, Edit, Exec |
本技能提供完整的模型自动降级和故障切换解决方案,确保在主模型不可用时自动切换到备用模型,维持 AI 助手的持续服务能力。
根据任务类型和模型状态智能选择最合适的模型:
优先级顺序:
1. anapi/opus-4.5 # 最强能力,最高优先级
2. zai/glm-4.7 # 中文优化,性价比高
3. openrouter-vip/gpt-5.2-codex # 编码专用
4. github-copilot/claude-sonnet-4-5 # 免费备用
自动检测以下故障并触发切换:
智能重试策略:
重试配置:
最大重试次数: 3
初始延迟: 1000ms
最大延迟: 10000ms
退避倍数: 2.0
使用备用模型: true
重试时间线:
第1次失败 → 等待 1s → 重试
第2次失败 → 等待 2s → 重试
第3次失败 → 等待 4s → 切换模型
持续监控所有模型供应商的健康状态:
# 每5分钟检查一次
检查项目:
- API 端点连通性
- 响应时间
- 错误率
- 配额使用情况
配置文件:~/.openclaw/agents/main/agent/agent.json
{
"model": "anapi/opus-4.5",
"modelFallback": [
"zai/glm-4.7",
"openrouter-vip/gpt-5.2-codex",
"github-copilot/claude-sonnet-4-5"
],
"retry": {
"maxAttempts": 3,
"initialDelayMs": 1000,
"maxDelayMs": 10000,
"backoffMultiplier": 2.0,
"useFallbackOnFailure": true
}
}
# 启动后台监控
~/.openclaw/scripts/monitor-models.sh start
# 查看监控状态
~/.openclaw/scripts/monitor-models.sh status
# 停止监控
~/.openclaw/scripts/monitor-models.sh stop
# 运行降级检查脚本
~/.openclaw/scripts/model-fallback.sh
用户请求
↓
选择主模型 (anapi/opus-4.5)
↓
发送请求到 API
↓
成功 → 返回结果
用户请求
↓
选择当前模型
↓
发送请求 → 失败/超时
↓
重试 (最多3次)
↓
仍然失败?
↓
切换到备用模型 (zai/glm-4.7)
↓
发送请求
↓
成功 → 返回结果并记录
监控守护进程 (每5分钟)
↓
检查所有模型健康状态
↓
├─ 主模型健康 → 保持当前
└─ 主模型不健康 → 切换到最佳可用模型
↓
更新状态文件
↓
记录日志
{
"timeout": {
"switchModel": true,
"retryCount": 2,
"timeoutMs": 60000,
"fallbackTo": "zai/glm-4.7"
}
}
行为:
{
"rateLimit": {
"switchModel": true,
"cooldownMs": 60000,
"alert": true,
"fallbackTo": "zai/glm-4.7"
}
}
行为:
{
"quotaExceeded": {
"switchModel": true,
"alert": true,
"fallbackTo": "zai/glm-4.7",
"checkInterval": 3600000
}
}
行为:
{
"authenticationError": {
"switchModel": true,
"alert": true,
"disableModel": true
}
}
行为:
根据任务类型自动选择最合适的模型:
{
"routing": {
"strategy": "priority-fallback",
"rules": [
{
"name": "coding-task",
"match": {
"contentContains": ["代码", "code", "编程", "函数"]
},
"preferModels": [
"openrouter-vip/gpt-5.2-codex",
"anapi/opus-4.5"
]
},
{
"name": "chinese-task",
"match": {
"language": "zh"
},
"preferModels":
~/.openclaw/logs/model-fallback.log # 切换日志
~/.openclaw/logs/model-monitor.log # 监控日志
~/.openclaw/logs/model-status.json # 状态报告
# 查看切换日志
tail -f ~/.openclaw/logs/model-fallback.log
# 查看监控日志
tail -f ~/.openclaw/logs/model-monitor.log
# 查看所有日志
tail -f ~/.openclaw/logs/*.log
# 查看当前状态
~/.openclaw/scripts/monitor-models.sh status
# JSON 格式状态
cat ~/.openclaw/logs/model-status.json | python3 -m json.tool
模型降级切换脚本,负责:
用法:
~/.openclaw/scripts/model-fallback.sh
健康监控守护进程,负责:
用法:
~/.openclaw/scripts/monitor-models.sh {start|stop|restart|status|check}
测试脚本,用于:
用法:
~/clawd/scripts/test-model-fallback.sh
{
"model": "anapi/opus-4.5",
"modelFallback": [
"zai/glm-4.7",
"openrouter-vip/gpt-5.2-codex",
"github-copilot/claude-sonnet-4-5"
],
"retry": {
"maxAttempts": 3,
"initialDelayMs": 1000,
"maxDelayMs": 10000,
"backoffMultiplier": 2.0,
"useFallbackOnFailure": true
},
"errorHandling": {
"rateLimit": {
"switchModel": true,
"cooldownMs": 60000,
"alert":
检查:
# 查看配置文件
cat ~/.openclaw/agents/main/agent/agent.json | grep modelFallback
# 查看日志
tail -20 ~/.openclaw/logs/model-fallback.log
# 手动运行切换脚本
~/.openclaw/scripts/model-fallback.sh
检查:
# 查看进程
ps aux | grep monitor-models
# 查看PID文件
cat ~/.openclaw/logs/model-monitor.pid
# 重启监控
~/.openclaw/scripts/monitor-models.sh restart
检查:
# 查看状态报告
~/.openclaw/scripts/monitor-models.sh status
# 检查 API 密钥
cat ~/.openclaw/agents/main/agent/auth-profiles.json
# 测试网络连接
ping -c 3 anapi.9w7.cn
ping -c 3 open.bigmodel.cn
{
"retry": {
"maxAttempts": 5, // 增加重试次数
"initialDelayMs": 2000 // 增加初始延迟
}
}
为不同任务选择最快的模型:
{
"routing": {
"rules": [
{
"name": "quick-response",
"match": {
"priority": "speed"
},
"preferModels": [
"github-copilot/claude-sonnet-4-5", // 通常响应最快
"zai/glm-4.7"
]
}
]
}
}
配置完成后,模型降级功能会自动集成到 OpenClaw Gateway:
openclaw gateway restart
openclaw status | grep Model
journalctl -u openclaw-gateway -f | grep model
每周运行一次全面检查:
~/clawd/scripts/test-model-fallback.sh
每天查看切换日志:
grep "切换模型" ~/.openclaw/logs/model-fallback.log | tail -10
当添加新模型时,更新 agent.json:
{
"modelFallback": [
"anapi/opus-4.5",
"zai/glm-4.7",
"new-model-here", // 新模型
"github-copilot/claude-sonnet-4-5"
]
}
定期备份配置文件:
cp ~/.openclaw/agents/main/agent/agent.json \
~/.openclaw/agents/main/agent/agent.json.backup
~/.openclaw/agents/main/agent/agent.json - 主配置文件~/.openclaw/agents/main/agent/auth-profiles.json - API 密钥~/.openclaw/scripts/model-fallback.sh - 切换脚本~/.openclaw/scripts/monitor-models.sh - 监控脚本~/clawd/scripts/test-model-fallback.sh - 测试脚本~/clawd/docs/model-fallback-strategy.md - 技术文档当前配置的模型及其特性:
| 模型 | 供应商 | 优先级 | 最大Token | 特长 |
|---|---|---|---|---|
| opus-4.5 | anapi | 1 | 200k | 最强能力,视觉 |
| glm-4.7 | zai | 2 | 200k | 中文优化 |
| gpt-5.2-codex | openrouter-vip | 3 | 100k | 编码专用 |
| sonnet-4.5 | github-copilot | 4 | 200k | 免费备用 |