Sr. Content Developer at Microsoft, working remotely in PA, TechBash conference organizer, former Microsoft MVP, Husband, Dad and Geek.
147194 stories
·
33 followers

Build an AI-Powered Space Invaders Game

1 Share

Build an AI-Powered Space Invaders Game: Integrating LLMs into HTML5 Games with Microsoft Foundry Local

Introduction

What if your game could talk back to you? Imagine playing Space Invaders while an AI commander taunts you during battle, delivers personalized mission briefings, and provides real-time feedback based on your performance. This isn't science fiction it's something you can build today using HTML, JavaScript, and a locally-running AI model.

In this tutorial, we'll explore how to create an HTML5 game with integrated Large Language Model (LLM) features using Microsoft Foundry Local. You'll learn how to combine classic game development with modern AI capabilities, all running entirely on your own machine—no cloud services, no API costs, no internet connection required during gameplay.

We'll be working with the Space Invaders - AI Commander Edition project, which demonstrates exactly how to architect games that leverage local AI. Whether you're a student learning game development, exploring AI integration patterns, or building your portfolio, this guide provides practical, hands-on experience with technologies that are reshaping how we build interactive applications.

What You'll Learn

By the end of this tutorial, you'll understand how to combine traditional web development with local AI inference. These skills transfer directly to building chatbots, interactive tutorials, AI-enhanced productivity tools, and any application where you want intelligent, context-aware responses.

  • Set up Microsoft Foundry Local for running AI models on your machine
  • Understand the architecture of games that integrate LLM features
  • Use GitHub Copilot CLI to accelerate your development workflow
  • Implement AI-powered game features like dynamic commentary and adaptive feedback
  • Extend the project with your own creative AI features

Why Local AI for Games?

Before diving into the code, let's understand why running AI locally matters for game development. Traditional cloud-based AI services have limitations that make them impractical for real-time gaming experiences.

Latency is the first challenge. Cloud API calls typically take 500ms to several seconds, an eternity in a game running at 60 frames per second. Local inference can respond in tens of milliseconds, enabling AI responses that feel instantaneous and natural. When an enemy ship appears, your AI commander can taunt you immediately, not three seconds later.

Cost is another consideration. Cloud AI services charge per token, which adds up quickly when generating dynamic content during gameplay. Local models have zero per-use cost, once installed, they run entirely on your hardware. This frees you to experiment without worrying about API bills.

Privacy and offline capability complete the picture. Local AI keeps all data on your machine, perfect for games that might handle player information. And since nothing requires internet connectivity, your game works anywhere, on planes, in areas with poor connectivity, or simply when you want to play without network access.

 

 

Understanding Microsoft Foundry Local

Microsoft Foundry Local is a runtime that enables you to run small language models (SLMs) directly on your computer. It's designed for developers who want to integrate AI capabilities into applications without requiring cloud infrastructure. Think of it as having a miniature AI assistant living on your laptop.

Foundry Local handles the complex work of loading AI models, managing memory, and processing inference requests through a simple API. You send text prompts, and it returns AI-generated responses, all happening locally on your CPU or GPU. The models are optimized to run efficiently on consumer hardware, so you don't need a supercomputer.

For our Space Invaders game, Foundry Local powers the "AI Commander" feature. During gameplay, the game sends context about what's happening, your score, accuracy, current level, enemies remaining and receives back contextual commentary, taunts, and encouragement. The result feels like playing alongside an AI companion who actually understands the game.

Setting Up Your Development Environment

Let's get your machine ready for AI-powered game development. We'll install Foundry Local, clone the project, and verify everything works. The entire setup takes about 10-15 minutes.

Step 1: Install Microsoft Foundry Local

Foundry Local installation varies by operating system. Open your terminal and run the appropriate command:

# Windows (using winget)
winget install Microsoft.FoundryLocal

# macOS (using Homebrew)
brew install microsoft/foundrylocal/foundrylocal

These commands download and install the Foundry Local runtime along with a default small language model. The installation includes everything needed to run AI inference locally.

Verify the installation by running:

foundry --version

If you see a version number, Foundry Local is ready. If you encounter errors, ensure you have administrator/sudo privileges and that your package manager is up to date.

Step 2: Install Node.js (If Not Already Installed)

