Patterns
Production-grade architecture patterns reverse-engineered from Claude Code's source. Deep dives into the systems that make agents work.
Agent Loop Architecture
How the core two-state machine drives every agent system, from the generator pattern through graceful cancellation, termination strategies, and error recovery.
Tool System Design
How tools are defined, registered, and dispatched in agent systems, covering concurrency partitioning, execution lifecycle, behavioral flags, dynamic tool sets, and the production patterns that make tool dispatch safe at scale.
Prompt Architecture
How the static/dynamic boundary in agent prompts affects cost, latency, and consistency, with the full assembly pipeline, five-level priority chain, memory injection, and production insights for cache management.
Memory and Context
How agent systems manage what the LLM sees, covering compaction pipeline internals, fact extraction subsystem, long-term storage with a closed taxonomy, and production insights for running memory management at scale.
Error Recovery and Resilience
How agent systems handle failure through a tiered escalation ladder, retryability classification, query-source partitioning, and a tool error pipeline that keeps the agent loop running even when individual tools fail.
Safety and Permissions
How a six-source permission cascade, five permission modes, and three resolution handlers keep agents within bounds, with denial tracking, shadow rule detection, and multi-agent permission forwarding.
Streaming and Events
How event-driven streaming delivers agent results as they happen, through typed events, producer-consumer pipelines, priority-based dispatch, capture/bubble phases, and a screen-diffing output model.
Multi-Agent Coordination
Why production multi-agent systems use delegation (not distribution): one coordinator decides what to do, specialist workers decide how. Covers spawning backends, file-based mailbox communication, session reconnection, and production trade-offs.
Command and Plugin Systems
How to build a scalable command registry that supports 100+ commands through metadata-first registration, lazy loading, and multi-source merging.
Hooks and Extension Points
How typed interceptors modify agent behavior at 27+ lifecycle events without touching core loop code: four execution modes, condition syntax, and error isolation.
MCP Integration
How the Model Context Protocol turns external services into agent tools: transport selection, tool bridging, and connection lifecycle management.
Observability and Debugging
Three independent observability layers for agent systems: structured event logging, per-model cost tracking, and session tracing with span hierarchy, each answering a different debugging question.