Chapter 6 - Layer 2a: Working Memory and the Scaffolding Loop
Loop Engineering by Fabio Correa, the Applied AI foundation volume on working with AI through framing, feedback, verification, memory, and human judgment.
Last updated 2026-10-25. This page hosts the seven primitives (the cover's design commitments), the NOTES.md externalized-scratchpad pattern, and the loopmaxxing failure mode that appears when the discipline degrades.
The question this chapter takes up
How does work survive a context limit, a compaction, or a brand-new session without starting over?
Put it to work
Open the working-memory worked example, then draft a scratchpad contract for one multi-iteration task.
Key sources
Chapter 6 cites in the print book: D8, D9, D24, D25, D30, D32, D33, D34, D57, D58, D60. Entries below are the sources this page draws on; some are related literature cited elsewhere in the book rather than in this chapter.
- D8 - Huntley, G. (2025). Ralph Wiggum as a Software Engineer. ghuntley.com/ralph/
- D11 - Willison, S. (2025). Designing agentic loops. simonwillison.net/2025/Sep/30/designing-agentic-loops
- D22 - Anthropic. (2025). Effective context engineering for AI agents. anthropic.com/engineering/effective-context-engineering-for-ai-agents
- D23 - Runkle, S. (2026). The Art of Loop Engineering. LangChain. langchain.com/blog/the-art-of-loop-engineering
Primary-source links
- Huntley, "Ralph Wiggum as a Software Engineer" - the original scaffolding-loop sketch: a bare bash loop with no exit condition, no iteration ceiling, and no kill switch. Chapter 6 calls it "a useful teaching object and a poor production default": its minimalism makes the missing control primitives visible, and a loop's quality depends on the task contract and the verifier, not on the loop alone.
- Willison, "Designing agentic loops" - names the discipline as the successor skill to prompt engineering.
- Anthropic, "Effective context engineering for AI agents" - first-party vendor guidance on what the working-memory layer should look like.
- Anthropic, "Effective harnesses for long-running agents" (2025) - Anthropic's design guidance for the operational scaffold around a model in long-running applications: context management, environment setup, persistent progress state, incremental work, and end-to-end testing.
- LangChain, "The Art of Loop Engineering" - framework-vendor framing that operationalizes the loop pattern.
Tooling note. Huntley's original sketch piped to claude-code. The book substitutes the current Amp CLI, amp, so the canonical loop reads while :; do cat PROMPT.md | amp -x ; done. Amp's -x execute mode runs a one-shot prompt, prints the response, and exits; it can also receive piped input.
Dates. Huntley published the Ralph pattern in July 2025. By June 2026, Osmani's loop engineering framing had popularized the term in trade-press language. The label changed quickly; the underlying mechanics did not.
Related resources
The book's Figure 6.1 is the translation table for the seven primitives: each primitive's failure mode and its mapping across the four practices. A working-memory worked example with a full NOTES.md trace and per-iteration state captures lives in the worked-examples section.