Our game's AI features require a small Node.js server to communicate between the browser and Foundry Local. Check if Node.js is installed:

node --version

If you see a version number (v16 or higher recommended), you're set. Otherwise, install Node.js:

# Windows
winget install OpenJS.NodeJS.LTS

# macOS
brew install node

# Linux
sudo apt install nodejs npm

Node.js provides the JavaScript runtime that powers our proxy server, bridging browser code with the local AI model.

Step 3: Clone the Project

Get the Space Invaders project onto your machine:

git clone https://github.com/leestott/Spaceinvaders-FoundryLocal.git
cd Spaceinvaders-FoundryLocal

This downloads all game files, including the HTML interface, game logic, AI integration module, and server code.

Step 4: Install Dependencies and Start the Server

Install the Node.js packages and launch the AI-enabled server:

npm install
npm start

The first command downloads required packages (primarily for the proxy server). The second starts the server, which listens for AI requests from the game. You should see output indicating the server is running on port 3001.

Step 5: Play the Game

Open your browser and navigate to:

http://localhost:3001

You should see Space Invaders with "AI: ONLINE" displayed in the game HUD, indicating that AI features are active. Use arrow keys or A/D to move, SPACE to fire, and P to pause. The AI Commander will start providing commentary as you play!

Understanding the Project Architecture

Now that the game is running, let's explore how the different pieces fit together. Understanding this architecture will help you modify the game and apply these patterns to your own projects.

The project follows a clean separation of concerns, with each file handling a specific responsibility:

Spaceinvaders-FoundryLocal/
├── index.html    # Main game page and UI structure
├── styles.css    # Retro arcade visual styling
├── game.js       # Core game logic and rendering
├── llm.js        # AI integration module
├── sound.js      # Web Audio API sound effects
├── server.js     # Node.js proxy for Foundry Local
└── package.json  # Project configuration
  • index.html: Defines the game canvas and UI elements. It's the entry point that loads all other modules.
  • game.js: Contains the game loop, physics, collision detection, scoring, and rendering logic. This is the heart of the game.
  • llm.js: Handles all communication with the AI backend. It formats game state into prompts and processes AI responses.
  • server.js: A lightweight Express server that proxies requests between the browser and Foundry Local.
  • sound.js: Synthesizes retro sound effects using the Web Audio API—no audio files needed!

How the AI Integration Works

The magic of the AI Commander happens through a simple but powerful pattern. Let's trace the flow from gameplay event to AI response.

When something interesting happens in the game, you clear a wave, achieve a combo, or lose a life, the game logic in game.js triggers an AI request. This request includes context about the current game state: your score, accuracy percentage, current level, lives remaining, and what just happened.

The llm.js module formats this context into a prompt. For example, when you clear a wave with 85% accuracy, it might construct:

You are an AI Commander in a Space Invaders game. The player just 
cleared wave 3 with 85% accuracy. Score: 12,500. Lives: 3. 
Provide a brief, enthusiastic comment (1-2 sentences).

This prompt travels to server.js, which forwards it to Foundry Local. The AI model processes the prompt and generates a response like: "Impressive accuracy, pilot! Wave 3 didn't stand a chance. Keep that trigger finger sharp!"

The response flows back through the server to the browser, where llm.js passes it to the game. The game displays the message in the HUD, creating the illusion of playing alongside an AI companion.

This entire round trip typically completes in 50-200 milliseconds, fast enough to feel responsive without interrupting gameplay.

Using GitHub Copilot CLI to Explore and Modify the Code


GitHub Copilot CLI accelerates your development workflow by letting you ask questions and generate code directly in your terminal. Let's use it to understand and extend the Space Invaders project.

Installing Copilot CLI

If you haven't installed Copilot CLI yet, here's the quick setup:

# Install GitHub CLI
winget install GitHub.cli    # Windows
brew install gh              # macOS

# Authenticate with GitHub
gh auth login

# Add Copilot extension
gh extension install github/gh-copilot

# Verify installation
gh copilot --help

With Copilot CLI ready, you can interact with AI directly from your terminal while working on the project.

Exploring Code with Copilot CLI

Use Copilot to understand unfamiliar code. Navigate to the project directory and try:

gh copilot explain "How does llm.js communicate with the server?"

