CHAPTER 17 · Building the Full Mini-Harness · 1 / 10
Architecture overview
The pieces and where they came from:
+-------------------+
user request -----> | agent loop | <-- Chapter 2 (the spine)
+---------+---------+
|
+---------------------+----------------------+
| | |
+------v------+ +-------v-------+ +--------v--------+
| PromptBuilder| | ContextMgr | | Budget+Hooks |
| Ch 3 + Ch 9 | | Ch 4 + Ch 5 | | Ch 4 + Ch 12 |
| (instr+memory| | (tokens, | | (cost/turn caps,|
| +skills) | | compaction) | | PreToolUse) |
+------+-------+ +-------+-------+ +--------+--------+
| | |
+----------+----------+----------+-----------+
| |
+------v------+ +-------v-------+
| ToolRegistry| | ApprovalPolicy|
| Ch 6 | <--- | Ch 7 | every call is gated
| (+ MCP Ch10)| | (+ guardian) |
+------+------+ +---------------+
|
+------v------+
| subagents | <-- Chapter 11 (delegate, isolate context)
| Ch 11 |
+-------------+
The loop is the spine. Each turn it asks the ContextManager to compact if needed, asks the PromptBuilder to assemble the request (with memory and skills folded in), calls the model, and for any tool call runs it through Budget and Hooks and the ApprovalPolicy before the ToolRegistry executes it. When the model returns plain text, the turn ends. Optional extras: a planner and CodeAct action mode (Chapter 14), a review subagent (Chapters 11 and 13).