Skip to main content
Software Engineering

Workshop 06: Mastering AI-Powered Coding Agents (2026 Edition)

26 Modules
Chapter 18: 5.b: Understanding Model & Tool Choices (June 2026)69%

5.b: Understanding Model & Tool Choices (June 2026)

Choosing the right model for an AI coding task is one of the most impactful decisions you make on a daily basis. The model determines quality, speed, cost, and context capacity. In mid-2026, the two major provider families for coding agents are Anthropic's Claude models and OpenAI's GPT/o-series models.

The Claude Model Family (Anthropic)

Claude Code defaults to Opus 4.8 but offers a full model family accessible via configuration or the /fast toggle.

Claude Models for Coding (June 2026)

ModelIDContextStrengthsBest For
Fable 5claude-fable-5200K tokensLatest and most capable; strongest on novel problems and creative solutionsComplex architecture, novel features, research-grade tasks
Opus 4.8claude-opus-4-8200K tokensTop-tier reasoning and instruction following; Claude Code defaultMulti-file refactoring, complex bug fixing, code review
Sonnet 4.6claude-sonnet-4-6200K tokensBest balance of speed, quality, and costDaily coding tasks, routine refactoring, test generation
Haiku 4.5claude-haiku-4-5-20251001200K tokensFastest and cheapest; still highly capable for straightforward tasksHigh-volume operations, quick lookups, simple fixes

Model Selection in Claude Code

# Default: uses Opus 4.8
claude

# Start with a specific model
claude --model claude-sonnet-4-6

# Toggle to Sonnet mid-session for speed
# (inside a Claude Code session)
/fast

# Toggle back to Opus for a complex task
/fast

Claude Model Selection Strategy

Matching model to complexity: Fable 5 for novel design, Opus 4.8 as the default, Sonnet 4.6 for routine work, Haiku 4.5 for simple bulk operations

Practical guidance:

  • Start a session with Opus 4.8 (the default) for any non-trivial task
  • Switch to Sonnet 4.6 via /fast when iterating on implementation details or generating tests
  • Use Haiku 4.5 for bulk operations (e.g., adding JSDoc comments to 50 functions)
  • Reserve Fable 5 for tasks where you want the absolute best output quality

Pricing

Model pricing changes frequently. Check console.anthropic.com for current per-token rates. The general ordering from most to least expensive is: Fable 5 > Opus 4.8 > Sonnet 4.6 > Haiku 4.5.

Claude Code displays session costs via the /cost command.

The OpenAI Model Family

OpenAI Codex CLI supports multiple models via the --model flag.

OpenAI Models for Coding (June 2026)

ModelStrengthsBest For
o3Deep reasoning, chain-of-thought, strongest on complex logicAlgorithms, system design, debugging subtle issues
GPT-4oFast, capable, multi-modal (text + image)General coding, UI implementation from screenshots
o4-miniFast reasoning at lower costInteractive CLI use, quick iterations
codex-mini-latestOptimised for Codex CLI specificallyDefault for Codex CLI terminal tasks
codex-1Fine-tuned for software engineering (o3 architecture)Codex Cloud Agent (within ChatGPT)

Model Selection in Codex CLI

# Default model (codex-mini-latest)
codex "Add input validation"

# Use GPT-4o for a more complex task
codex --model gpt-4o "Architect a caching layer for the API"

# Use o3 for a hard algorithmic problem
codex --model o3 "Optimise the pathfinding algorithm for large graphs"

# Use o4-mini for quick, cheap tasks
codex --model o4-mini "Format all files with Prettier"

OpenAI Pricing

Check platform.openai.com for current per-token rates. The general ordering from most to least expensive is: o3 > GPT-4o > codex-1 > o4-mini > codex-mini.

Open-Weight and Local Models

For privacy-sensitive work or offline use, both Codex CLI and Aider support local models via Ollama or other OpenAI-compatible APIs.

ModelProviderStrengthsLimitations
DeepSeek Coder V3DeepSeek (or local)Strong coding, open weightsRequires significant GPU for local
CodeLlamaMeta (via Ollama)Good for common languagesSmaller context, less capable than frontier
MixtralMistral (via Ollama)Fast, decent codingNot as strong as GPT-4o/Claude for complex tasks
# Using a local model with Codex CLI
codex --provider ollama --model deepseek-coder-v3 "Explain this function"

# Using a local model with Aider
aider --model ollama/deepseek-coder-v3

Local models are best for:

  • Air-gapped environments
  • Reducing API costs for simple tasks
  • Experimentation and learning
  • Privacy-critical codebases

They are generally not recommended for complex multi-file refactoring where frontier models (Opus 4.8, o3) substantially outperform.

Cross-Provider Comparison

Head-to-Head: Coding Task Performance

Task TypeBest Claude ModelBest OpenAI ModelNotes
Multi-file refactoringOpus 4.8o3Both excellent; Claude Code's tooling gives it an edge
Quick bug fixSonnet 4.6GPT-4oFast, capable, good value
Test generationSonnet 4.6codex-miniHigh volume, lower cost matters
Algorithm designFable 5o3Both strong at deep reasoning
Code reviewOpus 4.8o3Long context helps (Claude's 200K advantage)
DocumentationSonnet 4.6GPT-4oBoth produce good docs
Simple scriptingHaiku 4.5o4-miniCheapest options, still capable

Context Window Comparison

ModelContext Window
Claude Fable 5200K tokens
Claude Opus 4.8200K tokens
Claude Sonnet 4.6200K tokens
Claude Haiku 4.5200K tokens
GPT-4o128K tokens
o3128K-200K tokens
codex-mini128K tokens

The 200K context window across all Claude models is a significant advantage for large codebases where the agent needs to consider many files simultaneously.

Practical Model Selection Framework

Decision Matrix

Model choice by tool: Claude Code and Codex CLI model options per task type; IDE tools select the model for you

Cost Optimisation Tips

  1. Start expensive, then downgrade: Begin a task with Opus or o3 to get the architecture right, then switch to Sonnet/o4-mini for iteration
  2. Use /fast mode liberally in Claude Code: Sonnet 4.6 handles the vast majority of coding tasks well
  3. Monitor costs: Use Claude Code's /cost command and OpenAI's usage dashboard
  4. Batch simple tasks: Accumulate small fixes and run them as a batch with a cheaper model
  5. Match model to task, not to habit: Do not use o3 for formatting code; do not use Haiku for system design

The "Best" Model is Context-Dependent

There is no single best model. The optimal choice depends on:

  • Task complexity — How much reasoning is needed?
  • Speed requirements — Is this interactive or batch?
  • Cost sensitivity — How many tokens will this consume?
  • Context needs — How much code must the model consider?
  • Provider preference — Which ecosystem are you invested in?

Model capabilities evolve rapidly. What holds in June 2026 may shift by September 2026. Re-evaluate your default model choice periodically and stay current with provider announcements.


Next: 5.c: The Evolving Toolkit