Skip to content

Instantly share code, notes, and snippets.

@savarin
Last active June 27, 2026 16:28
Show Gist options
  • Select an option

  • Save savarin/ac8188f71656f38c0817c3ce87241d8e to your computer and use it in GitHub Desktop.

Select an option

Save savarin/ac8188f71656f38c0817c3ce87241d8e to your computer and use it in GitHub Desktop.
The Rewrite: Python Edition — Index

The Rewrite: Python Edition

Why throw away 132 working files and start over? This book follows a real rewrite of an agent runtime — v1 forked from an agent engine, v2 built from the ground up — and examines 14 dimensions where the two made different choices. Code examples are presented in Python.


Front Matter


Part 0 · The Rewrite Decision

# Chapter Focus
1 The Turn That Couldn't Crash v1's monolithic await, topology baggage, mid-migration shapes
2 Reading Other People's Runtimes Shape audit of claude-code and codex-rs across 9 dimensions

Part I · The Primitive

# Chapter Focus
3 Contracts 10 v1 seams vs 5 v2 seams; what survived and why
4 The Single Construction Seam SessionFactory as the one composition root
5 The Turn The 4-phase journal, AgentTurnJournal as a state machine

Part II · Durability

# Chapter Focus
6 The Journal Four phases, four points of no return
7 Resume and Repair classify_submission_state, 7 resume modes, pure-function recovery

Part III · Tools and the Sandbox

# Chapter Focus
8 Tools as Factories Trust-scoped tool factories with Pydantic validation
9 The Sandbox Boundary 11-operation SandboxApi contract, three backends

Part IV · Composition

# Chapter Focus
10 Workflows agent/parallel/pipeline DSL, coordinate paths, contextvars
11 The Sandbox Subprocess isolation, restricted builtins, DoS budgets

Part V · Distribution

# Chapter Focus
12 From Runtime to Fleet JSON-RPC transport, firewall, topology separation

Part VI · What Remains

# Chapter Focus
13 The Shape Gaps Seven ranked gaps (G0–G6), build order
14 Conclusion Three design moves: shape audit, single seam, durable envelope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment