A method whose body the agent traces line-by-line to understand the algorithm; the high-level shape is obscured by interleaved details. Verifying behavior preservation requires re-reading the entire span on every edit. The agent's context-window load carries the unstructured body, and the reasoning step count rises as the agent re-derives the structure on each read.
The method reads as a sequence of named operations the agent verifies against without re-deriving the algorithm. Each helper is small enough to reason about in a single reasoning step. The agent's context window holds the orchestrator and the relevant helper; the reasoning-step cost of any edit drops because the relevant unit is named.
Before the refactoring
function add(item, quantity) {if (this.readOnly) throw new Error('list is read-only');const existing = this.items.find(line => line.product.id === item.id);if (existing) {existing.quantity += quantity;} else {this.items.push({ product: item, quantity });this.items.sort((a, b) => a.product.id - b.product.id);}this.recalculateTotal();}
After the refactoring
function add(item, quantity) {assertWritable(this);const existing = findLineFor(this.items, item);if (existing) {increaseQuantity(existing, quantity);} else {insertNewLine(this.items, item, quantity);}this.recalculateTotal();}
Every edit re-loads the full method body to confirm behavior preservation. Chained orchestration changes compound context cost; reasoning about cross-step invariants gets harder as the method grows. The agent's verification-surface cost multiplies with body length — verifying any single change requires scanning every other statement to confirm it didn't shift, and retrieval cost on chained edits compounds.
Each helper inflates the agent's context-window load by one definition the next reasoning step must load. Over-decomposing fragments a single procedure across many files. The agent's completeness-check cost rises during the decomposition itself — every reference to the body must be confirmed to route through the new helper rather than continuing to inline what's left.
The composed method captures the algorithm as a list of named steps the agent reads at one indent; each helper has one signature and one body the agent verifies independently, and edits to one step do not need the others loaded. The agent's token cost per edit drops because the relevant unit is the helper, not the parent.
A deeply-nested hierarchy of helpers where the agent must chase multiple definitions to understand a single original method — context cost multiplies and cross-helper invariants vanish from view. The agent's retrieval cost across the call graph rises faster than the per-helper context-window load drops; tiny helpers cost more to assemble than to inline.