Lecture I: From Autocomplete to Agents

AI-Assisted Programming for PhD Researchers

Dr. Tobias Vlćek

Helmut Schmidt University, August 2026

Welcome

About This Course

  • Three days, hands-on from the first hour
  • You build a real data pipeline, then your own project
  • Pass/fail on attendance: show up for three days and you pass
  • The goal: use AI to code well, not just fast

About Me

  • Field: Optimizing and simulating complex systems
  • Languages: Julia, Python, and Rust
  • Interests: Modelling, Simulations, Machine Learning
  • Teaching: OR, Algorithms, and Programming
  • More: tobiasvlcek.com

The Three Days

  • Day 1: Foundations and the core agent loop
  • Day 2: Discipline: verification, safety, extension
  • Day 3: Your own project, then everyone shows what they built

What You Will Deliver

A project of your own, shown to the room on Day 3:

  • The thing running
  • How you worked with the agent
  • What went wrong on the way
  • No slides, no formal talk

This Website

  • Everything you need lives here, no separate handouts
  • Slides open as a deck via the RevealJS button
  • Labs are step-by-step pages you follow at your pace
  • A course chatbot sits in the sidebar for questions: EU-hosted, no training on your messages (how it works)

Who Are You?

Quick intro round.

Tell us three things:

  • Your name
  • Your field
  • One piece of code you fight with

First: Get Set Up

  • We install everything together: Zed, a Mistral key, a GitHub account, uv
  • Follow along at the Setup page
  • Ends with a self-check. Make sure you pass it before we continue

Getting Around Zed

Getting Around Zed

  • The Command Palette (cmd-shift-p / ctrl-shift-p) is the gateway to almost everything in Zed
  • Type a few characters to filter, press enter to run
  • Every action lives here: search it, don’t memorize it

