Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 1 of 30
Next❯

Generative AI Risks and Limitations

Module 1: Responsible AI ⏱ 9 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    VS Code & GitHub: Spot a hallucinated API Catch a suggestion that calls an API that doesn’t exist.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading…

    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
    1. Copilot suggests Money.roundBankers(…). It reads well, but this project has no Money library. LLMs can invent functions, packages and options.
    2. 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.
    3. 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.

    😟 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
    🛠️ Solved with: Generative AI limits

    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

    LimitWhat it looks like in contoso-shopWhy it happens
    HallucinationMoney.roundBankers(total), or npm install for a package name that doesn’t existThe model produces plausible names from patterns, not from your code or a registry
    Knowledge cut-offAn old Node.js API, a library version with a known vulnerabilityTraining data ends at a date; newer releases and fixes aren’t in it
    Insecure codeString-built SQL, a hard-coded secret, no input validationInsecure patterns exist in public code the model learned from
    BiasSample data that assumes every customer has a first and last nameTraining data reflects human bias
    Non-deterministic outputAsk twice, get two different versions of applyDiscountGeneration involves sampling, so answers vary
    Limited context windowCopilot ignores a rule in a file it never sawOnly so much fits into one prompt
    Weaker on rare languagesThin suggestions for an old in-house scripting languageLess training data for that language
    No real understandingCode that compiles but breaks the business ruleIt 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

    Online retail

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    A developer accepts a GitHub Copilot suggestion that calls a method named formatCurrencySafe(). The method does not exist in the project or in any installed package. Which limitation of generative AI does this illustrate?

    Question 2

    Question 2 of 5

    A team notices that GitHub Copilot suggests an older version of a library and does not use an API that was released recently. What is the most likely reason?

    Question 3

    Question 3 of 5

    Two developers enter the same prompt in GitHub Copilot Chat and receive different implementations of the same function. Which statement explains this behavior?

    Question 4

    Question 4 of 5 · Select 2

    Which TWO statements accurately describe limitations of the large language models used by GitHub Copilot?

    Question 5

    Question 5 of 5

    A developer asks GitHub Copilot Chat to rewrite a 5,000-line legacy file in one request. Copilot's version omits several business rules that appear near the end of the file. What should the developer do to reduce this risk?

    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. 1.Does Copilot execute code to check its suggestions?Show

      No. It predicts code; you run and test it.

    2. 2.What's a hallucination?Show

      Plausible-looking output that's made up, like an API that doesn't exist.

    3. 3.Why might Copilot suggest a deprecated API?Show

      Its training data has a cut-off and older patterns are common in it.

    4. 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. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.