Copilot analyzes the code and explains the communication pattern, helping you understand the architecture without reading every line manually.

You can also ask about specific functions:

gh copilot explain "What does the generateEnemyTaunt function do?"

This accelerates onboarding to unfamiliar codebases, a valuable skill when working with open source projects or joining teams.

Generating New Features

Want to add a new AI feature? Ask Copilot to help generate the code:

gh copilot suggest "Create a function that asks the AI to generate 
a mission briefing at the start of each level, including the level 
number and a random mission objective"

Copilot generates starter code that you can customize and integrate. This combination of AI-powered development tools and AI-integrated gameplay demonstrates how LLMs are transforming both how we build games and how games behave.

Customizing the AI Commander

The default AI Commander provides generic gaming commentary, but you can customize its personality and responses. Open llm.js to find the prompt templates that control AI behavior.

Changing the AI's Personality

The system prompt defines who the AI "is." Find the base prompt and modify it:

// Original
const systemPrompt = "You are an AI Commander in a Space Invaders game.";

// Customized - Drill Sergeant personality
const systemPrompt = `You are Sergeant Blaster, a gruff but 
encouraging drill sergeant commanding space cadets. Use military 
terminology, call the player "cadet," and be tough but fair.`;

// Customized - Supportive Coach personality  
const systemPrompt = `You are Coach Nova, a supportive and 
enthusiastic gaming coach. Use encouraging language, celebrate 
small victories, and provide gentle guidance when players struggle.`;

These personality changes dramatically alter the game's feel without changing any gameplay code. It's a powerful example of how AI can add variety to games with minimal development effort.

Adding New Commentary Triggers

Currently the AI responds to wave completions and game events. You can add new triggers in game.js:

// Add AI commentary when player achieves a kill streak
if (killStreak >= 5 && !streakCommentPending) {
    requestAIComment('killStreak', { count: killStreak });
    streakCommentPending = true;
}

// Add AI reaction when player narrowly avoids death
if (nearMissOccurred) {
    requestAIComment('nearMiss', { livesRemaining: lives });
}

Each new trigger point adds another opportunity for the AI to engage with the player, making the experience more dynamic and personalized.

Understanding the Game Features

Beyond AI integration, the Space Invaders project demonstrates solid game development patterns worth studying. Let's explore the key features.

Power-Up System

The game includes eight different power-ups, each with unique effects:

  • SPREAD (Orange): Fires three projectiles in a spread pattern
  • LASER (Red): Powerful beam with high damage
  • RAPID (Yellow): Dramatically increased fire rate
  • MISSILE (Purple): Homing projectiles that track enemies
  • SHIELD (Blue): Grants an extra life
  • EXTRA LIFE (Green): Grants two extra lives
  • BOMB (Red): Destroys all enemies on screen
  • BONUS (Gold): Random score bonus between 250-750 points

Power-ups demonstrate state management, tracking which power-up is active, applying its effects to player actions, and handling timeouts. Study the power-up code in game.js to understand how temporary state modifications work.

Leaderboard System

The game persists high scores using the browser's localStorage API:

// Saving scores
localStorage.setItem('spaceInvadersScores', JSON.stringify(scores));

// Loading scores
const savedScores = localStorage.getItem('spaceInvadersScores');
const scores = savedScores ? JSON.parse(savedScores) : [];

This pattern works for any data you want to persist between sessions—game progress, user preferences, or accumulated statistics. It's a simple but powerful technique for web games.

Sound Synthesis

Rather than loading audio files, the game synthesizes retro sound effects using the Web Audio API in sound.js. This approach has several benefits: no external assets to load, smaller project size, and complete control over sound parameters.

Examine how oscillators and gain nodes combine to create laser sounds, explosions, and victory fanfares. This knowledge transfers directly to any web project requiring audio feedback.

Extending the Project: Ideas for Students

Ready to make the project your own? Here are ideas ranging from beginner-friendly to challenging, each teaching valuable skills.

Beginner: Customize Visual Theme

Modify styles.css to create a new visual theme. Try changing the color scheme from green to blue, or create a "sunset" theme with orange and purple gradients. This builds CSS skills while making the game feel fresh.

Intermediate: Add New Enemy Types

Create a new enemy class in game.js with different movement patterns. Perhaps enemies that move in sine waves, or boss enemies that take multiple hits. This teaches object-oriented programming and game physics.

Intermediate: Expand AI Interactions

Add new AI features like:

  • Pre-game mission briefings that set up the story
  • Dynamic difficulty hints when players struggle
  • Post-game performance analysis and improvement suggestions
  • AI-generated names for enemy waves

Advanced: Multiplayer Commentary

Modify the game for two-player support and have the AI provide play-by-play commentary comparing both players' performance. This combines game networking concepts with advanced AI prompting.

Advanced: Voice Integration

Use the Web Speech API to speak the AI Commander's responses aloud. This creates a more immersive experience and demonstrates browser speech synthesis capabilities.

Troubleshooting Common Issues

If something isn't working, here are solutions to common problems.

"AI: OFFLINE" Displayed in Game

This means the game can't connect to the AI server. Check that:

  • The server is running (npm start shows no errors)
  • You're accessing the game via http://localhost:3001, not directly opening the HTML file
  • Foundry Local is installed correctly (foundry --version works)

Server Won't Start

If npm start fails:

  • Ensure you ran npm install first
  • Check that port 3001 isn't already in use by another application
  • Verify Node.js is installed (node --version)

AI Responses Are Slow

Local AI performance depends on your hardware. If responses feel sluggish:

  • Close other resource-intensive applications
  • Ensure your laptop is plugged in (battery mode may throttle CPU)
  • Consider that first requests may be slower as the model loads

Key Takeaways

  • Local AI enables real-time game features: Microsoft Foundry Local provides fast, free, private AI inference perfect for gaming applications
  • Clean architecture matters: Separating game logic, AI integration, and server code makes projects maintainable and extensible
  • AI personality is prompt-driven: Changing a few lines of prompt text completely transforms how the AI interacts with players
  • Copilot CLI accelerates learning: Use it to explore unfamiliar code and generate new features quickly
  • The patterns transfer everywhere: Skills from this project apply to chatbots, assistants, educational tools, and any AI-integrated application

Conclusion and Next Steps

You've now seen how to integrate AI capabilities into a browser-based game using Microsoft Foundry Local. The Space Invaders project demonstrates that modern AI features don't require cloud services or complex infrastructure, they can run entirely on your laptop, responding in milliseconds.

More importantly, you've learned patterns that extend far beyond gaming. The architecture of sending context to an AI, receiving generated responses, and integrating them into user experiences applies to countless applications: customer support bots, educational tutors, creative writing tools, and accessibility features.

Your next step is experimentation. Clone the repository, modify the AI's personality, add new commentary triggers, or build an entirely new game using these patterns. The combination of GitHub Copilot CLI for development assistance and Foundry Local for runtime AI gives you powerful tools to bring intelligent applications to life.

Start playing, start coding, and discover what you can create when your games can think.

Resources

Read the whole story
alvinashcraft
15 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Azure SQL’s Native JSON Type: Optimized for Performance

1 Share

Introduction

JSON has become the de-facto format for modern applications from web APIs to microservices and event-driven systems. Azure SQL has supported JSON for years, but JSON was treated just like text (stored as nvarchar or varchar). That meant every query involving JSON required parsing, which could get expensive as data volume grew.

The new native JSON binary type changes that story. Instead of saving JSON as raw text, Azure SQL can store it in a binary representation that’s optimized for fast reads, efficient in-place updates, and compact storage. You get the flexibility of JSON with performance that behaves more like a structured column.

Learn more about the JSON data type in the documentation –


A few useful things to know upfront:

  • JSON data is stored in a native binary format, not as plain text
  • Reads are faster because the JSON is already parsed
  • Improved write efficiency, since queries can update individual values without accessing the entire document.
  • Storage is more compact, optimized for compression
  • Existing JSON functions continue to work so app changes are minimal
  • Internally, JSON is stored using UTF-8 encoding (Latin1_General_100_BIN2_UTF8)

This blog shares the performance gains observed after migrating JSON from nvarchar/varchar to the native JSON binary type. Results will vary across JSON structures and workloads, so consider this a guide rather than a universal benchmark.

Note: The purpose of this blog is to introduce the native JSON binary data type. We are not covering JSON indexes or JSON functions at this time in order to maintain clarity and focus.

