Skip to content
Back to search

model-hierarchy-skill

OpenClaw skill for cost-optimized model routing based on task complexity

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/zscole--model-hierarchy-skill/badge.svg)](/listings/zscole--model-hierarchy-skill)

HTML

<a href="/listings/zscole--model-hierarchy-skill"><img src="/api/listings/zscole--model-hierarchy-skill/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

OpenClaw

# Copy SKILL.md to your skills directory
cp SKILL.md ~/.openclaw/skills/model-hierarchy/SKILL.md

# Restart gateway to pick up the skill
openclaw gateway restart

Claude Code / Codex

Add to your `CLAUDE.md` or project instructions:

## Model Routing

Before executing tasks, classify complexity:
- ROUTINE (file ops, lookups, formatting) → Use cheapest model
- MODERATE (code, summaries, analysis) → Use mid-tier model  
- COMPLEX (debugging, architecture, failures) → Use premium model

When spawning sub-agents, default to cheap models unless task requires more.

Other Agent Systems

See [SKILL.md](SKILL.md) for the full classification rules and integration examples.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 280 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ---
  2. name: model-hierarchy
  3. description: >
  4. Cost-optimize AI agent operations by routing tasks to appropriate models based on complexity.
  5. Use this skill when: (1) deciding which model to use for a task, (2) spawning sub-agents,
  6. (3) considering cost efficiency, (4) the current model feels like overkill for the task.
  7. Triggers: "model routing", "cost optimization", "which model", "too expensive", "spawn agent".
  8. ---
  9. # Model Hierarchy
  10. Route tasks to the cheapest model that can handle them. Most agent work is routine.
  11. ## Core Principle
  12. **80% of agent tasks are janitorial.** File reads, status checks, formatting, simple Q&A. These don't need expensive models. Reserve premium models for problems that actually require deep reasoning.
  13. ## Model Tiers
  14. ### Tier 1: Cheap ($0.10-0.50/M tokens)
  15. | Model | Input | Output | Best For |
  16. |-------|-------|--------|----------|
  17. | DeepSeek V3 | $0.14 | $0.28 | General routine work |
  18. | GPT-4o-mini | $0.15 | $0.60 | Quick responses |
  19. | Claude Haiku | $0.25 | $1.25 | Fast tool use |
  20. | Gemini Flash | $0.075 | $0.30 | High volume |
  21. | GLM 5 (Zhipu) | (OpenRouter Z.AI) | (OpenRouter Z.AI) | Routine + moderate text; 200K context; **text-only** — do not use for image/vision |
  22. | Kimi K2.5 (Moonshot) | $0.45 | $2.25 | Routine + moderate; 262K context; **multimodal (text + image + video)** |
  23. **Text-only models (e.g. GLM 5):** Do not use for any task that requires image input or vision — no photo analysis, screenshots, image-generation tools, or document/chart vision. Route to a vision-capable model (e.g. Kimi K2.5, GPT-4o, Gemini, Claude with vision, GLM-4.5V/4.6V).
  24. **Vision-capable Tier 1/2 (e.g. Kimi K2.5):** Use for routine or moderate tasks that may involve images — screenshots, photo analysis, docs, image-generation orchestration — without moving to premium vision models.
  25. ### Tier 2: Mid ($1-5/M tokens)
  26. | Model | Input | Output | Best For |
  27. |-------|-------|--------|----------|
  28. | Claude Sonnet | $3.00 | $15.00 | Balanced performance |
  29. | GPT-4o | $2.50 | $10.00 | Multimodal tasks |
  30. | Gemini Pro | $1.25 | $5.00 | Long context |
  31. ### Tier 3: Premium ($10-75/M tokens)
  32. | Model | Input | Output | Best For |
  33. |-------|-------|--------|----------|
  34. | Claude Opus | $15.00 | $75.00 | Complex reasoning |
  35. | GPT-4.5 | $75.00 | $150.00 | Frontier tasks |
  36. | o1 | $15.00 | $60.00 | Multi-step reasoning |
  37. | o3-mini | $1.10 | $4.40 | Reasoning on budget |
  38. *Prices as of Feb 2026. Check provider docs for current rates.*
  39. ## Task Classification
  40. Before executing any task, classify it:
  41. ### ROUTINE → Use Tier 1
  42. **Requires image/vision** → Do not assign to text-only models (GLM 5, etc.). Use a vision-capable model from Tier 1/2 or 3 (e.g. Kimi K2.5, GPT-4o, Gemini, Claude, GLM-4.5V).
  43. Characteristics:
  44. - Single-step operations
  45. - Clear, unambiguous instructions
  46. - No judgment required
  47. - Deterministic output expected
  48. Examples:
  49. - File read/write operations
  50. - Status checks and health monitoring
  51. - Simple lookups (time, weather, definitions)
  52. - Formatting and restructuring text
  53. - List operations (filter, sort, transform)
  54. - API calls with known parameters
  55. - Heartbeat and cron tasks
  56. - URL fetching and basic parsing
  57. ### MODERATE → Use Tier 2
  58. Characteristics:
  59. - Multi-step but well-defined
  60. - Some synthesis required
  61. - Standard patterns apply
  62. - Quality matters but isn't critical
  63. Examples:
  64. - Code generation (standard patterns)
  65. - Summarization and synthesis
  66. - Draft writing (emails, docs, messages)
  67. - Data analysis and transformation
  68. - Multi-file operations
  69. - Tool orchestration
  70. - Code review (non-security)
  71. - Search and research tasks
  72. ### COMPLEX → Use Tier 3
  73. Characteristics:
  74. - Novel problem solving required
  75. - Multiple valid approaches
  76. - Nuanced judgment calls
  77. - High stakes or irreversible
  78. - Previous attempts failed
  79. Examples:
  80. - Multi-step debugging
  81. - Architecture and design decisions
  82. - Security-sensitive code review
  83. - Tasks where cheaper model already failed
  84. - Ambiguous requirements needing interpretation
  85. - Long-context reasoning (>50K tokens)
  86. - Creative work requiring originality
  87. - Adversarial or edge-case handling
  88. ## Decision Algorithm
  89. ```
  90. function selectModel(task):
  91. # Rule 1: Vision override (Tier 1/2 includes text-only models)
  92. if task.requiresImageInput or task.requiresVision:
  93. return VISION_CAPABLE_MODEL # e.g. Kimi K2.5, GPT-4o, Gemini, Claude; do not use GLM 5 or other text-only
  94. # Rule 2: Escalation override
  95. if task.previousAttemptFailed:
  96. return nextTierUp(task.previousModel)
  97. # Rule 3: Explicit complexity signals
  98. if task.hasSignal("debug", "architect", "design", "security"):
  99. return TIER_3
  100. if task.hasSignal("write", "code", "summarize", "analyze"):
  101. return TIER_2
  102. # Rule 4: Default classification
  103. complexity = classifyTask(task)
  104. if complexity == ROUTINE:
  105. return TIER_1
  106. elif complexity == MODERATE:
  107. return TIER_2
  108. else:
  109. return TIER_3
  110. ```
  111. ## Behavioral Rules
  112. ### For Main Session
  113. 1. **Default to Tier 2** for interactive work
  114. 2. **Suggest downgrade** when doing routine work: "This is routine - I can handle this on a cheaper model or spawn a sub-agent."
  115. 3. **Request upgrade** when stuck: "This needs more reasoning power. Switching to [premium model]."
  116. ### For Sub-Agents
  117. 1. **Default to Tier 1** unless task is clearly moderate+
  118. 2. **Batch similar tasks** to amortize overhead
  119. 3. **Report failures** back to parent for escalation
  120. ### For Automated Tasks
  121. 1. **Heartbeats/monitoring** → Always Tier 1
  122. 2. **Scheduled reports** → Tier 1 or 2 based on complexity
  123. 3. **Alert responses** → Start Tier 2, escalate if needed
  124. ## Communication Patterns
  125. When suggesting model changes, use clear language:
  126. **Downgrade suggestion:**
  127. > "This looks like routine file work. Want me to spawn a sub-agent on DeepSeek for this? Same result, fraction of the cost."
  128. **Upgrade request:**
  129. > "I'm hitting the limits of what I can figure out here. This needs Opus-level reasoning. Switching up."
  130. **Explaining hierarchy:**
  131. > "I'm running the heavy analysis on Sonnet while sub-agents fetch the data on DeepSeek. Keeps costs down without sacrificing quality where it matters."
  132. ## Cost Impact
  133. Assuming 100K tokens/day average usage:
  134. | Strategy | Monthly Cost | Notes |
  135. |----------|--------------|-------|
  136. | Pure Opus | ~$225 | Maximum capability, maximum spend |
  137. | Pure Sonnet | ~$45 | Good default for most work |
  138. | Pure DeepSeek | ~$8 | Cheap but limited on hard problems |
  139. | **Hierarchy (80/15/5)** | **~$19** | Best of all worlds |
  140. The 80/15/5 split:
  141. - 80% routine tasks on Tier 1 (~$6)
  142. - 15% moderate tasks on Tier 2 (~$7)
  143. - 5% complex tasks on Tier 3 (~$6)
  144. **Result: 10x cost reduction vs pure premium, with equivalent quality on complex tasks.**
  145. ## Integration Examples
  146. ### OpenClaw
  147. ```yaml
  148. # config.yml - set default model
  149. model: anthropic/claude-sonnet-4
  150. # In session, switch models
  151. /model opus # upgrade for complex task
  152. /model deepseek # downgrade for routine
  153. # Spawn sub-agent on cheap model
  154. sessions_spawn:
  155. task: "Fetch and parse these 50 URLs"
  156. model: deepseek
  157. ```
  158. **OpenRouter (Tier 1 with vision or text-only):**
  159. ```yaml
  160. # Tier 1 with vision — Kimi K2.5 (multimodal)
  161. model: openrouter/moonshotai/kimi-k2.5
  162. # Heartbeats, cron, image-involving tasks: K2.5 handles text and vision.
  163. # Tier 1 text-only — GLM 5 (no vision)
  164. # model: openrouter/z-ai/glm-5 # exact ID TBD on OpenRouter Z.AI
  165. # Routine text-only only; for image tasks use Kimi K2.5 or another vision-capable model.
  166. ```
  167. ### Claude Code
  168. ```
  169. # In CLAUDE.md or project instructions
  170. When spawning background agents, use claude-3-haiku for:
  171. - File operations
  172. - Simple searches
  173. - Status checks
  174. Reserve claude-sonnet-4 for:
  175. - Code generation
  176. - Analysis tasks
  177. ```
  178. ### General Agent Systems
  179. ```python
  180. def get_model_for_task(task_description: str) -> str:
  181. routine_signals = ['read', 'fetch', 'check', 'list', 'format', 'status']
  182. complex_signals = ['debug', 'architect', 'design', 'security', 'why']
  183. desc_lower = task_description.lower()
  184. if any(signal in desc_lower for signal in complex_signals):
  185. return "claude-opus-4"
  186. elif any(signal in desc_lower for signal in routine_signals):
  187. return "deepseek-v3"
  188. else:
  189. return "claude-sonnet-4"
  190. ```
  191. ## Anti-Patterns
  192. **DON'T:**
  193. - Run heartbeats on Opus
  194. - Use premium models for file I/O
  195. - Keep expensive model when task is clearly routine
  196. - Spawn sub-agents on premium models by default
  197. - Use GLM 5 (or any text-only Tier 1/2 model) for image/vision tasks — e.g. photo analysis, screenshot understanding, image-generation skills, or any tool that takes image input
  198. **DO:**
  199. - Start mid-tier, adjust based on task
  200. - Spawn helpers on cheapest viable model
  201. - Escalate explicitly when stuck
  202. - Track cost per task type to optimize further
  203. ## Extending This Skill
  204. To customize for your use case:
  205. 1. **Adjust tier definitions** based on your provider/budget
  206. 2. **Add domain-specific signals** to classification rules
  207. 3. **Track actual complexity** vs predicted to improve heuristics
  208. 4. **Set budget alerts** to catch runaway premium usage
