Adaptive Model Cascade 标志

Adaptive Model Cascade

社区
roedyrustam
adaptive-model-cascade

Model cascading & complexity-scored routing (Grok, Gemini, Claude) / Routing kaskade model & scoring kompleksitas (Grok, Gemini, Claude).

概览

发布者roedyrustam
代码仓库vibes-plug
技能名称adaptive-model-cascade
星标数
117
复刻数
27
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 roedyrustam 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Adaptive Model Cascade AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/roedyrustam/vibes-plug/tree/main/skills/adaptive-model-cascade
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/roedyrustam/vibes-plug.git /tmp/vibes-plug
mkdir -p .claude/skills
cp -r /tmp/vibes-plug/skills/adaptive-model-cascade .claude/skills/adaptive-model-cascade
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Adaptive Model Cascade,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Adaptive Model Cascade。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Adaptive Model Cascade 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

adaptive-model-cascade — vibes-plug Skill

English | Bahasa Indonesia


English

Orchestration & Integration

  • Upstream & Orchestration: zero-to-prod-orchestrator (Phase 4 AI integration), brainstorming, session-memory-manager.
  • FinOps & Routing Gateways: llm-finops-router (ROI tracking & cost caps), llm-observability-expert (cascade decisions, escalations, & tracing).
  • Frontier Models & Context Engineering: frontier-ai-models-expert (model tier scoring & benchmarks), context-window-engineer (context threshold overflow routing), kv-cache-prefix-optimizer (tier prefix cache locking).
  • Inference & Compute Orchestration: test-time-compute-optimizer (dynamic reasoning tokens during escalation), ai-llm-integration-expert, vercel-ai-sdk-expert (multi-provider cascade fallbacks).

Description

Production architecture for routing AI requests to the optimal model tier based on real-time task complexity assessment. Instead of sending every request to the most expensive frontier model, this skill implements an intelligent cascade across four late-2026 tiers:

  1. Fast Tier (Composer 2.5 Fast, Grok 4.6 High Fast): Rapid multi-file diff application, single-file AST scans, and simple syntax transformations.
  2. High Fast Tier (Grok 4.7 High Fast): Sub-second TTFT, real-time web groundings, and rapid test-assert loops.
  3. Medium Tier (Gemini 4 Argon Medium, GPT-5.6 Sol Medium, Claude Opus 5.5 Medium): 2M+ monolithic repository ingestion, strict JSON schema contracts, and balanced CRUD feature implementations.
  4. High Tier (Claude Sonnet 5.5 High, Claude Fable 5.1 High, Muse Wonder High, Gemini 4 Pro): Extended System-2 thinking (up to 64K tokens), formal verification, mission-critical architectural synthesis, and exploratory generative UI design.

Achieves 45–70% cost reduction for typical production workloads where 60–80% of tasks do not require maximum reasoning compute.

Trigger Conditions

Activate this skill when:

  • Running AI features in production with significant token spend (>$500/month).
  • Building applications where response latency and cost vary across task complexities.
  • Routing IDE and agent tasks dynamically across Grok 4.7, Composer 2.5, Gemini 4 Argon, GPT-5.6 Sol, Claude Sonnet 5.5, and Muse Wonder.
  • Designing self-healing escalation loops with fast heuristic quality gates.

Core Concepts & Patterns

1. The 4-Tier Model Cascade Architecture
USER REQUEST
      │
      ▼