Test Environment Details:

To measure the performance impact of migrating JSON from nvarchar/varchar to the native JSON binary type, a test environment was set up with six tables on Azure SQL Database (General Purpose, Gen5, 2 vCores).

Note: The dataset used in the testing was generated using AI for demonstration purposes.


JSON data stored as nvarchar/varchar data types:

Table Name

Number of Records

Size (GB)

InventoryTrackingJSON

400,003

4.21

OrderDetailsJSON

554,153

1.29

CustomerProfileJSON

55,001

0.16

ProductCatalogJSON

100,001

0.10

SalesAnalyticsJSON

10,000

0.08

EmployeeRecordsJSON

5,000

0.02

 

Total database size: 5.94 GB (59.43% used), based on a maximum configured size of 10 GB, with JSON stored as nvarchar/varchar.                                    

 

Example schema (OrderDetailsJSON)

One of the core tables used in testing:

CREATE TABLE JSONTest.OrderDetailsJSON ( OrderDetailID INT IDENTITY(1,1) PRIMARY KEY, OrderMetadata NVARCHAR(MAX), -- JSON: order info,source, salesperson ShippingDetails NVARCHAR(MAX), -- JSON: carrier, priority, addresses CustomizationOptions NVARCHAR(MAX), -- JSON: customizations and add-ons CreatedDate DATETIME2 DEFAULT SYSDATETIME(), ModifiedDate DATETIME2 DEFAULT SYSDATETIME() );


Each JSON column simulated realistic business structure - for example:

OrderMetadata

{ "orderSource": "Mobile App", "salesPerson": "Jane Smith", "orderDate": "2025-11-14T10:30:00Z", "customerType": "Premium" }

ShippingDetails

{ "carrier": "FedEx", "priority": "standard", "address": { "city": "Anytown", "state": "CA" } }

CustomizationOptions

{ "color": "Green", "size": "Medium", "giftWrap": true }

Performance before migration:

To measure performance differences accurately, a continuous 12-minute test session was run. The load sizes referenced in the results (500, 1K, 2.5K, 5K, 10K, and 25K) represent the number of records read, and each record goes through the following operations:

  • Multiple JSON_VALUE extractions
  • JSON validation using ISJSON
  • Safe type conversions using TRY_CONVERT
  • Aggregation logic

During the 12-minute continuous workload, JSON stored as nvarchar/varchar showed consistent resource pressure, primarily on CPU and storage IO. The monitoring tools reported:

Disclaimer: These results are for illustration purposes only. Actual performance will vary depending on system hardware (CPU cores, memory, disk I/O), database configurations, network latency, and table structures. We recommend validating performance in dev/test to establish a baseline.

 

 

 

 

 

 

 

 

 



Data migration to native JSON binary data type

For testing, native JSON columns were added to the existing tables, and JSON data stored in nvarchar/varchar columns was migrated to the new native JSON binary columns using the CAST function.

Migration Script (example used for all tables)

  1. Add native JSON columns
    ALTER TABLE JSONTest.OrderDetailsJSON ADD OrderMetadata_native JSON, ShippingDetails_native JSON, CustomizationOptions_native JSON;

     

  2. Migrate existing NVARCHAR/VARCHAR JSON into native JSON
    UPDATE JSONTest.OrderDetailsJSON SET OrderMetadata_native = CAST(OrderMetadata AS JSON), ShippingDetails_native = CAST(ShippingDetails AS JSON), CustomizationOptions_native = CAST(CustomizationOptions AS JSON);

Note: After validating that the migrated data was consistent, the original nvarchar/varchar JSON columns were dropped. A rebuild index operation was then performed to remove fragmentation and reclaim space, ensuring that the subsequent storage comparison reflected the true storage footprint of the native JSON binary type.

The same pattern was repeated for all tables. 

Storage footprint after migration:

Table Name

Number of Records

Size_Before (GB)

Size_After (GB)

InventoryTrackingJSON

400,003

4.21

0.60

OrderDetailsJSON

554,153

1.29

0.27

ProductCatalogJSON

100,001

0.16

0.11

SalesAnalyticsJSON

10,000

0.10

0.04

CustomerProfileJSON

55,001

0.08

0.01

EmployeeRecordsJSON

5,000