README.md · README · 88 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # model-hierarchy-skill
  2. Cost-optimize AI agent operations by routing tasks to appropriate models based on complexity.
  3. ## The Problem
  4. Most AI agents run everything on expensive models. But 80% of agent tasks are routine: file reads, status checks, formatting, simple Q&A. You're paying $15-75/M tokens for work that $0.14/M tokens handles fine.
  5. ## The Solution
  6. A skill that teaches agents to classify tasks and route them to the cheapest model that can handle them:
  7. | Task Type | Model Tier | Cost | Examples |
  8. |-----------|------------|------|----------|
  9. | Routine (80%) | Cheap | $0.14-0.50/M | File ops, status checks, formatting |
  10. | Moderate (15%) | Mid | $1-5/M | Code gen, summaries, drafts |
  11. | Complex (5%) | Premium | $10-75/M | Debugging, architecture, novel problems |
  12. **Result: ~10x cost reduction** with equivalent quality on the tasks that matter.
  13. ## Quick Start
  14. ### OpenClaw
  15. ```bash
  16. # Copy SKILL.md to your skills directory
  17. cp SKILL.md ~/.openclaw/skills/model-hierarchy/SKILL.md
  18. # Restart gateway to pick up the skill
  19. openclaw gateway restart
  20. ```
  21. ### Claude Code / Codex
  22. Add to your `CLAUDE.md` or project instructions:
  23. ```markdown
  24. ## Model Routing
  25. Before executing tasks, classify complexity:
  26. - ROUTINE (file ops, lookups, formatting) → Use cheapest model
  27. - MODERATE (code, summaries, analysis) → Use mid-tier model
  28. - COMPLEX (debugging, architecture, failures) → Use premium model
  29. When spawning sub-agents, default to cheap models unless task requires more.
  30. ```
  31. ### Other Agent Systems
  32. See [SKILL.md](SKILL.md) for the full classification rules and integration examples.
  33. ## Cost Math
  34. Assuming 100K tokens/day:
  35. | Strategy | Monthly Cost |
  36. |----------|--------------|
  37. | Pure Opus | ~$225 |
  38. | Pure Sonnet | ~$45 |
  39. | Hierarchy (80/15/5) | ~$19 |
  40. ## Testing
  41. ```bash
  42. # Run classification tests
  43. python -m pytest tests/ -v
  44. # Test specific scenarios
  45. python tests/test_classification.py
  46. ```
  47. ## Files
  48. ```
  49. model-hierarchy-skill/
  50. ├── SKILL.md # The skill (install this)
  51. ├── README.md # You're here
  52. ├── tests/
  53. │ ├── test_classification.py
  54. │ └── scenarios.json
  55. └── examples/
  56. ├── openclaw.md
  57. └── claude-code.md
  58. ```
  59. ## License
  60. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.