┌───────────────────────────┐
│ COMPLEXITY SCORER         │  Classify task signals: FAST / HIGH_FAST / MEDIUM / HIGH
│ (Heuristic AST Evaluator) │
└─────────────┬─────────────┘
              │
              ├── FAST ─────────► Composer 2.5 Fast / Grok 4.6 ($0.10/1M)
              │                        │
              │                   ┌────▼────┐
              │                   │ QUALITY │  Pass? → Return response
              │                   │ GATE    │  Fail? → Escalate to HIGH_FAST
              │                   └─────────┘
              │
              ├── HIGH_FAST ────► Grok 4.7 High Fast ($0.50/1M)
              │                        │
              │                   ┌────▼────┐
              │                   │ QUALITY │  Pass? → Return response
              │                   │ GATE    │  Fail? → Escalate to MEDIUM
              │                   └─────────┘
              │
              ├── MEDIUM ───────► Gemini 4 Argon / GPT-5.6 Sol / Claude Opus 5.5 ($1.25/1M)
              │                        │
              │                   ┌────▼────┐
              │                   │ QUALITY │  Pass? → Return response
              │                   │ GATE    │  Fail? → Escalate to HIGH
              │                   └─────────┘
              │
              └── HIGH ─────────► Claude Sonnet 5.5 / Fable 5.1 / Muse Wonder ($3.00/1M)
                                       │
                                  Return response (Apex tier, no escalation)
2. Complexity Scorer (TypeScript Implementation)
typescript
export type CascadeTier = 'FAST' | 'HIGH_FAST' | 'MEDIUM' | 'HIGH';

export interface ComplexitySignals {
  tokenCount: number;
  hasCodeGeneration: boolean;
  requiresReasoning: boolean;
  hasMultiStep: boolean;
  domainSpecificity: 'general' | 'technical' | 'mission_critical';
  requiresCreativity: boolean;
  hasToolCalls: boolean;
  contextSize: number;
}

export function scoreComplexity(signals: ComplexitySignals): CascadeTier {
  let score = 0;

  if (signals.tokenCount > 2000) score += 1;
  if (signals.tokenCount > 8000) score += 2;
  if (signals.hasCodeGeneration) score += 2;
  if (signals.requiresReasoning) score += 2;
  if (signals.hasMultiStep) score += 1;
  if (signals.domainSpecificity === 'technical') score += 1;
  if (signals.domainSpecificity === 'mission_critical') score += 3;
  if (signals.requiresCreativity) score += 1;
  if (signals.hasToolCalls) score += 1;
  if (signals.contextSize > 100_000) score += 1;
  if (signals.contextSize > 500_000) score += 2;

  if (score <= 2) return 'FAST';
  if (score <= 5) return 'HIGH_FAST';
  if (score <= 8) return 'MEDIUM';
  return 'HIGH';
}
3. Heuristic Quality Gate Evaluator
typescript
export interface QualityGateResult {
  passed: boolean;
  score: number;
  reasons: string[];
}

