---
theme: seriph
title: "Lesson 18 — Why Is Code Generation Not Enough to Build a Coding Agent?"
info: "English video course for AI Agents in Depth"
author: Bojie Li
transition: slide-left
mdc: true
lineNumbers: false
monaco: false
aspectRatio: 16/9
canvasWidth: 980
layout: cover
class: cover
---
Build · Chapter 5 · Coding Agents
# Why Is Code Generation Not Enough to Build a Coding Agent?
Files, execution, harness recovery, and bounded verification
Lesson 18 of 42 · 18 minutes · Coding as a Foundational Capability; Sessionless Design; Harness Engineering; Failure Recovery
---
Build · Chapter 5 · Coding Agents
# Problems this chapter will solve
Lesson 18
Why Is Code Generation Not Enough to Build a Coding Agent?
Lesson 19
When Should an Agent Think in Code Instead of Words?
Lesson 20
How Can an Agent Create Media It Can Actually Verify?
Lesson 21
How Can Code Let an Agent Create New Capabilities?
---
# Why this problem matters
Workspace
Files provide durable, inspectable state outside the context window.
Action
Search, editing, and execution tools let the Agent change that state.
Evidence
Compilers, tests, and renderers expose mistakes independently.
---
# Three ideas to keep in view
Inspect
Search before reading; locate the smallest relevant surface
Modify
Apply localized, reviewable edits
Recover
Classify evidence, revise one hypothesis, and stop safely
---
# The book's visual model
Coding Agent workflow
---
# Chat code generation vs. Coding Agent
Chat code generation
- Produces a snippet
- Cannot observe repository state
- Leaves verification to the user
Coding Agent
- Navigates a workspace
- Executes and revises
- Stops with evidence
A workbench and recovery loop turn generation into engineering.
---
# Verification drives the next action
~~~python
for attempt in range(max_attempts):
patch = edit(inspect(task, workspace))
evidence = verify(patch)
if evidence.passed: return commit(patch)
task = revise_hypothesis(evidence)
return stop_safely(evidence)
~~~
---
# Test the claim
Coding workflow2 min
Run a write-search-edit-verify workflow
Observe: A real file moves through write, search, localized edit, and independent verification
Harness tests1 min
Run editing and shell-session contracts
Observe: Exact-match edits, failure messages, state preservation, and safe boundaries
Demo budget: 3 minutes · one contiguous terminal block
---
class: course-terminal
---
Live demo
# Switching to the terminal
~~~bash
$ uv run pytest -q chapter5/coding-agent/tests/test_integration.py::TestToolChaining::test_write_search_edit_workflow
$ uv run pytest -q chapter5/coding-agent/tests/test_edit_tool.py chapter5/coding-agent/tests/test_shell_session.py
~~~
Run the command(s), narrate decisions, and point to the observation—not just the output.
---
# What the evidence supports
Finding 1
Files make Agent state durable, inspectable, and reproducible.
Finding 2
Tool and test failures become observations that guide the next hypothesis.
Finding 3
A reliable loop distinguishes verified success, safe incompletion, and unsafe failure.
---
layout: center
---
Where the claim stops
# Boundary condition
Passing available tests proves only their covered properties; the same workbench also exposes credentials and destructive commands.
---
layout: center
---
Engineering takeaway
# Design rule
Treat coding as a bounded inspect–modify–verify loop, with an evidence-driven recovery path for every failure class.
---
# Continue the experiment
---
layout: center
class: text-center
---
Pause and apply
# Your turn
Which verifier would give your coding Agent genuinely new evidence after a wrong edit?
---
layout: center
class: text-center
---
Next · Lesson 19
Use code to improve reasoning and enforce strict business rules.
→