Principle:42 evey Hermes plugins Cost Optimization
| Knowledge Sources | |
|---|---|
| Domains | Cost_Optimization, Model_Selection, Recommendations |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
A cost optimization pattern that analyzes per-model spending patterns, identifies the most expensive non-local models, and recommends switching to cheaper local alternatives for simple tasks based on prompt size analysis.
Description
Cost Optimization goes beyond monitoring to actively recommend spending reductions. The pattern:
- Identifies the top spender: The most expensive non-local model by total cost.
- Analyzes prompt sizes: If the top spender's average input is small (<2000 tokens), the tasks may not require its full capability.
- Recommends local alternatives: Suggests switching simple tasks to a known local model (e.g.,
qwen35-4b) that can handle small prompts at zero API cost. - Distinguishes local from paid: A set of known local model names is excluded from expensive-model recommendations (local models have no API cost).
The recommendation is conservative: it only suggests alternatives for non-local models, and only when the prompt analysis suggests the task is simple enough for a smaller model.
Usage
Use this principle when an agent system uses multiple models (local and paid) and wants to optimize spending. The recommendation engine provides actionable, data-driven suggestions rather than just reporting costs. Most effective when the agent can autonomously switch models based on recommendations.
Theoretical Basis
The recommendation logic:
Failed to parse (unknown function "\begin{cases}"): {\displaystyle \text{recommendation} = \begin{cases} \text{suggest local model for simple tasks} & \text{if top\_spender is non-local AND avg\_input < 2000} \\ \text{review if all calls need this model} & \text{if top\_spender is non-local AND avg\_input} \geq 2000 \\ \text{costs are efficient} & \text{if top\_spender is local or cost is minimal} \end{cases} }
# Abstract pattern (NOT real implementation)
LOCAL_MODELS = {"qwen35-4b", "qwen35-9b", "hermes3:8b"}
def recommend(models, total_cost):
if total_cost < 0.001:
return "Costs are minimal. Usage is efficient."
expensive = max(models, key=lambda m: m.cost)
if expensive.name not in LOCAL_MODELS:
if expensive.avg_input < 2000:
return f"{expensive.name} has small prompts. Use qwen35-4b for simple tasks."
else:
return f"{expensive.name} is top spender. Review if all calls need it."
The token ratio analysis (input_output_ratio) provides additional insight: a high ratio suggests the model is processing large inputs but producing small outputs, which may indicate inefficiency.