0.02

0.00


Total database size: 1.06 GB (10.64% used), based on a maximum configured size of 10 GB, with JSON in native binary data type.

After migrating all JSON columns from nvarchar/varchar to the native JSON type, the total database size dropped from 5.94 GB to 1.06 GB - an ~82% reduction in storage.

Performance after migration

After moving all JSON columns from nvarchar/varchar to native JSON, the exact same 12-minute workload was rerun - same query patterns, same workload distribution. Only the JSON storage format was different. Here are the results:  

 

 

 

 

 

 

 

 

 

 



Key Metrics (Before vs. After)

The migration didn’t just shrink storage - it made JSON workloads easier for the engine to process. With the native JSON type, the same workload completed with ~27% lower CPU and ~80% lower Data IO.

Query duration, Throughput, & Logical Reads

Query duration

A comparison was conducted using the same workload, dataset, indexes, and query patterns - with the only variable being the JSON storage format. The outcome showed a clear trend in query duration.

 

 

 

 

 

 

 

 

 

 

 

 

 

Across every single load level, native JSON cut query duration by 2.5x - 4x. Even more interesting: as the workload scaled 50x, native JSON latency stayed almost flat, while text JSON steadily slowed down.

Note: The duration values shown represent the average across multiple runs within the performance test described earlier.

Throughput improvement

The benefits also translated directly into throughput. Overall, native JSON enabled 20x to 40x more records processed per second (rps). For example:

Load

Throughput Before (rps)

Throughput After (rps)

Small load

~60

~240

High load

~690

~2300

Peak load

~1360

~4700

Logical reads improvement

Native JSON significantly reduced I/O work as well:

  • Logical reads per run dropped from ~168,507 → ~33,880
  • An ~80% reduction in pages read

Lower logical reads directly correlate with improved scalability - fewer pages scanned means less work required to serve each request, especially under increasing load.


Sample results:

                          JSON (nvarchar/varchar)                                                                    JSON (native binary)

 

 

 

Cache management

To ensure the performance improvement was not simply a result of native JSON fitting more easily in memory, the test cleared the cache at regular intervals using DBCC DROPCLEANBUFFERS, forcing repeated cold-start execution. As expected, query duration increased immediately after each cache clear for both text JSON and native JSON, yet the relative benefit remained consistent: native JSON continued to show a 2.5x–4x reduction in duration across all load levels. This confirms that the gains are not due to buffer pool residency alone, but from reduced JSON parsing work during execution.

For example, in the chart below for the small load, runs 3 and 6 were executed right after clearing cache. Although both formats show higher duration, the relative performance advantage remains unchanged.

 

 

 

 

 

 

Conclusion

Native JSON storage in Azure SQL isn’t just a new way to store semi-structured data - it delivers tangible performance and efficiency gains. In our case, migrating JSON from NVARCHAR to the new binary JSON type resulted in:

 

 

 

 

 

 

If your workload involves frequent reading or updating of JSON documents - especially large or deeply nested ones, the native JSON type is worth evaluating. Your gains may vary based on JSON structure, indexing strategy, and workload patterns - but the benefits of eliminating repeated text parsing + reducing storage cost are difficult to ignore.

As SQL workloads continue to blend structured and semi-structured data, native JSON brings Azure SQL more in line with modern application design while preserving the maturity and stability of the relational engine.

Feedback and Suggestions

If you have feedback or suggestions, please contact the Databases SQL Customer Success Engineering (Ninja) Team (datasqlninja@microsoft.com). 

Note: For additional information about migrating various source databases to Azure, see the Azure Database Migration Guide.

Read the whole story
alvinashcraft
15 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Choosing the Right Model in GitHub Copilot: A Practical Guide for Developers

1 Share

AI-assisted development has grown far beyond simple code suggestions. GitHub Copilot now supports multiple AI models, each optimized for different workflows, from quick edits to deep debugging to multi-step agentic tasks that generate or modify code across your entire repository.

 

As developers, this flexibility is powerful… but only if we know how to choose the right model at the right time.

In this guide, I’ll break down:

  • Why model selection matters
  • The four major categories of development tasks
  • A simplified, developer-friendly model comparison table
  • Enterprise considerations and practical tips