Finding Files and Text

  • File Finder (cmd-p / ctrl-p): jump straight to any file by name
  • Project Search (cmd-shift-f / ctrl-shift-f): find any string across every file in the project
  • Split panes to view files side by side, and toggle the built-in terminal with ctrl-` (macOS, Windows, and Linux)

Your Turn: Get Around Zed

Your turn: 30 seconds, three moves.

  • Open the Command Palette
  • Use the File Finder to open any file
  • Run a Project Search for a word you know is in the repo

Why This Course

Research Runs on Code

  • Most PhDs write research software with little to no formal software training (Hannay et al. 2009)
  • Hannay’s survey of nearly 2,000 scientists showed learning was mostly informal, from peers
  • That was already hard before AI entered the loop

What Changed

  • 2021: autocomplete suggests the next line as you type
  • 2023: chat answers questions in a side window
  • 2025+: agents read your files and run commands
  • A capability jump, and a widening discipline gap

The Promise and the Trap

  • Promise: hours saved on boilerplate, debugging, and learning
  • Trap: code you don’t understand ends up in your thesis
  • A gap widens between those who use AI well and those who lean on it as a crutch (Prather et al. 2024)

How LLMs Work

What Is an LLM?

  • Think of an LLM as an advanced pattern-recognition system, trained on huge amounts of text, books, and code
  • What it actually does: predict the next token: autocomplete on your phone, but vastly more capable
  • It does not “think” or “understand” the way you do

Despite the limits ahead, LLMs are genuinely useful for coding, writing, and research.

From Text to Tokens

  • The model never sees words: it sees tokens, text chunks mapped to numbers
  • Common words are one token; rarer words split into pieces: “un-”, “break”, “-able”
  • That lets it handle words it has never seen before
  • Its vocabulary holds from tens of thousands to a few hundred thousand tokens (for the Mistral models we use in this course, about 131,000)

Attention: Which Words Matter

  • Modern LLMs use the Transformer architecture (Vaswani et al. 2017)
  • Its core trick, attention, weighs which earlier tokens matter most for the next one

“The cat did not fit in the box because it was too small.” Attention is what lets the model tie “it” to “the box,” not “the cat.”

Predicting the Next Token

  • For every token it might generate, the model computes a score, a logit
  • One score per vocabulary entry: over a hundred thousand numbers, at every single step
  • Softmax turns those scores into a probability distribution that sums to 1

Sampling, Not Always the Top Pick

  • Naively, you would always take the highest-probability token: greedy decoding
  • Real models instead sample from the distribution: the top pick wins most often, not always
  • Where two tokens are near-tied (“gray” vs “overcast”), which one lands is chance: the same prompt can give a different answer on different runs

Complete the Sentence

Question: “The students opened their ___”

  • Books? Laptops? Presents? Eyes?
  • Every answer is plausible; none is “the” answer
  • The model faces exactly this choice, silently, at every token it writes

Same Seed, Same Answer

  • Sampling needs randomness, but computers only have pseudo-randomness, seeded by a number
  • Fix that random seed and the “random” choice becomes reproducible: same prompt, same seed, same output
  • Reproducible in principle; hosted APIs treat seeds as best-effort (batching, nondeterministic kernels), so don’t rely on it
  • Lecture VI on safety builds on exactly this: steering which token gets sampled, on purpose, is how AI text gets watermarked

Context: Short-Term Memory

  • The context window: how many tokens the model can hold at once, its short-term memory
  • Larger: remembers more of the conversation
  • Smaller: forgets earlier turns
  • Nothing outside it exists for the model: not your screen, not your intent

How LLMs Are Trained

  • Pre-training: predict the next token over massive, unlabelled text. This is where grammar, facts, and patterns come from
  • Fine-tuning: curated examples teach it to follow instructions
  • RLHF: humans rank outputs; the model learns to prefer the ranked-higher ones

Why Hallucination Happens

  • Pre-training rewards plausible continuations, not true ones: nothing in the loop checks facts
  • Sampling always produces some next token, confident or not
  • The result is hallucination: fluent, well-formed text that is simply wrong

Knowledge Cutoff

  • Training data has an end date: the knowledge cutoff
  • Anything after that date is not “unlikely”: it is simply absent
  • The model rarely tells you it does not know; it guesses fluently instead

Models vs. Apps

  • A model (Claude, GPT, Mistral) is the thing that predicts tokens
  • An app (ChatGPT, Claude.ai, an agent in your terminal) is everything around it: tools, saved instructions, and rules
  • Same model, different app: very different results
  • Next: which apps turn this into something that edits your code

The Tool Landscape

Three Kinds of AI Coding Tools

  • Autocomplete: inline, at the keystroke level
  • Chat: you copy and paste, it answers
  • Agents: they act inside your repository

Autocomplete

  • Completes code as you type
  • Zed edit predictions, powered by the free Mistral key from setup
  • Great for boilerplate
  • Useless for design decisions

Chat

  • Paste your code, get an answer back
  • No repository access: you are the clipboard
  • Still useful for concepts and quick explanations

Agents

  • Read files, edit them, run commands, iterate toward a goal
  • Live in your terminal or your editor
  • This is the course’s focus: agentic coding

The 2026 Market

  • IDE-integrated: Copilot, Cursor, Windsurf
  • Vendor CLIs: Claude Code, Codex, Gemini CLI
  • Open source: OpenCode, Aider, Goose

Orientation only, no detail needed today.

Our Stack, and Why

  • Zed: fast editor, free (optional student plan), with a capable built-in agent of its own
  • OpenCode: open source, works with any model (in the terminal, or inside Zed via ACP)
  • Mistral: free tier, EU-hosted, no training on opted-out data

Learn the workflow, not the tool. These concepts transfer to every other agent, including Zed’s own, which you are free to use.

How Agents Work

A Language Model in a Loop

  • The model proposes an action
  • A tool runs it: read, edit, or shell command
  • The result feeds back into the model
  • Repeat until the goal is met

Nothing magical, and no memory between sessions.

Context Is Everything

  • The agent’s context window holds only: your prompt, the files it read, command output
  • Garbage in, garbage out

Where the Loop Breaks

  • Long-context degradation: quality drops in huge sessions
  • Every failure mode from before still applies, at every step, and a loop gives them many steps to compound in

The answer is verification. We build that on Day 2.

The Evidence

Faster: Sometimes, Somewhere

These are real gains, on the right kind of work.

…But Slower Where It Counts

  • Experienced devs on their own mature codebases:
  • 19% slower, while believing they were about 20% faster (Becker et al. 2025)
  • The perceived speedup and the real one point opposite ways

Does AI Assistance Hurt Learning?

  • Anthropic ran a randomized controlled trial on coding skill
  • AI group scored 50% on a mastery quiz vs 67% hand-coding (Shen and Tamkin 2026)
  • The largest gap was on debugging questions

Comprehension Debt

  • Code that works today but nobody understands tomorrow (Osmani 2026)
  • Like technical debt, but for understanding
  • The interest comes due during revisions and review
  • You pay it when a reviewer asks “why does this work?”

It Depends How You Use It

  • Same study: conceptual questions and explain-back preserved learning; passive “just fix it” did not
  • At scale: unguarded AI cut exam scores, a guardrailed tutor did not (high-school maths RCT) (Bastani et al. 2025)

This course is those guardrails.

More Bugs Than You Think

  • About 45% of AI-generated samples carry OWASP-class vulnerabilities (Veracode 2025)
  • AI-authored PRs: ~1.7× more issues overall, up to 2.74× for security issues (correlational) (Loker 2025)

Day 2 is built around catching exactly this.

Our Working Rules

Rule 1: Explain Before You Accept

  • The era’s shift is from writing code to reading and evaluating it (Denny et al. 2024)
  • You must be able to explain every change the agent made
  • Labs have “Explain it” boxes for exactly this (Smith and Zilles 2024)

Rule 2: Verify, Then Trust

  • Never believe the word “done”
  • Run it
  • Test it
  • Read the diff

Rule 3: You Own Every Line

  • “The AI wrote it” is not a defense, not in your thesis, your paper, or this course
  • Task stewardship: delegate the labor, keep the accountability (Lee et al. 2025)

Rule 4: Small Steps, Frequent Commits

  • Small, verified increments beat one giant diff
  • Every step stays reviewable and reversible
  • Git makes this cheap: that’s our next session

Continue Your Journey

Next Up

Bastani, Hamsa, Osbert Bastani, Alp Sungu, Haosen Ge, Özge Kabakcı, and Rei Mariman. 2025. “Generative AI Without Guardrails Can Harm Learning: Evidence from High School Mathematics.” Proceedings of the National Academy of Sciences 122 (26): e2422633122. https://doi.org/10.1073/pnas.2422633122.
Becker, Joel, Nate Rush, Elizabeth Barnes, and David Rein. 2025. Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity. arXiv. https://doi.org/10.48550/ARXIV.2507.09089.
Cui, Kevin Zheyuan, Mert Demirer, Sonia Jaffe, Leon Musolff, Sida Peng, and Tobias Salz. 2026. “The Effects of Generative AI on High-Skilled Work: Evidence from Three Field Experiments with Software Developers.” Management Science, February, mnsc.2025.00535. https://doi.org/10.1287/mnsc.2025.00535.
Denny, Paul, James Prather, Brett A. Becker, et al. 2024. “Computing Education in the Era of Generative AI.” Communications of the ACM 67 (2): 56–67. https://doi.org/10.1145/3624720.
Hannay, Jo Erskine, Carolyn MacLeod, Janice Singer, Hans Petter Langtangen, Dietmar Pfahl, and Greg Wilson. 2009. “How Do Scientists Develop and Use Scientific Software?” 2009 ICSE Workshop on Software Engineering for Computational Science and Engineering, May, 1–8. https://doi.org/10.1109/SECSE.2009.5069155.
Lee, Hao-Ping (Hank), Advait Sarkar, Lev Tankelevitch, et al. 2025. “The Impact of Generative AI on Critical Thinking: Self-Reported Reductions in Cognitive Effort and Confidence Effects From a Survey of Knowledge Workers.” Proceedings of the 2025 CHI Conference on Human Factors in Computing Systems (Yokohama Japan), April, 1–22. https://doi.org/10.1145/3706598.3713778.
Loker, David. 2025. AI Vs Human Code Gen Report: AI Code Creates 1.7x More Issues.” In CodeRabbit. https://coderabbit.ai/blog/state-of-ai-vs-human-code-generation-report.
Osmani, Addy. 2026. “Comprehension Debt: The Hidden Cost of AI-Generated Code.” In Addyosmani.com. https://addyosmani.com/blog/comprehension-debt/.
Peng, Sida, Eirini Kalliamvakou, Peter Cihon, and Mert Demirer. 2023. The Impact of AI on Developer Productivity: Evidence from GitHub Copilot. arXiv. https://doi.org/10.48550/ARXIV.2302.06590.
Prather, James, Brent N Reeves, Juho Leinonen, et al. 2024. “The Widening Gap: The Benefits and Harms of Generative AI for Novice Programmers.” Proceedings of the 2024 ACM Conference on International Computing Education Research - Volume 1 (Melbourne VIC Australia), August, 469–86. https://doi.org/10.1145/3632620.3671116.
Shen, Judy Hanwen, and Alex Tamkin. 2026. How AI Impacts Skill Formation. arXiv. https://doi.org/10.48550/ARXIV.2601.20245.
Smith, David H., and Craig Zilles. 2024. “Code Generation Based Grading: Evaluating an Auto-Grading Mechanism for "Explain-in-Plain-English" Questions.” Proceedings of the 2024 on Innovation and Technology in Computer Science Education V. 1 (Milan Italy), July, 171–77. https://doi.org/10.1145/3649217.3653582.
Vaswani, Ashish, Noam Shazeer, Niki Parmar, et al. 2017. “Attention Is All You Need.” Advances in Neural Information Processing Systems 30: 5998–6008. https://papers.nips.cc/paper_files/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa-Abstract.html.
Veracode. 2025. 2025 GenAI Code Security Report. Veracode. https://www.veracode.com/wp-content/uploads/2025_GenAI_Code_Security_Report_Final.pdf.