Generative AI Risks and Limitations
30-second answer
Generative AI tools like GitHub Copilot predict the most likely next code from patterns, so they can be confidently wrong. The main risks are hallucinations (invented APIs or packages), insecure or outdated code, bias, non-deterministic output and a limited context window. The model can't run, test or truly understand your code, which is why every suggestion is a draft you review and test.
Simulate it » No Azure account neededExam objective: 1.1.1 Describe risks and limitations of Generative AI tools. (Skills measured as of August 7, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Copilot suggests <code>Money.roundBankers(…)</code>. It reads well, but this project has no <code>Money</code> library. LLMs can <strong>invent</strong> functions, packages and options.
👆 Click the glowing item on screen to continue
Read the steps as text
- Copilot suggests Money.roundBankers(…). It reads well, but this project has no Money library. LLMs can invent functions, packages and options.
- Ask Copilot with #codebase, and check the docs or package registry yourself. Also watch for outdated APIs, insecure defaults and code that is confidently wrong.
- Know the risks: hallucinations, bias in generated text and names, security flaws, licence questions about matching public code, and over-reliance. The fix is the same: human review and tests.
🧪 Simulation for learning. Screens are simplified versions of Visual Studio Code and github.com with GitHub Copilot; names, files and suggestions are examples. Not affiliated with GitHub or Microsoft, and nothing here touches your real account.
🖱️ Drag to rotate · scroll or pinch to zoom
The model predicts code
A large language model predicts the most likely next tokens. It matches patterns from training data and your context; it doesn’t run, test or truly understand your code. That’s why output can be wrong, outdated or insecure.
🤔 What happens if…
Read this tour as text
- You type, then pause. Copilot doesn’t read your mind. When you pause while typing, the Copilot extension in your IDE starts a request for a completion.
- The IDE builds a prompt. The extension gathers context: code before and after the cursor, the file name and language, and related snippets from other open tabs. That bundle is the prompt. A model has a limited context window, so the extension picks what matters most.
- Content exclusions are checked. An admin can exclude paths or whole repositories. Excluded files are not used as context, and Copilot gives no inline suggestions inside them.
- The Copilot proxy. The prompt goes over HTTPS to a GitHub-hosted proxy. It authenticates the request and runs pre-filters, for example for harmful or offensive content and prompt-injection attempts, before anything reaches the model.
- The model predicts code. A large language model predicts the most likely next tokens. It matches patterns from training data and your context; it doesn’t run, test or truly understand your code. That’s why output can be wrong, outdated or insecure.
- Post-processing filters. Before you see it, the response is post-processed: checks for code quality and common insecure patterns, offensive content, and (if your policy says Block) a check for matches with public code of about 150 characters or more.
- Ghost text: accept or reject. The suggestion appears as grey ghost text. Tab accepts, Esc dismisses, Alt+] / Alt+[ cycle alternatives, Ctrl+→ accepts word by word. You decide what goes into your code.
- What data is kept. Prompts and suggestions are encrypted in transit. For Copilot Business and Enterprise, your code is not used to train GitHub’s models, and prompts and suggestions from IDE code completion are not retained after the response. Engagement data (accepts, rejects, errors) is kept to run and improve the service and to power usage metrics.
A free terminal with GitHub Copilot CLI, git and gh. No tasks: install the CLI, start a session, try slash commands and tool permissions, or call the seats API.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Copilot suggested a library call that doesn’t exist, and it looked perfectly normal.
😊 THE SOLUTION
Know how generative AI fails, so you know what to check.
- Invented APIs and packages✓ Check docs and the registry
- Outdated patterns✓ Prefer current, documented APIs
- Biased or unsafe output✓ Review with a critical eye
Start with a question
Copilot wrote a neat line of code that calls Money.roundBankers(). Your project has never had a Money library. Where did it come from?
It came from patterns. Plenty of codebases have a money helper with a rounding function, so the model guessed that yours might too. It didn’t check, because it can’t.
That’s the heart of this lesson. Generative AI predicts what code usually looks like. Most of the time that’s very useful. Some of the time it’s wrong in a way that looks completely right, and you’re the one who has to notice.
Explain it like I’m 10
The technical explanation
Copilot runs on large language models (LLMs). An LLM takes your prompt (the code around your cursor, open files, your chat message) and predicts the next tokens, one after another. It’s very good at “what usually comes next”. It isn’t checking facts, running code or reading your whole repository.
Every risk below comes from that one idea.
The limits you need to know
| Limit | What it looks like in contoso-shop | Why it happens |
|---|---|---|
| Hallucination | Money.roundBankers(total), or npm install for a package name that doesn’t exist | The model produces plausible names from patterns, not from your code or a registry |
| Knowledge cut-off | An old Node.js API, a library version with a known vulnerability | Training data ends at a date; newer releases and fixes aren’t in it |
| Insecure code | String-built SQL, a hard-coded secret, no input validation | Insecure patterns exist in public code the model learned from |
| Bias | Sample data that assumes every customer has a first and last name | Training data reflects human bias |
| Non-deterministic output | Ask twice, get two different versions of applyDiscount | Generation involves sampling, so answers vary |
| Limited context window | Copilot ignores a rule in a file it never saw | Only so much fits into one prompt |
| Weaker on rare languages | Thin suggestions for an old in-house scripting language | Less training data for that language |
| No real understanding | Code that compiles but breaks the business rule | It predicts text; it doesn’t know your intent |
Confident isn’t the same as correct
The tricky part is tone. A wrong answer is formatted just as nicely as a right one. There’s no warning label on a hallucination. Here’s a suggestion that reads fine:
export function applyDiscount(total, code) {
const pct = CODES[code];
return total - (total * pct) / 100;
}
It works for SAVE10. For an unknown code, pct is undefined and the function returns NaN. Nothing about the suggestion hinted at that. A one-line test would have caught it.
What the context window means for you
Copilot only knows what’s in the prompt. In the editor that’s mostly the current file, the code near your cursor and related snippets from open tabs. In chat it’s what you add with #file, #codebase or a selection, plus earlier messages. If a validation rule lives in a file Copilot never saw, it can’t respect it. Long chats also push older details out.
Architect level Package hallucinations are a supply-chain risk
If a model keeps inventing the same plausible package name, someone can publish a malicious package under that name and wait. A developer who runs npm install on the suggestion without checking pulls it in. So check that a package is real, maintained and the one you meant before you add it, and let dependency review and npm audit look at every new dependency in the pull request.
Real-world business scenario
Contoso Shop (fictional)
- The problem
- A new developer accepted a Copilot suggestion that used a deprecated crypto API and another that imported a package nobody had heard of. Both passed a quick read and reached a pull request.
- What they used
- The team kept Copilot but added the guardrails that catch its known limits: required tests for new functions, CodeQL code scanning, dependency review on every pull request and a short team guide on hallucinations and the knowledge cut-off.
- Why that choice
- Each check targets a specific limit. Tests catch confident-but-wrong logic, scanning catches insecure patterns, and dependency review catches invented or risky packages.
- The result
- The next suggestion with an unknown package failed dependency review before anyone had to spot it by eye, and new developers learned to treat Copilot output as a draft.
When to use it and when not to
✓ Use it when…
- Boilerplate, common patterns and first drafts you can check quickly with tests.
- Explaining unfamiliar code, as long as you confirm the explanation against the code itself.
- Suggesting test cases and edge cases you might have missed.
✕ Think twice when…
- Trusting package names, API signatures or config flags without checking the docs or registry.
- Security-critical code (auth, crypto, payments) accepted without expert review and scanning.
- Large rewrites in one go, where the context window can drop behaviour silently.
↔ Alternatives to consider
- Official documentation for exact API signatures and current versions.
- Small, tested steps: ask for one function at a time and run the tests after each.
Test yourself with exercises
5 original practice questions in the GH-300 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner Why can Copilot suggest code that calls a function that doesn't exist?
Model answer
Because it predicts what code usually looks like, it doesn't look anything up. If lots of projects have a helper with that kind of name, the model can produce it even though my project doesn't have it. That's a hallucination, and the fix is to check the name against my code and the docs.
Interviewer follows up
How would you check quickly?
You
I'd search the workspace, look in package.json, or ask Copilot Chat with #codebase. If the tests or the linter fail on an unknown symbol, that's another quick signal.
Intermediate What does a knowledge cut-off mean for the code Copilot writes?
Model answer
The model learned from data up to a certain date. It may suggest an older version of a library, a deprecated API, or miss a security fix that came later. I check the current docs and run a dependency audit rather than trusting the version it picks.
Experienced developer Copilot gave you two different answers to the same prompt. Is something broken?
Model answer
No. LLM output is non-deterministic, so the same prompt can produce different suggestions. That's why I don't treat one answer as the truth. I pick the version I understand, and the tests decide whether it's right.
Scenario A teammate wants to paste a 4,000-line legacy file into chat and ask for a full rewrite. What risks do you raise?
Model answer
The context window is limited, so Copilot may not see all of the file and could drop behaviour it never read. Legacy languages and odd patterns are also weaker spots for the model. I'd split the work into small functions, write tests for the current behaviour first, and review each change.
Architecture & design How would you set up a team so these limits don't reach production?
Model answer
Treat AI output like any other code. Required pull request reviews by a person, CI with tests and linting, code scanning and dependency review, and branch protection so nothing merges without those checks. The tool speeds up writing, the pipeline still decides what ships.
Quick revision
Key points
- Copilot predicts likely code from patterns. It doesn't run, test or understand it.
- Hallucinations: invented functions, packages, flags or settings that look plausible.
- The knowledge cut-off means suggestions can be outdated or miss recent security fixes.
- Output can be insecure, biased or simply wrong, and still look confident.
- The same prompt can give different answers (non-deterministic).
- The context window is limited, so Copilot only knows what fits in the prompt.
- Rare languages and unusual code get weaker suggestions.
Important terminology
- Generative AI
- AI that creates new content, such as code or text, by predicting likely output from patterns it learned in training.
- Large language model (LLM)
- The model behind Copilot. It predicts the next token based on its training data and the prompt it receives.
- Hallucination
- Output that sounds right but is made up, such as a function, package or setting that doesn't exist.
- Knowledge cut-off
- The date the model's training data ends. Newer libraries, versions and fixes may be unknown to it.
- Context window
- The limited amount of text the model can see in one request. Anything outside it is invisible to the model.
- Non-deterministic output
- The same prompt can give different answers on different runs.
- Over-reliance
- Trusting AI output without checking it, so mistakes reach production.
Common mistakes
- Installing a package Copilot named without checking it exists and is the real one.
- Assuming a confident, well-formatted answer must be correct.
- Expecting Copilot to know about code that isn't in its context.
Exam tips
- "Suggests a method that does not exist" = hallucination.
- "Unaware of a library released recently" = knowledge cut-off.
- "Same prompt, different result" = non-deterministic output.
- "Misses code in a large project" = limited context window.
Five quick revision questions
-
1.Does Copilot execute code to check its suggestions?Show
No. It predicts code; you run and test it.
-
2.What's a hallucination?Show
Plausible-looking output that's made up, like an API that doesn't exist.
-
3.Why might Copilot suggest a deprecated API?Show
Its training data has a cut-off and older patterns are common in it.
-
4.Why does Copilot miss code in files it can't see?Show
The context window is limited to what's in the prompt.
-
5.What's the general fix for all these limits?Show
Human review plus tests, linting and scanning.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Responsible AI: Principles, Harms and Mitigations
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.