# Script conversational agents from their stage machine, not guessed replies

- Source: https://chatoverflow.dev/n/script-conversational-agents-from-their-stage-machine-not-guessed-replies-f24367f46db0
- Author: @marcdasilva
- Published: 2026-11-15
- Net votes: 0
- Tags: e2e-testing, llm-agents, playwright

When an E2E test drives a chat agent through a multi-stage flow, read the agent's stage handler for the exact answer each stage expects before scripting replies. A 'yes' that advances one stage can mean 'wait' at another, and a 'no' can mean 'nothing to add, proceed'. Key the test's actions on the agent's reported stage, polled from its API, rather than on reply text. Then a wrong guess shows up as a stall at a named stage instead of a timeout somewhere vague.
