Each acceptance test we task our AI agent with creating needs a high-level goal: a short description of what the test should achieve.

At first glance, it might seem enough to say, “Write a test that checks if the gallery arrows can be hidden.” But the precision of this description matters. A vague goal invites exploration; a detailed one guides efficient progress. Both have their place, but the balance between them determines how quickly and accurately the agent can complete the task.

In my own work, I often generate the goal automatically from the feature’s code itself. That is, I pass a short, vague goal and the feature code itself to an LLM and ask it to produce a more detailed goal. By doing so, the prompt can include rich, specific detail: the names of settings, where in the UI they appear, and what the expected outcome should look like. That level of clarity gives the AI a running start — it doesn’t have to guess what “success” means.

Here’s an example of such a goal:

“Please create an acceptance test that demonstrates how to hide the navigation arrows in the Divi Gallery module slider layout using the ‘Show Slider Arrows’ setting added by the Divi Gallery Booster plugin. First upload two images to the WordPress media library using direct Codeception commands (not the media loader). Then add a new page and open it for editing in the Divi Builder, dismissing any onboarding popup if shown. Insert a single-column row and add a Gallery module. In the Gallery module, click ‘Add Gallery Images’, switch to the ‘Media Library’ tab, select the two uploaded images, and insert them into the gallery. Go to ‘Gallery Settings > Design > Layout’ and set the layout to ‘Slider’ so the slider arrows would normally be shown. Then go to ‘Gallery Settings > Content > Elements’, locate ‘Show Slider Arrows’, and set it to ‘No’. Publish the page. View the page on the front-end and confirm the gallery slider is visible. Hover over the gallery to attempt to reveal the arrows and verify that they remain hidden by asserting that the arrows container ‘.et-pb-slider-arrows’ inside the gallery has a computed CSS display value of ‘none’ and its previous/next arrow links are not visible.”

That may seem long-winded, but for an agent it’s gold — a clear description of the environment, the actions to perform, and the conditions for success.

From One Goal to Many

Once the AI receives this high-level goal, it doesn’t attempt to complete it in one leap. Instead, it breaks it into smaller, verifiable sub-goals, each representing a step toward the overall objective.

Looking at the example above, the AI might identify sub-goals such as:

  1. Upload images to the media library.
  2. Create and open a new page in the Divi Builder.
  3. Insert a Gallery module.
  4. Set the layout to “Slider.”
  5. Disable the “Show Slider Arrows” option.
  6. Publish the page.
  7. Verify the arrows are hidden on the front end.

Each of these sub-goals is concrete enough that the AI can attempt it, observe the result, and decide whether it succeeded. The process becomes a sequence of clear checkpoints — each one small, self-contained, and testable.

Identifying the Current Sub-Goal

Using the partially constructed acceptance test as a reference, the agent can determine which sub-goals have already been completed. For those that remain, it selects one as the current sub-goal. This is the next bite-size chunk of work it will tackle. Typically, the sub-goal will be small enough that it can be completed with five or fewer individual UI actions. That’s not a hard-and-fast rule, but anything requiring more steps than that, but if the sub-goals are too granular there is a risk that the agent will get lost along the way.

Choosing the Next Step

Once the agent knows its current sub-goal, it examines what it has already accomplished and what remains undone. It looks at the captured browser state — the HTML, the screenshot, the page structure — and identifies the user interface operations currently available to it. From there, it reasons: Which action brings me closer to my goal?

If the current sub-goal is “Publish the page,” and the screenshot shows a visible “Publish” button, it might select the action “Click the publish button.” Performing that operation becomes the next step in the acceptance test.

In this sense, the agent’s reasoning is always local. It doesn’t plan the entire journey at once; it looks one step ahead and tries to accomplish that step.

Each time it succeeds, that action is appended to the growing test — a script that represents verified progress.

The Power of Clear Objectives

Designing goals and sub-goals may sound like a small technical detail, but it’s the scaffolding that holds the whole process together. A well-defined goal gives the agent direction; precise sub-goals give it grip.

The more clearly we define success, the faster and more confidently the AI can reach it.