export async function evaluateQualityGate(
  request: string,
  response: string,
  tier: CascadeTier
): Promise<QualityGateResult> {
  const checks: Array<{ name: string; passed: boolean }> = [];

  // 1. Substance check: response has meaningful length and is not a refusal
  const hasSubstance = response.trim().length > 50 && !response.includes("I cannot assist");
  checks.push({ name: 'substance', passed: hasSubstance });

  // 2. Code integrity check: if code was requested, verify balanced code fences
  if (/code|function|interface|class|implementation/i.test(request)) {
    const codeBlockCount = (response.match(/```/g) || []).length;
    const hasBalancedFences = codeBlockCount > 0 && codeBlockCount % 2 === 0;
    checks.push({ name: 'code_fences_balanced', passed: hasBalancedFences });
  }

  // 3. Anti-Slop verification: zero placeholder markers
  const hasNoPlaceholders = !/\/\/\s*(TODO|FIXME|\.\.\.rest of code)/i.test(response);
  checks.push({ name: 'no_placeholders', passed: hasNoPlaceholders });

  // 4. Tier-proportional length threshold
  const minExpectedLength = tier === 'FAST' ? 80 : tier === 'HIGH_FAST' ? 160 : tier === 'MEDIUM' ? 320 : 600;
  const adequateLength = response.length >= minExpectedLength;
  checks.push({ name: 'adequate_length', passed: adequateLength });

  const passedCount = checks.filter((c) => c.passed).length;
  const score = passedCount / checks.length;
  const failedReasons = checks.filter((c) => !c.passed).map((c) => c.name);

  return {
    passed: score >= 0.75,
    score,
    reasons: failedReasons,
  };
}
4. Cascade Router with Escalation
typescript
import { generateText } from 'ai';

export interface ModelTierConfig {
  tier: CascadeTier;
  modelId: string;
  provider: string;
  costPer1MTokens: number;
  fallbackModelId?: string;
  fallbackProvider?: string;
}

export const CASCADE_TIERS: ModelTierConfig[] = [
  { tier: 'FAST', modelId: 'composer-2.5-fast', provider: 'cursor', costPer1MTokens: 0.10, fallbackModelId: 'grok-4.6-high-fast', fallbackProvider: 'xai' },
  { tier: 'HIGH_FAST', modelId: 'grok-4.7-high-fast', provider: 'xai', costPer1MTokens: 0.50, fallbackModelId: 'grok-4.6-high-fast', fallbackProvider: 'xai' },
  { tier: 'MEDIUM', modelId: 'gemini-4-argon-medium', provider: 'google', costPer1MTokens: 0.80, fallbackModelId: 'gemini-3.8-flash', fallbackProvider: 'google' },
  { tier: 'HIGH', modelId: 'claude-sonnet-5.5-high', provider: 'anthropic', costPer1MTokens: 3.00, fallbackModelId: 'claude-opus-4.6', fallbackProvider: 'anthropic' },
];

export const AVAILABILITY_FALLBACK_MATRIX: Record<string, { fallbackModel: string; fallbackProvider: string; reason: string }> = {
  'gemini-4-argon-medium': { fallbackModel: 'gemini-3.8-flash', fallbackProvider: 'google', reason: 'Gemini 4 not yet available / regional quota limit' },
  'gemini-4-pro': { fallbackModel: 'gemini-3.8-flash', fallbackProvider: 'google', reason: 'Gemini 4 not yet available / regional quota limit' },
  'claude-opus-5.5-medium': { fallbackModel: 'claude-opus-4.6', fallbackProvider: 'anthropic', reason: 'Claude Opus 5.5 not yet available / tier fallback' },
};

const TIER_SEQUENCE: CascadeTier[] = ['FAST', 'HIGH_FAST', 'MEDIUM', 'HIGH'];

export async function cascadeRequest(
  prompt: string,
  signals: ComplexitySignals,
  systemPrompt: string,
  providerResolver: (provider: string, modelId: string) => any
): Promise<{ text: string; modelId: string; tier: CascadeTier; escalations: number; fellback: boolean }> {
  const initialTier = scoreComplexity(signals);
  const startIndex = TIER_SEQUENCE.indexOf(initialTier);
  let escalations = 0;

  for (let i = startIndex; i < CASCADE_TIERS.length; i++) {
    const tierConfig = CASCADE_TIERS[i];
    let activeModelId = tierConfig.modelId;
    let activeProvider = tierConfig.provider;
    let fellback = false;

    let result;
    try {
      result = await generateText({
        model: providerResolver(activeProvider, activeModelId),
        system: systemPrompt,
        prompt,
      });
    } catch (error) {
      // Automatic availability fallback (e.g. Gemini 4 -> Gemini 3.8 Flash, Claude Opus 5.5 -> Claude Opus 4.6)
      if (tierConfig.fallbackModelId && tierConfig.fallbackProvider) {
        console.warn(`[Cascade] Primary model ${activeModelId} unavailable, falling back to ${tierConfig.fallbackModelId}...`);
        activeModelId = tierConfig.fallbackModelId;
        activeProvider = tierConfig.fallbackProvider;
        fellback = true;
        result = await generateText({
          model: providerResolver(activeProvider, activeModelId),
          system: systemPrompt,
          prompt,
        });
      } else {
        throw error;
      }
    }

    const quality = await evaluateQualityGate(prompt, result.text, tierConfig.tier);

    if (quality.passed || i === CASCADE_TIERS.length - 1) {
      return {
        text: result.text,
        modelId: activeModelId,
        tier: tierConfig.tier,
        escalations,
        fellback,
      };
    }

    escalations++;
  }

  throw new Error('All cascade model tiers exhausted');
}

Best Practices

  1. Start with the Fastest Feasible Tier: Attempt surgical edits using Composer 2.5 Fast or Grok 4.7 High Fast before escalating to high-budget models.
  2. Deterministic Heuristic Quality Gates: Gates must evaluate in <50ms using regex and structural checks. Never call another LLM as a quality gate.
  3. Persist Escalation Telemetry: Track which prompt clusters frequently trigger escalations to automatically bias their future initial routing towards Medium or High.
  4. Lock KV-Cache Prefixes Across Tiers: Ensure all tiers share byte-identical system prompt prefixes to maximize upstream provider prompt caching.

Sovereign Execution, Token Efficiency & Invariants

DimensionSovereign Mandate & Deterministic Contract
Frontier Model CascadeMedium / High (GPT-5.6 Sol Medium, Gemini 4 Argon, Claude Sonnet 5.5 High, Grok 4.7 High Fast)
Availability FallbackGemini 4 Argon/Pro -> Gemini 3.8 Flash; Claude Opus 5.5 -> Claude Opus 4.6 (Zero unhandled missing-model errors)
KV-Cache & Token ProtocolPin static instructions & schemas at prompt prefix (kv-cache-prefix-optimizer); pass surgical CONTEXT_MAP.md slices (<250 tokens/call) during Swarm Fan-Out
SaaT CLI & MCP DispatchCLI: vibes skill exec adaptive-model-cascade <audit|eval|verify|generate|blueprint> / MCP: vibes_skill_dispatch, vibes_ast_query, vibes_compile_cache, vibes_optimize_budget, vibes_verify_gate
NFR & Anti-Slop InvariantsP99 API Gateway Latency < 85ms, OpenAPI 3.1 / TypeSpec strict schema parity, RFC 9457 Problem Details error contracts, Idempotency-Key enforcement; 100% complete zero-placeholder output verified via node scripts/check-anti-slop.js --strict


Bahasa Indonesia

Integrasi Orkestrasi

  • Hulu & Orkestrasi: zero-to-prod-orchestrator (Integrasi AI Fase 4), brainstorming, session-memory-manager.
  • FinOps & Gateway Routing: llm-finops-router (pelacakan ROI & batas biaya), llm-observability-expert (keputusan kaskade, eskalasi, & tracing).
  • Model Frontier & Rekayasa Konteks: frontier-ai-models-expert (skor tier model & tolok ukur), context-window-engineer (routing luapan batas konteks), kv-cache-prefix-optimizer (penguncian cache prefix tier).
  • Inferensi & Orkestrasi Komputasi: test-time-compute-optimizer (token penalaran dinamis saat eskalasi), ai-llm-integration-expert, vercel-ai-sdk-expert (fallback kaskade multi-provider).

Deskripsi

Arsitektur produksi untuk merutekan permintaan AI ke tier model optimal berdasarkan penilaian kompleksitas tugas secara real-time. Alih-alih mengirim seluruh prompt ke model termahal, skill ini menerapkan kaskade cerdas melintasi empat tier frontier akhir 2026:

  1. Tier Fast (Composer 2.5 Fast, Grok 4.6 High Fast): Aplikasi diff multi-file cepat, pemindaian AST satu file, dan transformasi sintaks sederhana.
  2. Tier High Fast (Grok 4.7 High Fast): TTFT sub-detik, pencarian web real-time, dan loop validasi tes kilat.
  3. Tier Medium (Gemini 4 Argon Medium, GPT-5.6 Sol Medium, Claude Opus 5.5 Medium): Ingesti repositori monolitik 2M+, kontrak skema JSON ketat, dan implementasi fitur standar.
  4. Tier High (Claude Sonnet 5.5 High, Claude Fable 5.1 High, Muse Wonder High, Gemini 4 Pro): Penalaran System-2 mendalam (hingga 64K token), verifikasi formal, arsitektur misi-kritis, dan desain UI generatif.

Kondisi Pemicu

Aktifkan skill ini ketika:

  • Menjalankan beban kerja produksi AI dengan biaya token substansial (>$500/bulan).
  • Merutekan tugas agen secara dinamis melintasi Grok 4.7, Composer 2.5, Gemini 4 Argon, GPT-5.6 Sol, Claude Sonnet 5.5, dan Muse Wonder.
  • Membangun alur eskalasi mandiri dengan gerbang kualitas berbasis heuristik instan.

Panduan Praktik Terbaik

  1. Mulai dari Tier Tercepat yang Memadai: Lakukan modifikasi kode dengan Composer 2.5 Fast atau Grok 4.7 High Fast sebelum beralih ke tier ber-budget tinggi.
  2. Gerbang Kualitas Heuristik Deterministic: Evaluasi kualitas harus selesai dalam <50ms menggunakan regex dan validasi struktur sintaks, tanpa panggilan LLM tambahan.
  3. Kunci Prefix KV-Cache: Pastikan prefix prompt sistem identik byte-for-byte antar-tier agar provider caching bekerja optimal.
  4. Protokol Pengalihan Ketersediaan (Availability Fallback):
    • Jika Gemini 4 Argon atau Gemini 4 Pro belum tersedia atau mengalami limit kuota regional, alihkan tugas secara instan ke Gemini 3.8 Flash (mempertahankan 1M+ konteks dan latensi sub-100ms).
    • Jika Claude Opus 5.5 belum tersedia, alihkan tugas secara instan ke Claude Opus 4.6 (mempertahankan ketelitian pemahaman arsitektur).
    • Pastikan agen tidak pernah berhenti karena error model tidak ditemukan.

Matriks Eksekusi Berdaulat, Efisiensi Token & Invarian

DimensiMandat Berdaulat & Kontrak Deterministik
Kaskade Model FrontierMedium / High (GPT-5.6 Sol Medium, Gemini 4 Argon, Claude Sonnet 5.5 High, Grok 4.7 High Fast)
Invarian Fallback KetersediaanGemini 4 Argon/Pro -> Gemini 3.8 Flash; Claude Opus 5.5 -> Claude Opus 4.6 (Bebas gagal saat model belum tersedia/kuota penuh)
Protokol Hemat Token & KV-CacheKunci instruksi & skema statis di prefix awal (kv-cache-prefix-optimizer); kirim potongan CONTEXT_MAP.md (<250 token/panggilan) saat Fan-Out
Eksekusi SaaT CLI & MCPCLI: vibes skill exec adaptive-model-cascade <audit|eval|verify|generate|blueprint> / MCP: vibes_skill_dispatch, vibes_ast_query, vibes_compile_cache, vibes_optimize_budget, vibes_verify_gate
Invarian NFR & Anti-SlopLatensi P99 API < 85ms, paritas skema ketat OpenAPI 3.1 / TypeSpec, kontrak error RFC 9457 Problem Details, penegakan Idempotency-Key; kode 100% tuntas tanpa placeholder diverifikasi melalui node scripts/check-anti-slop.js --strict

常见问题

Adaptive Model Cascade AI 技能有什么作用?

Model cascading & complexity-scored routing (Grok, Gemini, Claude) / Routing kaskade model & scoring kompleksitas (Grok, Gemini, Claude).

为什么在 TypingMind 中使用 Adaptive Model Cascade?

因为您只需安装一次,就能搭配任何模型使用。Adaptive Model Cascade 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Adaptive Model Cascade?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/roedyrustam/vibes-plug/tree/main/skills/adaptive-model-cascade。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Adaptive Model Cascade?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Adaptive Model Cascade 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Adaptive Model Cascade 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Adaptive Model Cascade AI 技能免费吗?

是的。roedyrustam 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