| name | ari-model-selection |
| description | Intelligent model selection for autonomous operations โ balance capability, cost, and task requirements |
| triggers | ["model selection","which model","use sonnet","use opus","token cost","cost optimization","/ari-model"] |
ARI Model Selection โ Adaptive Intelligence
ARI autonomously selects the optimal model for each task based on:
- Task complexity โ Does this require deep reasoning or pattern matching?
- Token cost โ What's the budget impact?
- Quality requirements โ Is this production-critical or exploratory?
- Speed needs โ Is latency a factor?
Available Models
| Model | Strengths | Token Cost | Use When |
|---|
| Claude Opus 4.5 | Deep reasoning, complex analysis, nuanced judgment | Highest | Complex decisions, architecture, security |
| Claude Sonnet 4 | Balanced capability, good at coding | Medium | Most development tasks, code generation |
| Claude Haiku 4 | Fast, efficient, pattern matching | Lowest | Simple queries, formatting, quick checks |
Decision Framework
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MODEL SELECTION DECISION TREE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Is this task... โ
โ โ โ
โ โโโบ COMPLEX REASONING โ
โ โ โข Architecture decisions โ
โ โ โข Security analysis โ
โ โ โข Novel problem solving โ
โ โ โข Multi-step planning โ
โ โ โข Ambiguous requirements โ
โ โ โข Cross-domain synthesis โ
โ โ โโโบ Use: OPUS โ
โ โ โ
โ โโโบ STANDARD DEVELOPMENT โ
โ โ โข Code generation โ
โ โ โข Bug fixing โ
โ โ โข Test writing โ
โ โ โข Documentation โ
โ โ โข Code review โ
โ โ โข Refactoring โ
โ โ โโโบ Use: SONNET (default) โ
โ โ โ
โ โโโบ SIMPLE/ROUTINE โ
โ โข File operations โ
โ โข Formatting โ
โ โข Simple lookups โ
โ โข Status checks โ
โ โข Quick answers โ
โ โโโบ Use: HAIKU โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Implementation
When Spawning Agents (Task Tool)
{
description: "Design authentication system",
prompt: "...",
subagent_type: "feature-dev:code-architect",
model: "opus"
}
{
description: "Implement login endpoint",
prompt: "...",
subagent_type: "Bash",
model: "sonnet"
}
{
description: "Find all config files",
prompt: "...",
subagent_type: "Explore",
model: "haiku"
}
Decision Matrix
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TASK TYPE โ MODEL MAPPING โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ ALWAYS OPUS โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข Security audits and vulnerability analysis โ
โ โข Architectural decisions with long-term impact โ
โ โข Novel problem solving (no clear pattern to follow) โ
โ โข Constitutional/governance decisions โ
โ โข Complex multi-system integration design โ
โ โข Ambiguous requirements that need interpretation โ
โ โข High-stakes decisions (irreversible actions) โ
โ โข Cross-domain reasoning (e.g., code + security + UX) โ
โ โ
โ PREFER SONNET (default for most tasks) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข Code generation from clear specifications โ
โ โข Test writing โ
โ โข Bug fixing (standard bugs) โ
โ โข Documentation โ
โ โข Code review (standard review) โ
โ โข Refactoring with clear patterns โ
โ โข Feature implementation with defined scope โ
โ โข API development โ
โ โ
โ USE HAIKU (cost optimization) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข File exploration and search โ
โ โข Simple grep/glob operations โ
โ โข Formatting tasks โ
โ โข Status checks โ
โ โข Simple data transformations โ
โ โข Quick lookups in documentation โ
โ โข Syntax validation โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Cost-Benefit Analysis
Token Cost Ratios (Approximate)
Opus : โโโโโโโโโโโโโโโโโโโโ 100% (Baseline)
Sonnet : โโโโโโโโ 40% (2.5x cheaper)
Haiku : โโ 10% (10x cheaper)
ROI Calculation
function calculateModelValue(task: Task): ModelRecommendation {
const complexity = assessComplexity(task);
const qualityImpact = estimateQualityDelta(task, 'opus', 'sonnet');
const costDelta = estimateTokenCost(task, 'opus') - estimateTokenCost(task, 'sonnet');
if (qualityImpact > costDelta * costSensitivity) {
return { model: 'opus', reason: 'Quality gain justifies cost' };
} else if (complexity === 'low') {
return { model: 'haiku', reason: 'Simple task, maximize savings' };
} else {
return { model: 'sonnet', reason: 'Balanced capability/cost' };
}
}
Complexity Indicators
Signs Task Needs Opus
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ด OPUS INDICATORS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ LANGUAGE SIGNALS: โ
โ โข "Design the architecture for..." โ
โ โข "What's the best approach to..." โ
โ โข "Consider all the tradeoffs..." โ
โ โข "This is security-critical..." โ
โ โข "We need to think through..." โ
โ โข "The requirements are unclear..." โ
โ โ
โ TASK CHARACTERISTICS: โ
โ โข Multiple valid solutions exist โ
โ โข Requires weighing tradeoffs โ
โ โข Has long-term consequences โ
โ โข Involves multiple systems/domains โ
โ โข No clear pattern to follow โ
โ โข Stakeholder judgment required โ
โ โ
โ DOMAIN SIGNALS: โ
โ โข Security, authentication, authorization โ
โ โข Data migration with integrity requirements โ
โ โข Performance optimization (non-trivial) โ
โ โข Distributed systems coordination โ
โ โข Constitutional/governance decisions โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Signs Task Needs Sonnet
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ก SONNET INDICATORS (Default) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ LANGUAGE SIGNALS: โ
โ โข "Implement this feature..." โ
โ โข "Write a function that..." โ
โ โข "Fix this bug..." โ
โ โข "Add tests for..." โ
โ โข "Create a component that..." โ
โ โ
โ TASK CHARACTERISTICS: โ
โ โข Clear specification provided โ
โ โข Similar patterns exist in codebase โ
โ โข Standard coding task โ
โ โข Known solution approach โ
โ โข Contained scope (single file/module) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Signs Task Needs Haiku
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ข HAIKU INDICATORS (Cost-Optimized) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ LANGUAGE SIGNALS: โ
โ โข "Find all files that..." โ
โ โข "List the..." โ
โ โข "Check if..." โ
โ โข "Format this..." โ
โ โข "Search for..." โ
โ โ
โ TASK CHARACTERISTICS: โ
โ โข Single operation โ
โ โข Pattern matching / lookup โ
โ โข No judgment required โ
โ โข Deterministic output expected โ
โ โข Speed is more important than depth โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Autonomous Operation
When ARI operates autonomously (via scheduler, daemon, or spawned agents), it should:
1. Assess Each Task Before Execution
async function executeAutonomousTask(task: ScheduledTask) {
const analysis = analyzeTaskComplexity(task);
const model = selectModel(analysis);
this.eventBus.emit('audit:log', {
action: 'model_selected',
details: {
task: task.name,
model,
reason: analysis.reason,
estimatedTokens: analysis.estimatedTokens,
estimatedCost: analysis.estimatedCost,
}
});
return await executeWithModel(task, model);
}
2. Track Cost Over Time
interface CostTracking {
daily: {
opus: number;
sonnet: number;
haiku: number;
};
weekly: {
totalCost: number;
savingsFromDowngrade: number;
qualityImpactFromDowngrade: number;
};
}
3. Learn from Outcomes
function evaluateModelChoice(task: Task, result: Result, modelUsed: Model) {
const qualityMet = result.quality >= task.qualityThreshold;
const withinBudget = result.cost <= task.costBudget;
recordModelOutcome({
taskType: task.type,
model: modelUsed,
success: qualityMet && withinBudget,
actualCost: result.cost,
qualityScore: result.quality,
});
}
Practical Examples
Example 1: Security Audit (Opus Required)
{
description: "Security audit of auth system",
prompt: "Review the authentication implementation in src/kernel/... for security vulnerabilities",
subagent_type: "ari-security-auditor",
model: "opus"
}
Example 2: Code Generation (Sonnet Default)
{
description: "Implement /api/users endpoint",
prompt: "Create a CRUD endpoint for users following existing patterns in src/api/routes.ts",
subagent_type: "general-purpose",
model: "sonnet"
}
Example 3: File Search (Haiku for Speed)
{
description: "Find config files",
prompt: "Find all files matching *.config.ts",
subagent_type: "Explore",
model: "haiku"
}
Override Conditions
Always Upgrade to Opus
- Security-related tasks
- Irreversible operations (data deletion, migrations)
- Constitutional/governance decisions
- User-facing critical paths
- When previous attempt with Sonnet failed
Never Downgrade Below Sonnet
- Production deployments
- Database operations
- API design
- Error handling logic
Integration with ARI's Architecture
async function spawnAgent(config: AgentConfig): Promise<Agent> {
const model = determineOptimalModel({
taskType: config.subagent_type,
taskDescription: config.description,
taskPrompt: config.prompt,
previousAttempts: config.retryCount || 0,
});
return await Task({
...config,
model,
});
}
function determineOptimalModel(context: ModelSelectionContext): 'opus' | 'sonnet' | 'haiku' {
if (isSecuritySensitive(context)) return 'opus';
if (context.previousAttempts > 0) return upgradeModel(context.currentModel);
if (context.taskType === 'Explore' && isSimpleSearch(context.taskPrompt)) {
return 'haiku';
}
return 'sonnet';
}
Monitoring & Reporting
Cost Dashboard
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MODEL USAGE (Last 7 Days) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Opus โโโโโโโโโโโโโโโโโโโโ 30% โ $12.50 โ High-value tasks โ
โ Sonnet โโโโโโโโโโโโโโโโโโโโ 55% โ $8.25 โ Standard work โ
โ Haiku โโโโโโโโโโโโโโโโโโโโ 15% โ $0.50 โ Quick operations โ
โ โ
โ Total: $21.25 (vs. $45.00 if all Opus = 53% savings) โ
โ โ
โ Quality Impact: None detected (all quality gates passed) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Key Principles
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ 1. DEFAULT TO SONNET โ
โ Most tasks don't need Opus. Start at Sonnet. โ
โ โ
โ 2. UPGRADE FOR COMPLEXITY โ
โ When judgment, tradeoffs, or security matter โ Opus. โ
โ โ
โ 3. DOWNGRADE FOR SPEED โ
โ Simple searches, lookups, formatting โ Haiku. โ
โ โ
โ 4. TRACK AND LEARN โ
โ Monitor outcomes. Adjust thresholds based on results. โ
โ โ
โ 5. WHEN IN DOUBT, UPGRADE โ
โ Quality failures are more expensive than token costs. โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