“Program testing can be used to show the presence of bugs, but never to show their absence.” — Edsger W. Dijkstra
Say you want to read a NetCDF file (one month of ERA5 temperature,
for example) and draw a filled map with xarray and
cartopy. The hard part is usually not the science. It is
remembering the exact xarray/cartopy
functions, getting the projection right, and fixing a dimension-order
mistake. With an AI coding assistant, you can describe what you want in
one sentence and get a first working draft in seconds. AI does not do
the thinking for you. It takes away the busywork, including looking
things up, remembering syntax, writing the first draft, so you can spend
your time on the science, and on checking the results. AI can
write, but you must verify.
An LLM is a neural network trained on a huge amount of text and code to predict the next token. Almost everything else follows from that one fact: it is a probabilistic text generator. It is not a database, and it is not a reasoning engine that is guaranteed to be correct.
The model does not read characters or words. It reads tokens, which are short chunks of text. In English, a common word like “ozone” is one token; a longer word like “concentration” may split into two. In Chinese, a token is usually one or two characters. Cost and the context window are both counted in tokens, which is why tokens matter in practice.
Figure source, adapted from Jay Alammar, The Illustrated GPT-2 (redrawn).
The model can only “see” a fixed number of tokens at once. That limit is its context window. Everything you give it, like the instruction, the files, the conversation history, has to fit inside the window. Whatever does not fit is dropped or compressed. This one limit is the reason context engineering exists.
Figure source, adapted from Jay Alammar, The Illustrated GPT-2 (redrawn).
Generating text is a loop: given the tokens it has seen so far, the model assigns a probability to each possible next token, picks one, appends it, and starts again. Two things follow:
Figure source, adapted from Jay Alammar, The Illustrated GPT-2 (redrawn).
That picking step is why the same prompt can give different answers each time. Temperature controls how random the picking is. A low temperature concentrates the probability on the most likely tokens, so the output is stable and “safe”. A high temperature spreads the probability out, so the output is more varied, more creative, and more likely to drift into nonsense.
Figure source, adapted from Jay Alammar, The Illustrated GPT-2 (redrawn).
A base model only knows how to keep writing whatever text it is given; it is not trying to be helpful. An instruct/chat model has been fine-tuned (with a method like Reinforcement learning from human feedback (RLHF)) to follow instructions. The assistants and coding agents you use are instruct/chat models, and many of them add a reasoning (chain-of-thought) step on top.
A model’s knowledge stops at the cutoff date of its training data. Past that point, it will sometimes hallucinate: it confidently invents functions, parameters, or facts that do not exist. This is not a bug; it is a direct result of next-token prediction. The model is trying to write a plausible continuation, not a true one. That is why the rule of this module is verify.
Under the hood, an LLM is just a function: you pass text in and get text back.
Here we want to answer one question: why did AI for coding become useful and cheap only in the last few years? The answer is a series of jumps in what these systems can do, driven by four turning points.
Everything was rules written by hand. Symbolic AI and expert systems stored knowledge as explicit rules. In the editor, “AI” meant rule-based autocompletion (e.g., IntelliSense), syntax checking, and code templates. It was pattern matching, not understanding. This is the era of the IntelliSense you still use today.
Statistical language models gave way to neural networks. In 2017, the paper Attention Is All You Need introduced the Transformer, which made it practical to train models on long pieces of text (this is where the context window from the last section comes from). In 2018, Generative pre-trained transformer (GPT) and Bidirectional Encoder Representations from Transformers (BERT) established the pre-train, then fine-tune recipe that most models still follow.
In 2020, GPT-3 showed what are now called scaling laws: the more parameters and data, the more capable the model. The loss keeps dropping as compute grows, with no plateau in sight.
Figure source, adapted from Kaplan et al., Scaling Laws for Neural Language Models (2020).
In 2021, OpenAI Codex powered GitHub Copilot, the first mainstream AI pair programmer. But Copilot could only complete code; it could not change your project. In late 2022, ChatGPT showed the second turning point, alignment: a model tuned to follow instructions, not just to keep writing text.
GPT-4 (2023) made multi-step reasoning practical. Early agent experiments (AutoGPT, BabyAGI) showed how much an agent can do on its own, and how easily it can go off the rails. The field then matured on the engineering side: Cursor put agents inside the editor, SWE-bench became a serious benchmark, and in 2024 Claude Code shipped a coding agent that runs in the terminal. Anthropic also proposed Model Context Protocol (MCP) as a way to connect agents to outside tools. This is when coding AI crossed from completing to doing, like reading files, editing, running tests, and fixing bugs.
Open-weight models such as DeepSeek R1/V3 closed much of the quality gap and cut the cost dramatically. They are now cheap enough that you can bring your own API key, as we will in the labs. Reasoning models (which write out a chain of thought before answering) got better at hard tasks. And the ecosystem around agent harnesses (skills, plugins, and workflows) became the normal way to customize these tools. Today’s tools sit in this last stage.
To sum up, scale made models smart, alignment made them follow instructions, engineering let them act, and open weights made it cheap.
Here is the whole vocabulary in one picture, from the bottom up:
A way to remember:
Three pairs people often mix up:
The model itself, described above. In practice the choice that matters is which model: a stronger reasoning model, or a faster and cheaper one. It is a trade-off between quality, speed, and cost.
The major providers are OpenAI (GPT), Anthropic (Claude), Google (Gemini), and DeepSeek. There are also open-weight models you can run yourself, such as Llama (Meta) and Qwen (Alibaba). Model names change often, so you do not need to memorize them. Just know the two kinds: reasoning models, which are stronger on hard problems but slower and pricier, and chat models, which are fast and cheap.
Most models you will use are cloud models, which you call through an Application Programming Interface (API), as you will set up in Lab 13. They are strong but cost money and send your data to the provider. You can also run local models on your own computer, for example with Ollama. Local models are free and keep your data private, but they are slower and weaker than cloud models.
Everything you say to the model: a system prompt
(the role and rules) plus the user prompt (the task),
plus any files or examples you attach. In coding, a good prompt is a
clear spec. For example, “write a function that reads a CSV of station
observations, returns a pandas.DataFrame, and handles
missing values” works much better than “process the data”.
Everything the model can see right now: relevant code, error messages, documentation, and the conversation so far. Choosing carefully what goes into that window and what stays out is context engineering. Feeding the model 500 irrelevant lines is noise, not help.
Prepared for this course.
A single thing the agent can do, like read a file, edit a file, run a shell command, search the web, and so on. Tools are what turn a chatbot into something that can do things. For example, to “fix code and check it”, an agent needs at least two tools: “read file” and “run test”.
An agent is an LLM wrapped in a loop: think → act (call a tool) → observe (read the result) → think again, until the goal is reached. You give the goal (like, “make this script run and pass the test”); the agent reads, edits, runs, reads the error, and tries again. A main agent can also hand off parts of the work to subagents.
Figure source, adapted from Anthropic, Building Effective Agents (2024, redrawn).
The harness is the program that gives the agent its hands and its environment. It manages the session, connects the tools, enforces permissions and a sandbox, loads skills/plugins/workflows, and keeps track of models and credentials. It is the shell that lets the model act safely inside your environment. DeepSeek Harness, Claude Code, Codex, and Cursor are all harnesses.
Prepared for this course.
A skill is a reusable how-to with a short set of instructions that
teaches the agent to do one kind of task well, loaded only when needed.
For example, a “geoscience plotting style” skill could say “use
cartopy, pick the projection this way, use
cmocean colormaps, label the units”, so every figure comes
out consistent.
Prepared for this course.
A workflow is a fixed and multi-step process. It is a script that splits a big job into ordered steps and hands them to many subagents in parallel or in a pipeline. Use it for batch work that is well defined and repeatable. For example, “audit these 50 scripts for bugs and summarize”. It is predictable and easy to re-run.
Figure source, adapted from Anthropic, Building Effective Agents (2024, redrawn).
A plugin is a software package that extends the harness. It can add new tools, new parts of the interface, or connections to other services, and it may bundle skills and workflows too. In DeepSeek Harness, plugins are installed as packages (aka, “bundles”) through the plugin manager.
| Kind | Examples | What it is for |
|---|---|---|
| Chat assistant | ChatGPT, Claude, DeepSeek web | Answer questions, draft snippets, explain errors |
| IDE autocomplete | GitHub Copilot, editor built-ins | Suggest code as you type |
| Agent harness | DeepSeek Harness, Claude Code, Cursor, Codex, Gemini CLI | Run the edit→test→fix loop on its own; Customizable with skills/plugins/workflows |
Which is a better instruction to give a coding assistant, and why?
station.csv with pandas, drop rows where
Ozone is NaN, and plot a daily-mean time
series saved as ozone_timeseries.png.”For each item, name the concept it matches: LLM, prompt, context, tool, agent, harness, skill, workflow, and plugin.
cartopy and cmocean.50 scripts by fanning out to many
subagents.Using any chat assistant you have access to, ask it to write a
Python function that reads a CSV and computes
the mean of a numeric column, ignoring missing values. Then:
The notes were prepared for the ESE5023 AI-for-coding module and adapt ideas from the resources above.