Chat vs Agent Mode: Upgrade ByteStrike's Decoder
Where ByteStrike Stands
You've helped ByteStrike build a working blueprint decoder. It fetches encrypted data from The League's remote servers, extracts secrets hidden between {* and *} markers, and logs them cleanly. The code is documented, tested, and ready (sort of).
But now the mission evolves. The League has realized they need faster iteration on the decoder. New requirements arrive daily: support for multiple secret formats, better error recovery, UI improvements, even CLI flags for advanced operators.
This is where you learn the difference between two ways of working with Copilot:
- Chat Mode (Ask Mode): You stay in control. Ask targeted questions, get targeted answers. Great for quick improvements and understanding.
- Agent Mode (Autonomous Mode): You set a goal; Copilot explores files, makes multiple edits, and runs tests. Faster for big refactors, but requires review.
Learning Objectives
- Know when to use Chat vs Agent Mode for different ByteStrike missions
- Practice both workflows on the same goal (decoder improvements)
- Understand the risks and rewards of autonomous mode
- Learn to review and validate Agent Mode's work before shipping
Mode Selection Guide
| Scenario | Chat (Ask) | Agent (Autonomous) |
|---|---|---|
| Add a single feature (e.g., timeout + retry) |
✓ Best | Over-kill |
| Debug or explain code (e.g., why regex fails) |
✓ Best | Not applicable |
| Refactor an entire file (e.g., clean up all code style) |
Possible but slow | ✓ Best |
| Build + test + scaffold (e.g., full CLI with tests) |
Very tedious | ✓ Best |
| Many files, many changes (e.g., add new module to project) |
Manual coordination needed | ✓ Best |
Ask Mode is always the better choice for Junior Developers who want to learn by doing. It walks you through the process step by step and explains what's happening as it goes — making it an ideal teaching companion.
Agent Mode is best utilised by Senior Developers and Architects who are comfortable with spec-driven development and can confidently read, review, and understand the code Copilot produces.
Your Starter: The League's Blueprint Decoder
Note: This is a fresh starter for Part 4 — it is not a continuation of the blueprint_decoder.py file built in Parts 1–3. This new version retrieves blueprints from a remote URL instead of reading a local file, giving you more to work with as you explore Chat and Agent modes. Set your previous file aside and use this as your new starting point.
It works, but it's basic. You'll improve it using Chat and Agent modes.
import requests
import re
def retrieve_and_decode_blueprint(blueprint_url):
"""
Retrieves a classified League blueprint and deciphers it,
extracting only authentic secrets hidden by The League's tech.
Secrets are wrapped in {* and *} markers.
"""
try:
response = requests.get(blueprint_url, timeout=10)
response.raise_for_status()
secret_pattern = re.compile(r"\{\*(.*?)\*\}")
secrets = secret_pattern.findall(response.text)
print("=== LEAGUE MISSION REPORT ===")
if secrets:
for idx, secret in enumerate(secrets, 1):
print(f"Secret #{idx}: {secret.strip()}")
else:
print("No authentic secrets found. The League's decoys were strong!")
except Exception as err:
print(f"[ALERT] Unexpected error: {err}")
# Run the mission
blueprint_url = "https://raw.githubusercontent.com/codess-aus/AI-Assisted-Dev-with-GitHub-Copilot/main/blueprint-data.txt"
retrieve_and_decode_blueprint(blueprint_url)
async function retrieveAndDecodeBlueprint(url) {
try {
console.log(`Starting League mission: ${url}`);
const response = await fetch(url);
if (!response.ok) throw new Error(`Fetch error: ${response.status}`);
const secretPattern = /\{\*(.*?)\*\}/g;
const text = await response.text();
const secrets = [...text.matchAll(secretPattern)].map(m => m[1].trim());
console.log("=== LEAGUE MISSION DOSSIER ===");
if (secrets.length) {
secrets.forEach((s, i) => console.log(`Secret #${i + 1}: ${s}`));
} else {
console.log("No League secrets found. All data may be decoys!");
}
} catch (error) {
console.error("[ALERT] Mission error:", error);
}
}
// Run the mission
const url = "https://raw.githubusercontent.com/codess-aus/AI-Assisted-Dev-with-GitHub-Copilot/main/blueprint-data.txt";
retrieveAndDecodeBlueprint(url);
using System;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Linq;
public class LeagueHQ
{
private static async Task RetrieveAndDecodeBlueprint(string url)
{
Console.WriteLine($"Initiating League mission: {url}");
try
{
using var httpClient = new HttpClient();
var blueprintContent = await httpClient.GetStringAsync(url);
var secretPattern = new Regex(@"\{\*(.*?)\*\}");
var matches = secretPattern.Matches(blueprintContent);
Console.WriteLine("=== LEAGUE MISSION DOSSIER ===");
if (matches.Count == 0)
{
Console.WriteLine("No League secrets found. All data may be decoys!");
return;
}
int count = 1;
foreach (Match match in matches)
{
Console.WriteLine($"Secret #{count}: {match.Groups[1].Value.Trim()}");
count++;
}
}
catch (Exception ex)
{
Console.WriteLine($"[ALERT] Operation error: {ex.Message}");
}
}
public static async Task Main()
{
const string url = "https://raw.githubusercontent.com/codess-aus/AI-Assisted-Dev-with-GitHub-Copilot/main/blueprint-data.txt";
await RetrieveAndDecodeBlueprint(url);
}
}
Lab 4: ByteStrike's Decoder Upgrade Sprint
Task 1: Chat Mode - Quick Improvements
The League's intel says improved error handling could save 10 seconds per failed mission. Let's use Chat mode to add resilience quickly.
- Copy the starter code for your language into a new file.
- Open Copilot Chat (Cmd+I or Ctrl+I) and ask:
"Add retry logic (3 attempts) with exponential backoff and timeout handling to this blueprint decoder. Also add logging so we can see what's happening."
- Review the suggestions and accept the improvements one by one.
- Test it: Run the code and verify it still works. To test your error handling without disconnecting the network (required if you're in Codespaces), try one of these:
- Bad URL: Temporarily change the URL to something that doesn't exist (e.g., append
-brokento the filename) to trigger a 404 error. - Force a timeout: Ask Copilot: "How do I set the timeout to 0.001 seconds to simulate a timeout error in this code?" — apply it, run it, then revert.
- Valid network test: If you're running locally (not Codespaces), you can disconnect your network briefly to trigger the connection error path.
- Bad URL: Temporarily change the URL to something that doesn't exist (e.g., append
Task 2: Chat Mode - Understanding the Regex
Ask Copilot to explain the regex and suggest edge cases it might miss.
- In Chat, ask:
"Explain the regex pattern
\{\*(.*?)\*\}. What edge cases might break it? How would you handle secrets that span multiple lines?" - Read the answer (this is learning, not just automating!).
- Ask for a fix: "Update the regex to handle multi-line secrets."
- Apply the improved pattern to your code.
Task 3: Agent Mode - Full Refactor & CLI
The League now wants ByteStrike's decoder as a production CLI tool with tests, config, and docs. This is a job for Agent Mode.
- Set up a new folder for your project (e.g.,
league-mission-decoder). - Create one starter file (the decoder) and a simple README placeholder.
- Open Agent Mode (use the Copilot Agent extension or chat command) and prompt:
"Refactor the blueprint decoder into a production-ready CLI tool. Add command-line arguments (--source-url, --marker-start, --marker-end, --output), unit tests, error handling with retries, structured logging, and a README with install and usage examples. Structure the code across separate files for the CLI entry point, decode logic, and tests. Use pytest for Python, xUnit for C#, Jest for JavaScript. Use best practices for [language]."
Note: Agent Mode output varies. Copilot may choose a single-file layout, use
unittestinstead ofpytest, or add apyproject.tomlpackage setup. This is normal — check the solutions reference for what a compliant output looks like and what variations are acceptable. - Watch Agent Mode work (it will create/edit multiple files, run tests, etc.).
- Review every change: Read the files it created. Do they make sense? Are the tests good? Does the README help?
- Accept or reject: If satisfied, accept all changes. If something is off, ask Agent to refine it or manually fix it yourself.
Task 4: Compare & Reflect
- Which tasks were faster in Chat? (Probably error handling and explanation.)
- Which felt natural in Agent Mode? (Probably the full refactor with tests and CLI.)
- What would you choose for the next mission? Think about how you'd apply this decision-making.
Key Takeaway: Know Your Tool
Chat and Agent modes are not better or worse; they're different tools for different jobs. ByteStrike's team will succeed by:
- Using Chat for quick questions, targeted fixes, and learning
- Using Agent Mode for big refactors, scaffolding, and multi-file changes
- Always reviewing the output before shipping
- Building a culture where Copilot is a collaborator, not a black box
Next up: Part 5 shows you how The League adds guardrails: security, privacy, and correctness checks before trusting ByteStrike's decoder in production.