--- name: model-cost-optimization description: Best practices for reducing expensive model token usage author: Hermes Agent tags: [cost-optimization, model-selection, efficiency] --- # Model Cost Optimization Guide ## When to Use Cheap vs Expensive Models ### Use Cheap Model For: - Simple factual questions and basic information - Short clarifications (under current thresholds) - Basic tool parameter preparation - Simple yes/no decisions - Routing questions like "which skill should I use?" ### Use Expensive Model For: - Complex multi-step reasoning - Code generation and debugging - Long-form content creation - Advanced planning and analysis - Creative tasks requiring originality ## User Query Optimization Tips 1. **Break down complex requests** into smaller, focused questions 2. **Be specific and direct** in your queries 3. **Ask one thing at a time** rather than multiple questions 4. **Use clear, concise language** to stay under character limits ## Current System Behavior The system automatically routes based on: - Message character count - Word count - Current thresholds are set to maximize cheap model usage while maintaining quality If you find responses from the cheap model are insufficient, you can: - Rephrase your query to be more complex (triggering expensive model) - Explicitly request detailed/complex analysis - Ask follow-up questions that naturally exceed thresholds ## Hermes Delegation Model Strategy When using `delegate_task` for subagents, configure a cheaper/faster model to save cost without sacrificing quality on simple tasks. ### Setup ```bash hermes config set delegation.provider deepseek hermes config set delegation.model deepseek-v4-flash ``` API key auto-resolves from `.env` (e.g. `DEEPSEEK_API_KEY`). ### Decision Rules — Delegate vs Handle Yourself | Delegate to cheap model | Keep in main (expensive) model | |---|---| | Translation, formatting, boilerplate | Complex architecture design | | Simple code snippets (≤1 function) | Multi-step debugging | | File batch operations (search, rename, extract) | Tasks needing deep context understanding | | Data extraction and parsing | Tasks requiring iterative back-and-forth | | Mechanical, well-scoped tasks | Ambiguous tasks with unclear requirements | **Litmus test:** Can you describe the task in one sentence and does it need no iterative feedback? → delegate to cheap model. ### Pitfalls - **Subagent self-reports are unreliable** — verify file creation, HTTP responses, and test results yourself after the subagent finishes - **Don't delegate tasks needing user clarification** — subagents can't use `clarify` - **Flash models are more verbose** — they may use more tokens per task but are still cheaper overall due to lower per-token pricing - **Don't delegate when context is critical** — subagents have no memory of your conversation, so pass all relevant file paths, error messages, and constraints explicitly ## Monitoring Effectiveness See `references/deepseek-v4-benchmark.md` for real-world speed/token benchmarks of DeepSeek models. Pay attention to response quality. If simple tasks are getting inadequate responses, the thresholds may need adjustment through configuration changes.