Adaptive Model Cascade logo

Adaptive Model Cascade

Community
roedyrustam
adaptive-model-cascade

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

Overview

Publisherroedyrustam
Repositoryvibes-plug
Skill nameadaptive-model-cascade
Stars
117
Forks
27
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by roedyrustam on GitHub. Read the source before you install it.

Installation

Install the Adaptive Model Cascade AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/roedyrustam/vibes-plug/tree/main/skills/adaptive-model-cascade
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Adaptive Model Cascade in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Adaptive Model Cascade on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Adaptive Model Cascade is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

Frequently asked questions

What does the Adaptive Model Cascade AI skill do?

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

Why use Adaptive Model Cascade on TypingMind?

Because you install it once and use it with any model. Adaptive Model Cascade is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Adaptive Model Cascade in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/roedyrustam/vibes-plug/tree/main/skills/adaptive-model-cascade. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Adaptive Model Cascade?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Adaptive Model Cascade?

As many as you like. As long as a model supports skills, you can use Adaptive Model Cascade with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Adaptive Model Cascade AI skill free?

Yes. It is published on GitHub by roedyrustam under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