đ§ Week 4 Live Walkthrough: One Real Model Through Five Modules
The nine day checks prove your mechanisms with scripted models. This walkthrough shows the same mechanisms working with a real model: the supplied Week 4 implementation on the Week 2 reference engine and a cached Qwen3-4B, through all five modules of the week. It doesnât run your code, so it works at any point. It makes the most sense after Day 9, once you have built every piece it uses.
| Module | Days | What you watch the real model do |
|---|---|---|
| Control | 1 | Propose one JSON action at a time, through generate_response() and a fresh growing cache |
| Effects | 2, 3 | Read the fixture, make the approved edits, and leave receipts |
| Sessions | 4, 6 | Pause after a complete observation, take a steering message, and resume |
| Context | 5, 9 | Compact completed work and read oversized evidence by range, measured in real tokens |
| Branches | 7, 8 | Continue twice from one shared prefix, then accept the branch you name only if its Day 7 report passes |
The deterministic capstone
(pdm run week4-capstone) and the
confined fixture
(--autoreject-fixture) stay as they are. They are the repeatable checks.
This walkthrough is the live run. The real model can depart from the
fixtureâs guide, so a run doesnât always finish.
Before You Start
- Complete Setup and build the reference extension with
pdm run build-ext-ref. - Have the
Qwen/Qwen3-4B-MLX-4bitsnapshot in your local Hugging Face cache from Setup. The walkthrough never downloads. If the snapshot is missing, it stops with an error instead of fetching it.
Run it from the checkout root:
PDM_CHECK_UPDATE=false pdm run --skip pre_run agent -- --live-fixture
It starts in a fresh temporary workspace that holds only the fixture files. It allows only the named reads and edits, validates fixture bytes with a fixed in-process check, and refuses anything else before it has an effect. Tool calls and generated tokens both have fixed budgets.
What You Will See
The fixture guides the model. At each step, its prompt gives the exact JSON action to take next and asks the model to copy it. The guide, the allowed effects and the Day 7 evaluation criteria are fixed. The modelâs reply still goes through your harness like any other, and it can depart from the guide. If it does, the run stops early or a branch report fails.
The run prints one labelled line for each stage, such as pause>,
context>, branch> and selected>. Most carry a JSON object. The
counts and passing reports below are what one successful run observed.
They arenât guaranteed for every run.
Control and Effects
The model proposes actions, and the harness decides what happens. In the
fixture, the model reads app.py, makes the approved edit and validates
it. A write it wasnât approved to make is refused before anything is
written. The run then pauses and prints a pause> line that summarizes
this first stage:
last_action: the modelâs last action, aread_fileofapp.py.last_observation: the editedapp.py, which now returnsWelcome, {name}!.checkpoint_tokens: how many tokens the paused conversation holds, 671 in the verified run.denied_unapproved_write:true, for the refused note.receipts: the edit and validation receipts. Each records an approved effect.
If the model answers before it has read the file, the run stops with an error. A guess never counts as success.
Sessions: Pause and Resume
The run pauses after a complete action and observation, never in the
middle of a tool call. After the pause> line it prints
resume> type resume to continue. Inspect the paused state, then type
resume.
- How long the checkpoint lasts: it lives inside the running process
until you resume it or the process exits. Exit at the prompt and the
checkpoint is gone. There is no resuming it from a new process. Typing
anything other than
resumestops the run. - What resume keeps: the run continues from the saved conversation, and no completed effect runs again. Before you choose a branch, the run checks that the original workspace and receipt log are unchanged.
Steering comes in the next stage. Each branch adds its own visible, fixed Day 6 steering message to the checkpoint before it continues.
Context: Real Token Counts
The capstone counts characters. This run counts the modelâs own tokens.
- Compaction: the first
context>line showstokens_beforeandtokens_after, measured with the Week 2 tokenizer, plus thereceipt_idsthe compacted view keeps. In the verified run it went from 671 to 494 tokens. - Oversized evidence: each branch prints a
context>line with itsbranchname. It shows the fullartifact_bytes, theinline_bytesthe model sees, and the exactrange_bytesandrange_textit reads back. In the verified run, both branches stored 1,053 bytes, showed the model 512, and read back the exact first 63 bytes.
Branches: Shared Prefix, Separate Effects, Your Choice
The run continues twice from the compacted checkpoint, each branch with its
own steering message. For example, validate-only adds âKeep the changed
greeting and only validate the existing files.â The validate-only branch
validates without another edit. The add-notes branch writes a fixed note first, then validates.
Each prints a branch> line.
- Cache reuse:
reused_tokensand thecacheobjectâslayer_offsetsshow that both branches started from the same KV prefix, built by the Week 2 tokenizer and cache. In the verified run, each branch reused the whole 494-token compacted prefix at all 36 layers. Thecacheobjectâsinput_tokensshows what each branch still had to prefill: only its steering message and the tokens after it, 65 and 77 tokens. - Separate effects: each branch works in its own copy of the workspace,
with its own receipt log.
changedlists the files that branch modified, andreceiptsits effects. Each branch starts with the receipts from before the pause. In the verified run,validate-onlywrote no new file and added one validation receipt.add-noteswroteNOTES.mdand added write and validation receipts. Before you choose, the run checks that neither branch touched the original workspace or the other branch. - Report:
reportis that branchâs Day 7 evaluation, andpassedis its result. In the verified run,validate-onlypassed 8 checks andadd-notespassed 10. - Selection: after both reports, the run prints
select> type validate-only or add-notes. Type the branch you want. The run accepts it only if that branchâs Day 7 report passes, as on Day 8. A failing branch is refused with an error. The run never picks a winner for you. An accepted choice prints, for example,selected> {"name": "validate-only", "passed": true}. In the verified run both branches passed, so either name would have been accepted.
What This Run Proves, and What It Doesnât
It shows the weekâs mechanisms working around a real model: effects confined to the fixture, receipts that survive a pause, real token and cache accounting, and a selection the Day 7 report gates. It doesnât prove the model can plan the task on its own, since it follows a fixed guide, and it doesnât measure speed. A run can stop early or fail a report when the model departs from the guide. Use the day checks and the capstone for repeatable results.
Your feedback is greatly appreciated. Join our Discord community.
Found an issue? Open an issue or pull request at github.com/skyzh/tiny-llm.
tiny-llm-book © 2025 by Alex Chi Z is licensed under CC BY-NC-SA 4.0.