Compare
Symptom
Human

An opaque, convoluted, or hand-rolled algorithm where a clearer and well-known pattern (often library-provided) produces the same outputs.

Agent

The agent encounters a convoluted or hand-rolled algorithm where a well-known pattern produces the same outputs; reasoning about the bespoke version is expensive per read.

Goal
Human

An opaque or convoluted algorithm gets replaced by a clearer one (often from a library or well-known pattern) that produces the same outputs.

Agent

The clearer algorithm replaces the bespoke; the agent reasons about a recognized pattern instead of reverse-engineering the original.

Before the refactoring

function found(people, n) {
for (const p of people) if (p.name === n) return p;
return null;
}

After the refactoring

function found(people, n) {
return people.find(p => p.name === n) ?? null;
}
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure
Human

Future readers spend cycles decoding the bespoke version; correctness arguments stay local to this implementation; performance characteristics are unknown.

Agent

Every read of the bespoke algorithm pays the same decoding cost; the agent can't trust correctness without re-deriving the algorithm's invariants on every change.

Tradeoff
Human

Swapping algorithms wholesale forfeits behavioral safety — characterize the function with tests at every relevant input boundary before substituting.

Agent

Swapping algorithms wholesale forfeits behavioral safety unless every input boundary is characterized first; the agent that substitutes without characterization tests ships silent regressions.

Relief
Human

Future maintainers read the well-known pattern instead of decoding the bespoke implementation; performance and correctness usually improve.

Agent

The replacement algorithm has a known cost profile and known invariants the agent reads from one well-named function; verification against the new algorithm pays one read of its definition instead of simulating the original's behavior step by step.

Trap
Human

Swapping algorithms without characterizing every input boundary the original handled — including the off-by-one cases the original quietly got right that the substitute might get differently.

Agent

Substituting without characterization tests at every input boundary ships silent regressions where the original quietly handled edge cases the substitute handles differently.