# Debugging & self-healing

> For the complete documentation index, see [llms.txt](/llms.txt)

When a step fails, the run **freezes on that step** instead of crashing. The same
paused state is available to both the agent and you.

## The agent's loop

1. The step throws → the runtime pauses.
2. The agent calls `inspect_runtime` — live DOM, variables, the last event.
3. It patches the scenario and calls `resume` from the same step — no browser
   restart, no re-running setup.

## Your loop (the viewer)

In the [viewer's debugger](/viewer/debugger/) you do the same visually: set
gutter breakpoints, run paused, inspect on each stop (**Vars / Call stack /
Trace / Breakpoints**), and step with **Continue / Step / Stop**.

```sh
npx @unotest/web e2e checkout --debug
```

## Self-healing is agent-assisted, never silent

`agent_fix` composes the failure context and a suggested fix — but it **does not
call an LLM itself and never applies a patch on its own**. The agent forms a
diff; **you review and commit**. That's the core balance: AI repairs, a human
approves. Tests are never changed behind your back.
