> ## Documentation Index
> Fetch the complete documentation index at: https://e2e.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How agent steps work

> Learn how an agent step runs in e2e, from what the AI model sees and which actions it may take to how a step ends and what it costs in model calls.

An agent step is one `agent.act`, `agent.assert`, `agent.waitFor`, or
`agent.extract` call. The model reads the screen, asks for actions, and ends
the step with a verdict. Every step has a deadline and a model-call budget.

## Who does what

The executor chooses the actions and returns the verdict. The runner
redacts the screen, authorizes and performs each action, enforces budgets,
fills secrets, and writes the report. The built-in agent is the executor
unless the agents entry sets a [custom one](https://e2e.com/docs/executors).

## What the model sees

For `act`, the first prompt holds the instruction, the params, the completed
steps, and a redacted text snapshot of the screen: roles, names, text, and
states. It holds no raw HTML, cookies, headers, or environment values.
Password fields are masked, unless a page script hides one from e2e
([where redaction stops](https://e2e.com/docs/reference/security#where-redaction-stops)).
A configured secret value on screen becomes `<secret:name>`.

After an action, the model gets the changes to the screen, or a new full
snapshot when most of it changed. Node ids stay the same while their
elements exist. A failed action also returns the current screen, so the
model can choose its next action.

Default judgments from `assert`, `waitFor`, and `extract` see the instruction,
the current screen and its location, and the agent's `context`, never completed steps or the
acting agent's summaries. They can use a separate [judge model](https://e2e.com/docs/models#a-judge-of-its-own).
Built-in exploring assertions use `agents.<name>.model`, even when `judge` is set.

`vision: true` adds a masked screenshot, and `vision: 'only'` judges the
screenshot alone. See the [agent reference](https://e2e.com/docs/reference/agent#vision) for
the modes. Screenshots mask secure fields only
([after a secret fill](https://e2e.com/docs/reference/security#screenshots-after-a-secret-fill)).

## What the model may do

The agent gets whatever action tools the target engine supports (`tap`,
`type`, `press`, `select`, `scroll`, `navigate`, focused keyboard input, and
coordinate-based pixel actions when the accessibility tree isn't enough).
See the [tool reference](https://e2e.com/docs/reference/agent#pixel-tools-screenshot-and-the-point-verbs).

For a `Secret` param, the model calls `type_secret` using only the secret's
name and purpose. e2e validates the field and types the real value itself
so it never enters prompts, transcripts, reports, or AI traces.

Targeted actions time out after 15 seconds. You can also expose custom
operations with [project tools](https://e2e.com/docs/tools).

To avoid duplicate submissions, the built-in agent only clicks Save/Submit
buttons once unless the screen clearly shows the submission didn't go
through (like a validation error) or the tap only dismissed the keyboard.
A silent save with no visible confirmation can end the step as `failed`, so
tell the agent how to confirm it, for example `"save the product, then
confirm it appears in the product list"`.

A built-in loop guard catches repeated failures, cycles, or long stalls on
an unchanged screen, prompting the agent to wrap up with a verdict before it
burns its budget or hits the deadline.

<Accordion title="Loop-guard thresholds and same-turn verdicts">
- **Failed actions:** the loop warns after 3 consecutive failed actions and
  asks for a verdict after 5.
- **Repeated observations:** `observe` or `screenshot` calls warn after 6
  looks without a change to the listing, location, or tabs (verdict at 10),
  or 12 total consecutive looks even when the screen changes (verdict at 20).
- **Same-turn verdicts:** when a step only asks for actions, the agent can
  send its verdict in the same turn as its last action to save a model call.
  The runner refuses that verdict if an earlier action failed or the last
  action changed nothing.
</Accordion>

## Assertion exploration

With `explore: true`, `agent.assert` can scroll and combine evidence from several
viewports using read-only tools. The viewport remains where exploration ends.
Use it for content elsewhere on the current screen, and `waitFor` for changes over time. See
[assertion exploration](https://e2e.com/docs/reference/agent#agent-assert) for tools, budgets, and verdicts.

## How a step ends

A step ends with one of three verdicts:

- `passed`: the screen shows that the step succeeded.
- `failed`: the required condition is false or can't be shown. Too little
  evidence is `ASSERTION_INCONCLUSIVE`.
- `blocked`: a prerequisite, the environment, or a limit stopped the step
  before a product verdict. The error code sets the exit code.

Only `failed` and `blocked` carry an error code.

| Blocked by | Codes | Exit |
| --- | --- | ---: |
| A credential the app rejected, or one that is not configured | `AUTH_CREDENTIAL_INVALID`, `AUTH_CREDENTIAL_UNAVAILABLE` | 2 |
| An environment that is down | `ENVIRONMENT_UNAVAILABLE` | 3 |
| Seed data or a prerequisite outside the product that is not there | `SEED_DATA_MISSING`, `TEST_SETUP_FAILED` | 2 |
| A budget or the clock | `STEP_BUDGET_EXHAUSTED`, `STEP_TIMEOUT` | 1 |
| An interaction the toolset cannot perform | `AUTOMATION_UNSUPPORTED` | 1 |

The [errors reference](https://e2e.com/docs/reference/errors#agenterror) lists every code a
verdict can carry.

## What a step costs

Each call has a model-call budget and a default timeout. See
[budgets](https://e2e.com/docs/reference/agent#budgets).

- `assert` without exploration and `extract` make one judgment, plus one repair call if the
  answer is malformed. When the data is not on screen, `extract` fails with
  `ASSERTION_INCONCLUSIVE` and returns no placeholder.
- `waitFor` makes no model call while the screen and its location stay the same.
- A screenshot adds input tokens to every call that carries it. `act` asks
  for one only when the text snapshot is not enough.
- The [replay cache](https://e2e.com/docs/cache) reruns passing `act` steps with no model calls.
- Under a [custom executor](https://e2e.com/docs/executors#what-the-executor-handles), `assert`
  uses the `act` budgets.

Use `expect` for exact checks, and give each `act` the
steps toward one [goal](https://e2e.com/docs/core-concepts#goals). When the provider caches prompts,
`--debug` shows the cached share of input tokens per step.

## Split a long flow into goals

Start with one `agent.act` call for the behavior under test. Split it at a
meaningful transition when the next step needs a known state (such as the
payment page of a long checkout), when a long flow risks the `maxSteps` or
`maxModelCalls` budgets, or when a failure in the middle needs its own step
boundary. Say why the split is needed, and wait for the intermediate screen
state before you continue. Each call has its own
[budgets](https://e2e.com/docs/reference/agent#budgets) and can replay from its own recording.

```ts title="Complete one checkout across two screens"

test('places an order with a saved card', async ({ app, agent, screen }) => {
  await app.open('/checkout');

  // The saved card can load after the Payment heading appears.
  await agent.act('Fill the Shipping address with {address}, then choose Continue to payment.', {
    params: { address: '12 Market Street' },
  });
  await screen.getByRole('radio', 'Test card').waitFor();
  await agent.act('Select the saved Test card and choose Place order.');

  await expect(screen.getByText('Order confirmed')).toBeVisible();
});
```

- **Wait after setup, assert at the end.** When setup uses `agent.act`, end
  setup with a wait for the starting state, and check the final outcome in
  the assert block. A later passing verification check, such as a locator
  assertion or `locator.waitFor()`, confirms earlier goals for the
  [replay cache](https://e2e.com/docs/cache#when-a-recording-is-written). An `expect` on a plain
  value and `expect.poll` do not.
- **Match the UI's wording.** Use the field and button names shown on
  screen, and say the order when it matters, such as filling shipping info,
  picking a delivery option, then placing the order.
- **When a goal fails, tighten the instruction.** Terms that every goal
  shares go into the agent's [`context`](https://e2e.com/docs/agents) instead.

## Next

<CardGroup cols={2}>
  <Card title="Project tools" icon="wrench" href="/tools">
    Add your own tools to the agent.
  </Card>
  <Card title="Custom executors" icon="gears" href="/executors">
    Keep the loop with your prompt, or replace it.
  </Card>
</CardGroup>
