Skip to main content

Overview

Shannon automatically selects the optimal LLM model for each task based on:
  1. Task complexity (analyzed during decomposition)
  2. Explicit tier requests (model_tier parameter)
  3. Model/provider overrides (model_override, provider_override)
  4. Priority rankings (defined in config/models.yaml)
  5. Budget constraints and token limits
This guide explains how model selection works and how to control it.

Model Tiers

Shannon organizes models into three tiers: Note: Percentages are target distributions, not enforced quotas. Actual usage depends on your workload.

Selection Flow

Model Selection Flow

Priority Ranking

Within each tier, models are ranked by priority (lower number = higher priority). Shannon attempts models in priority order until one succeeds. Example from config/models.yaml:
Fallback Behavior:
  • If priority 1 fails (rate limit, API error), Shannon tries priority 2
  • Continues until a model succeeds or all options exhausted
  • Failures are logged to orchestrator logs

Parameter Precedence

When multiple parameters specify model selection, the precedence is:
  1. model_override (highest priority) → Forces specific model
  2. provider_override → Limits to one provider’s models
  3. model_tier → Uses requested tier
  4. Auto-detected complexity (lowest priority) → Default behavior

Top-Level vs Context Parameters

Top-level parameters always override context parameters:

Usage Examples

Auto-Selection (Default)

Shannon analyzes complexity → Selects small tier → Uses gpt-5-nano-2025-08-07 (priority 1 in small tier)

Force Specific Tier

Uses large tier → gpt-5.1-2025-11-01 (priority 1 in large tier)

Override to Specific Model

Forces Anthropic Claude Sonnet, ignoring tier/priority.

Force Provider

Uses medium tier but only Anthropic modelsclaude-sonnet-4-5-20250929

Python SDK Examples

Cost Optimization Strategies

1. Start Small, Escalate if Needed

2. Provider-Specific Optimization

3. Session-Based Escalation

Research Tiered Model Architecture

Added in Shannon v0.3.0. This feature achieves 50-70% cost reduction compared to uniform large-model usage for research workflows.
Shannon’s research workflows automatically assign different model tiers to different stages of execution, using expensive models only where quality matters most.

How It Works

Configuration

The synthesis tier is configurable via synthesis_model_tier in your task request or config/shannon.yaml:
You can also override per-request:

Quick Research Strategy

The quick strategy forces all research agents to run in parallel using small models, optimizing for speed and cost over depth:

Cost Comparison

Example: 5-agent research workflow Result: 50-70% cost reduction with tiered architecture, maintaining synthesis quality.

Complexity Analysis

Shannon analyzes task complexity using several factors:
  • Query length and specificity
  • Number of sub-tasks identified
  • Tool usage requirements
  • Context depth needed
  • Reasoning intensity (keywords like “analyze”, “compare”, “synthesize”)
Complexity Thresholds (configurable):
  • < 0.3 → Small tier (simple Q&A, basic tasks)
  • 0.3 - 0.7 → Medium tier (multi-step, moderate reasoning)
  • > 0.7 → Large tier (complex research, heavy reasoning)

Monitoring & Debugging

Check Which Model Was Used

Response:

Prometheus Metrics

Orchestrator Logs

Look for:
  • "Model selected: gpt-5-nano-2025-08-07 (small tier, priority 1)"
  • "Falling back to priority 2: claude-haiku-4-5-20251001"
  • "Falling back to priority 3: grok-3-mini (xAI)"
  • "Tier override: user requested large → using gpt-5.1-2025-11-01"

Configuration

Model tiers and priorities are defined in config/models.yaml:
Selection Modes:
  • priority (default): Try models in priority order
  • round-robin: Distribute load evenly across same-priority models
  • least-cost: Always select cheapest model in tier

Troubleshooting

Issue: Wrong tier selected

Symptoms: Task uses medium tier when you expected small Solutions:
  1. Explicitly set model_tier: "small" in request
  2. Check complexity score in orchestrator logs
  3. Verify query isn’t triggering complexity heuristics (avoid words like “analyze deeply”)

Issue: Specific model not used

Symptoms: Request model_override: "gpt-5.1-2025-11-01" but gets different model Solutions:
  1. Verify model is in config/models.yaml under model_catalog
  2. Check API key for provider is set in .env (e.g., OPENAI_API_KEY, XAI_API_KEY)
  3. Verify model ID uses canonical name (not alias)
  4. Check orchestrator logs for fallback messages
  5. Ensure the model is available in your API plan (e.g., GPT-5.1 requires appropriate tier)

Issue: High costs

Symptoms: Costs higher than expected Solutions:
  1. Check actual tier distribution via Prometheus
  2. Add explicit model_tier: "small" to requests
  3. Review shannon_tier_drift_total for unwanted escalations
  4. Set MAX_COST_PER_REQUEST in .env to enforce budget

Issue: Rate limiting

Symptoms: Frequent 429 errors, slow fallback cascade Solutions:
  1. Add more providers to tier priority list
  2. Enable round-robin mode to distribute load
  3. Increase RATE_LIMIT_WINDOW for affected providers
  4. Consider cheaper providers (DeepSeek, Groq) as fallbacks

Best Practices

  1. Default to Auto-Selection: Let Shannon’s complexity analysis work
  2. Override Sparingly: Use model_override only when required
  3. Start Small: Set model_tier: "small" for cost-sensitive workloads
  4. Monitor Distribution: Track tier usage via metrics
  5. Configure Fallbacks: Ensure each tier has 3+ providers
  6. Test Priority Order: Verify your preferred models are priority 1
  7. Budget Enforcement: Set MAX_COST_PER_REQUEST for safety

Models API

List available models and pricing

Submit Task

Task submission with model parameters

Configuration

Environment variables and YAML config

Cost Tracking

View model usage and costs