This is written from the perspective of real-world customer conversations, GitHub Copilot demos, and enterprise adoption journeys

Why Model Selection Matters

GitHub Copilot isn’t tied to a single model. Instead, it offers a range of models, each with different strengths:

  • Some are optimized for speed
  • Others are optimized for reasoning depth
  • Some are built for agentic workflows 

Choosing the right model can dramatically improve:

  • The quality of the output
  • The speed of your workflow
  • The accuracy of Copilot’s reasoning
  • The effectiveness of Agents and Plan Mode
  • Your usage efficiency under enterprise quotas

Model selection is now a core part of modern software development, just like choosing the right library, framework, or cloud service.

The Four Task Categories (and which Model Fits)

To simplify model selection, I group tasks into four categories.
Each category aligns naturally with specific types of models.

1. Everyday Development Tasks

Examples:

  • Writing new functions
  • Improving readability
  • Generating tests
  • Creating documentation

Best fit:
General-purpose coding models (e.g., GPT‑4.1, GPT‑5‑mini, Claude Sonnet)

These models offer the best balance between speed and quality.

2. Fast, Lightweight Edits

Examples:

  • Quick explanations
  • JSON/YAML transformations
  • Small refactors
  • Regex generation
  • Short Q&A tasks

Best fit:
Lightweight models (e.g., Claude Haiku 4.5)

These models give near-instant responses and keep you “in flow.”

3. Complex Debugging & Deep Reasoning

Examples:

  • Analyzing unfamiliar code
  • Debugging tricky production issues
  • Architecture decisions
  • Multi-step reasoning
  • Performance analysis

Best fit:
Deep reasoning models (e.g., GPT‑5, GPT‑5.1, GPT‑5.2, Claude Opus)

These models handle large context, produce structured reasoning, and give the most reliable insights for complex engineering tasks.

4. Multi-step Agentic Development

Examples:

  • Repo-wide refactors
  • Migrating a codebase
  • Scaffolding entire features
  • Implementing multi-file plans in Agent Mode
  • Automated workflows (Plan → Execute → Modify)

Best fit:
Agent-capable models (e.g., GPT‑5.1‑Codex‑Max, GPT‑5.2‑Codex)

These models are ideal when you need Copilot to execute multi-step tasks across your repository.

 

GitHub Copilot Models - Developer Friendly Comparison

The set of models you can choose from depends on your Copilot subscription, and the available options may evolve over time. Each model also has its own premium request multiplier, which reflects the compute resources it requires. If you're using a paid Copilot plan, the multiplier determines how many premium requests are deducted whenever that model is used.

Model Category Example Models (Premium request Multiplier for paid plans)What they’re best atWhen to Use Them
Fast Lightweight Models

Claude Haiku 4.5, Gemini 3 Flash (0.33x)

Grok Code Fast 1 (0.25x)

Low latency, quick responsesSmall edits, Q&A, simple code tasks
General-Purpose Coding Models

GPT‑4.1, GPT‑5‑mini (0x)

GPT-5-Codex, Claude Sonnet 4.5 (1x) 

Reliable day‑to‑day developmentWriting functions, small tests, documentation
Deep Reasoning Models

GPT-5.1 Codex Mini (0.33x)

GPT‑5, GPT‑5.1, GPT-5.1 Codex, GPT‑5.2, Claude Sonnet 4.0, Gemini 2.5 Pro, Gemini 3 Pro (1x)

Claude Opus 4.5 (3x)

Complex reasoning and debuggingArchitecture work, deep bug diagnosis
Agentic / Multi-step ModelsGPT‑5.1‑Codex‑Max, GPT‑5.2‑Codex (1x)Planning + execution workflowsRepo-wide changes, feature scaffolding

 

Enterprise Considerations

For organizations using Copilot Enterprise or Business:

  • Admins can control which models employees can use
  • Model selection may be restricted due to security, regulation, or data governance
  • You may see fewer available models depending on your organization’s Copilot policies

Using "Auto" Model selection in GitHub Copilot

