Files
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

8.3 KiB
Raw Permalink Blame History

theme, title, info, author, transition, mdc, lineNumbers, monaco, aspectRatio, canvasWidth, layout, class
theme title info author transition mdc lineNumbers monaco aspectRatio canvasWidth layout class
seriph Lesson 18 — Why Is Code Generation Not Enough to Build a Coding Agent? English video course for AI Agents in Depth Bojie Li slide-left true false false 16/9 980 cover 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
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

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

$ 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 inspectmodifyverify 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.