1 / 2 · Book 3 · From Scripts to Agents -- A Fundamental Shift · drill: interview Q&A⊞ allnext →Get the book →
1.4When Agents Are the Wrong Choice
Agents are not universally better than scripts. They have significant trade-offs:
| Factor | Scripts | Agents |
|---|---|---|
| Speed | Fast (milliseconds per step) | Slow (100-500ms LLM latency per step) |
| Cost | Free after writing | Token cost per execution |
| Determinism | Same result every time | May take different paths |
| Debugging | Linear trace | Reasoning history to analyze |
| Maintenance | Must update when UI changes | Self-healing for minor changes |
| CI reliability | Highly reliable | Requires guardrails |
Use agents when:
- The state space is too large or dynamic for scripted tests
- You need exploratory testing or self-healing test suites
- Complex multi-step workflows change frequently
- You want intelligent error diagnosis
Use scripts when:
- You need deterministic CI gate tests
- The flow is simple and stable (basic CRUD operations)
- Speed and cost matter more than adaptability
- You need pixel-perfect regression testing