GitHub Copilot’s Auto model selection automatically chooses the best available model for your prompts, reducing the mental load of picking a model and helping you avoid rate‑limiting. When enabled, Copilot prioritizes model availability and selects from a rotating set of eligible models such as GPT‑4.1, GPT‑5 mini, GPT‑5.2‑Codex, Claude Haiku 4.5, and Claude Sonnet 4.5 while respecting your subscription level and any administrator‑imposed restrictions. Auto also excludes models blocked by policies, models with premium multipliers greater than 1, and models unavailable in your plan. For paid plans, Auto provides an additional benefit: a 10% discount on premium request multipliers when used in Copilot Chat. Overall, Auto offers a balanced, optimized experience by dynamically selecting a performant and cost‑efficient model without requiring developers to switch models manually. Read more about the 'Auto' Model selection here - About Copilot auto model selection - GitHub Docs

Final Thoughts

GitHub Copilot is becoming a core part of the developer workflows.
Choosing the right model can dramatically improve your productivity, the accuracy of Copilot’s responses, your experience with multi-step agentic tasks, your ability to navigate complex codebases

Whether you’re building features, debugging complex issues, or orchestrating repo-wide changes, picking the right model helps you get the best out of GitHub Copilot.

 

References and Further Reading

To explore each model further, visit the GitHub Copilot model comparison documentation or try switching models in Copilot Chat to see how they impact your workflow.

AI model comparison - GitHub Docs

Requests in GitHub Copilot - GitHub Docs

About Copilot auto model selection - GitHub Docs

 

 

Read the whole story
alvinashcraft
15 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

David Starr: DevOps Success Story - Episode 388

1 Share

David Starr is the President and Founder of Cumulus26, which helps companies succeed in the Microsoft Azure Marketplace and other facets of Azure. He's had a multi-decade career at Microsoft, Godaddy and others in senior technical leadership roles. He's spoken at industry conferences and delivered technical training courses and many other things.

Mentioned In This Episode

Episode 311 
Episode 149
LinkedIn
Making HIPAA and HITRUST compliance easier
Azure for Executives
Elegant Code
Elegant Coder X Account 
Plural Sight
Plural Sight Course
Mastering the Marketplace
Episode 99

Cumulus26 AmpUp - for Microsoft Markeplace 

Want to Learn More?

Visit AzureDevOps.Show for show notes and additional episodes.





Download audio: https://traffic.libsyn.com/clean/secure/azuredevops/Episode_388.mp3?dest-id=768873
Read the whole story
alvinashcraft
15 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Subagents: Parallel Execution and Context Isolation

1 Share

Discover how VS Code's subagents revolutionize parallel execution and context management. Learn the fundamentals of agent loops and context windows, then dive into how subagents isolate tasks, run simultaneously, and keep your main agent focused. Plus, explore custom agents and model optimization strategies to supercharge your development workflow.

Follow VS Code:

Special Guest: Harald Kirschner.

Links:





Download audio: https://aphid.fireside.fm/d/1437767933/fc261209-0765-4b49-be13-c610671ae141/28045885-eb83-4943-b740-bf9fc20d86be.mp3
Read the whole story
alvinashcraft
15 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

304 - Agent Skills - when to use them and why they matter

1 Share

Agent Skills look simple, but they are one of the most powerful building blocks
in modern AI coding workflows. In this episode, Kaushik and Iury break down when
to use skills, how progressive disclosure works, and how skills compare with
commands, instructions, and MCPs.

Full shownotes at fragmentedpodcast.com.

Show Notes

Main References

Creating Skills

Using other Skills

Warnings before installing random skills

[!warning] Don't install from hubs blindly.

Inspect the repo code before adding anything to your agent.

Additional resources

Get in touch

We'd love to hear from you. Email is the
best way to reach us or you can check our contact page for other
ways.

We want to hear all the feedback: what's working, what's not, topics you'd like
to hear more on.

Co-hosts:

[!fyi] We transitioned from Android development to AI starting with
Ep. #300. Listen to that episode for the full story behind
our new direction.





Download audio: https://cdn.simplecast.com/audio/20f35050-e836-44cd-8f7f-fd13e8cb2e44/episodes/c3bf3b11-1c58-482b-8ddd-f2741e3dd2b4/audio/2de2d02a-06a1-49e6-8ad9-290e24431e0a/default_tc.mp3?aid=rss_feed&feed=LpAGSLnY
Read the whole story
alvinashcraft
16 minutes ago
reply
Pennsylvania, USA
Share this story
Delete
Next Page of Stories