An answer in five seconds
You start on a support team. Your manager asks for a script that counts last week's tickets. You ask the company's AI assistant. Five seconds later you have neat, confident code.
Does it work? Are the functions it uses real? To answer that, you need to know what the assistant can know and what it cannot.
By the end of this lesson
Note
I can explain what an AI coding assistant does and does not know.
Key words
| Word | What it means |
|---|---|
| AI coding assistant | a tool that writes and explains code from your words |
| Model | the program inside it that predicts text |
| Prompt | the words you send the assistant |
| Context | all the text the model can see right now |
| Training data | the text the model learnt from, up to a date |
| Hallucination | a made-up answer that sounds true |
The cells students fill in are left blank in this preview.
An assistant predicts likely text
The model learnt from a huge amount of public text and code. When you send a prompt, it predicts the words most likely to come next. It does this again and again until the answer is finished.
It does not look the answer up. It usually does not run the code it writes. A likely answer is often a right one, but not always.
It only sees what is in the context
The context is the text the model can see right now. That is your prompt, the chat so far and any files your tool adds.
It cannot see your other files, your database or your servers. It does not remember last week's chat unless the tool saves it. Its training stops at a date, so newer tools may be missing.
What the assistant can see
| Thing | Can it see it? | Why |
|---|---|---|
| The prompt you just sent | Yes | It is in the context |
| A file you pasted in this chat | Yes | It is in the context |
| The rest of your project | No, unless a tool adds it | It is not in the context |
| Your live customer database | No | It never reaches the model |
| A chat from last week | Usually not | Each chat starts again |
| A library from this month | Maybe not | It is newer than the training data |
The cells students fill in are left blank in this preview.
A confident answer can be invented
Sometimes the model writes a function or a library that does not exist. The name looks sensible, so it is easy to believe. This is a hallucination.
The tone gives no warning. A wrong answer sounds just as sure as a right one. Run the code below and see one.
Try it: an invented method
# A support lead asked an assistant:
# "Find the longest ticket title in this list."
titles = ["Printer offline", "Password reset", "VPN will not connect"]
# The assistant suggested this line. Press Run and read the error.
longest = titles.longest()
print(longest)
# Python lists have no longest() method: the assistant invented it.
# Delete the line with longest() and the print line under it.
# Then remove the # from the five lines below and press Run again.
# longest = ""
# for title in titles:
# if len(title) > len(longest):
# longest = title
# print(longest)
A common mistake
Warning
Many people think an assistant checks its code before it answers. It predicts likely code and usually does not run it. So treat every answer as a draft until you have read it and run it yourself.