"Many mechanisms, one loop" — tools, permissions, memory, tasks, teams, and plugins all hang on the same while True.
Congratulations on making it here! Now you've learned all the foundational content from the previous 19 chapters, thank you for your hard work!
The Problem
As the original text says, each of the previous 19 chapters added only one module, because ease of teaching and learning had to be considered, but it goes without saying that a real Agent must have all of these:
Tool dispatch and permission boundaries
hooks extension points
todo planning and task graphs
skills, memory, system prompt assembly
compaction and error recovery
background tasks and cron scheduling
teams, protocols, autonomous claiming
worktree isolation
MCP external tool integration
The hard part isn't stacking up features, but seeing clearly where each of them attaches to the loop. This chapter fully applies the harness mindset — putting every component back in its place.
The Solution
This time, we finally don't need to add anything new — this time, we just combine everything into a complete harness:
用户输入
→ UserPromptSubmit hooks
→ cron/background 通知注入
→ context compact
→ memory + skills + MCP 状态组装 system prompt
→ LLM
→ has tool_use block?
否 → Stop hooks → 返回
是 → PreToolUse hooks + permission
→ TOOL_HANDLERS / MCP handlers / background dispatch
→ PostToolUse hooks
→ tool_result / task_notification 回 messages
→ 下一轮The loop itself is still the same structure:
Call the model and check whether the response contains a
tool_useblockExecute the tool and append the result back to
messages(the CC source code also doesn't truststop_reason == "tool_use"directly, but uses the actual tool_use block that appears as the signal for whether to continue the tool round).
What really changes is that the harness around the loop becomes complete.
78 likes
You can like once today