In the overview, you saw where this course is headed: setting up Claude Code or Codex in a project folder and handing it small jobs. Before you install anything, it pays to look at the engine inside both tools. Every coding agent is built around a language model, and most of the habits in this course come straight from what a model does and what it can’t do.
By the end of this lesson, you’ll be able to explain what a model does with a request. You’ll also be able to judge whether a job suits a model and what your own code has to supply or check. Start with what happens to the text you send.
Predict Text One Token at a Time
When a chat tool answers your question in fluent paragraphs, it’s tempting to picture something that reads, looks things up, and replies. What actually happens is narrower than that, and knowing it helps you predict where a model will be useful and where it will let you down.
A language model takes text in and gives text out. It doesn’t produce the reply all at once. Instead, it generates one token at a time, where a token is a small piece of text: often a whole common word, sometimes part of a longer word or a punctuation mark.
Each new token is a likely continuation of everything before it, meaning your request plus the tokens the model has already produced. Then the model takes that longer text and predicts the next token, and so on until the reply ends.
The phone keyboard that suggests your next word is a fair comparison. However, the comparison stops at scale. A model learned its patterns from an enormous amount of text during training, and it weighs your whole request, not only the last word you typed. That’s why its continuations can be full answers, code that often runs, or a convincing explanation.
To see prediction at work, take the tabletop game group from the overview, whose members are inventing a language for their fantasy world. Their sound sheet has vowels, soft consonants, and hard consonants, and they already use words such as “velora”, “kamu”, and “tiresa”. Here’s a request sent to an OpenAI model, with the reply it returned:
Request:
A tabletop game group invented a language. Its words so
far: velora, kamu, tiresa. Suggest three more words in
the same style, as a comma-separated list, nothing else.
Reply:
sarenu, melora, tavisa
The reply fits the request well. Every word ends in a vowel and sounds like it belongs next to “velora”. No dictionary of the group’s language exists anywhere for the model to consult. It produced text that continues the request plausibly, based on patterns in its training and on the three words you gave it.
Suppose the very same request went to the model a second time. Would you expect the same three words?
The second run of the identical request returned this:
sarima, kelavo, tumera
The same input can give a different output on the next call. At each step, a model can pick from several likely tokens rather than always taking the single most likely one, so two runs drift apart after a token or two. For inventing words, that variety helps. For a job where you need the same answer every time, it’s a reason to have code do the work, or at least to check the result.
You’ll meet this variation all through the course. When you give your agent a job and compare the result with a lesson’s, expect differences in wording and detail, and look at whether the shape of the result and the things you check stay the same.
Know What a Request Contains
Prediction from patterns explains what a model does well. It also sets hard limits. Each of them follows from the fact that the model works only with what it learned in training and what the current request contains:
- No lookup: A model doesn’t search the web, open your files, run your code, or query your database. If that information isn’t in the request, the model doesn’t have it.
- No memory between calls: Each request starts from nothing. What you sent in an earlier call isn’t part of the next one unless it’s sent again.
- A training cutoff: The model’s training data stops at a cutoff date. Today’s date, recent releases, and anything that happened afterward aren’t in it, and neither is your own data.
- Fluent isn’t correct: A model can invent facts and state them with complete confidence, a behavior called hallucination. Smooth wording tells you nothing about whether a fact was checked.
The limit you’ll hit most often is that a model doesn’t have today’s date, the latest version of a package, or this week’s prices. Ask for one, and it either says it can’t tell or gives an answer that nobody checked.
Anything current has to come from outside the model. Your program supplies it by putting it into the request, for example by getting today’s date from JavaScript’s Date.
The same idea explains a chat that seems to remember. A chat app keeps your conversation and sends the earlier messages again with each new one, sometimes with extras such as the date. So the turn you see on screen isn’t necessarily the whole request the model receives. The model underneath still only predicts from what it’s given, and a later lesson shows how an agent’s session builds those requests.
Hallucination deserves the most care, because it doesn’t announce itself. A reply that names a function, a package option, or a command-line flag can read as perfectly plausible and still be wrong. Code an agent writes for you has the same problem, which is why the course keeps returning to checking what the agent did. The tutorial The JavaScript You Need to Review AI-Written Code goes deeper into reviewing code once you’re ready.
To test whether these limits have sunk in, click the button below to ask Code Mentor to quiz you, one question at a time:
Decide What Suits a Model
When a feature needs text, knowing the limits helps you decide whether a model should produce it and what your code has to add. The question to ask is whether the job rewards plausible text or whether it needs facts and rules that must be exactly right.
Here are three jobs the game group might want:
- Suggest new place names in the language’s style: This suits a model well. Plausible, varied names are exactly what you want. Your code should still check each word against the two sound rules—every word ending in a vowel and no two hard consonants in a row—because the model follows patterns and doesn’t guarantee compliance.
- Check whether a word breaks a sound rule: Code does this better. The rules are exact, a few lines of JavaScript can test them the same way every time, and there’s nothing to predict.
- List the words the group added last week: The model can’t do this alone. Those words are your group’s own records, so your code has to read them and put them in the request, and then a model can format or summarize them.
Across those examples, a model is a good fit for producing or reshaping text. Your code supplies anything current or private, and it checks whether the result gets facts right and obeys the rules. With that split, you get the model’s variety without trusting it for facts.
Try the same judgment on a feature of your own. Pick something you’ve built or want to build, and decide which parts a model could produce and what your code would need to supply or check. When you’ve made your call, you can talk it through with Code Mentor, which asks you about the feature and points out anything you might have missed:
Have a feature of your own in mind?
Check Your Understanding
Answer these in your own words before you open the answers:
- What does a language model do with the text of a request, step by step?
- A friend’s code asks a model in one call to suggest three words in the group’s style, then in the next call asks, “Which of those words did you list first?” Why can’t the second reply be based on the first?
- The game group wants a feature that greets each player by name and lists the words they invented this month. Which part could a model produce, and what must the code supply?
- It predicts a likely next token from everything in the request, adds it, and repeats until the reply is done. It works from patterns it learned in training and from what the request contains, with no lookup.
- The model keeps no memory between calls. The second request contains only its own text, so unless the code sends the first request and its reply again, the model has no list to answer from.
- A model could write a friendly greeting around the list. The code must supply the players’ names and the words from the group’s own records, because those are private and current, and the code could check that the words in the reply match the records.
A model on its own only predicts text from what a request contains. It can’t open a file in your project or run a command. The next lesson, How a Model Becomes an Agent, shows what lets a coding agent read your code, edit it, and run your scripts.