Self-healing
How Cofactor replays a test quickly, repairs the step that broke when your UI changes, and what that uses from your plan.
Each step of a test says what to do in plain words. The first run uses an agent to do each step and records how it did it. Later runs replay that record, which needs no AI while a step still works. When your UI changes and a step stops working, an agent redoes only that step and the run carries on.
See how a test is replaying
-
Find the run. Look up the test, then list its runs. The newest run may have failed, so pick the one you want to read.
bashcofactor workflow list --search "invoice" cofactor workflow runs list <workflow id>
-
Read the cache summary. The overview prints the share of steps that replayed.
bashcofactor workflow debug <run id>
The line to read looks like
cache: 92% hit (11/12). A hit is a step that used its recording. A miss is a step that did not, and the reason says why. -
List the steps that did not use a recording. The reason
no_prior_cachemeans the step has no recording yet, so an agent did it fresh. The reasonreplay_failedmeans the recording stopped working and an agent took over.debug stepsshows each step's status and cache source.bashcofactor workflow debug cache <run id> --misses-only cofactor workflow debug steps <run id>
In the app, open the run and read the steps list. A step replayed from its recording is marked Cached. Playbook means an agent followed the recorded steps. Heal means a repair fixed a failed recorded action and the replay then finished. A step an agent did from scratch is marked Agent.
The steps list of a run. One step shows a Playbook 3/3 badge because an agent followed its recorded steps, and another step shows an Agent badge because an agent did it from scratch. -
Read the test's health. It prints values such as passing, flaky and failing.
bashcofactor workflow status <workflow id>
What heals and what doesn't
Cofactor tries the cheapest way first and stops at the first one that works.
| How the step runs | When | Uses an agent |
|---|---|---|
| Replay | The recorded way still works. | No |
| Repair | A recorded step no longer works. The agent redoes that step from its description and saves the new way. | Yes, for that step |
| Fresh | The step has no record yet, or you changed it. The agent does it from scratch. | Yes |
It heals a button that moved, a label that changed or a field that was renamed. These change how a step finds things, and the test still means the same.
It does not hide a real bug. If the app is wrong, the step or its assertion fails, and the run fails. Replay runs your assertions again every time. It never reuses an earlier result.
It leaves what a test checks to you. By default Cofactor changes how steps run. If the app changed on purpose and the test should check something different, you update the test. Assertions that need judgment, such as a chart that should look right, use an agent on every run.
It cannot fix a test that depends on yesterday's data. Create fresh data in each run, with macros, so a rerun starts clean.
What it costs
Replaying a step that still works uses compute only, counted in vCPU-hours. AI credits go to agent work: repairing a step, running a step fresh, following a recorded playbook, judging an assertion with the agent and diagnosing failures. On Free, AI work stops when credits run out. See Plans and limits.
When a test keeps failing
Cofactor tracks each test's health from its recent runs. A test that is in a suite and has passed before becomes degraded after five failures in a row. Automatic runs skip it until you edit it or re-enable it, so one broken test does not slow every run.
Open the failing run with cofactor workflow debug <run id>, fix the test or the app, then run it again. For a failed suite run, cofactor triage get <execution id> groups the failures by cause. It is a beta feature.
Check it worked
The run overview shows a cache hit rate, and debug cache --misses-only lists each step that did not use a recording, with the reason. cofactor workflow status <workflow id> shows the test's health. After the UI changes and one run repairs a step, the next run shows that step as a hit.
Go deeper
- End-to-end tests covers writing steps that replay well.
- Suites and schedules covers what skipped and paused tests mean.
- Reference: Caching, Cache optimization, Author repeatable cached tests
- Run
cofactor workflow guide playbookfor how steps are recorded.
Auto-maintain, replay-only runs and resetting a cache.
Auto-maintain. An organization admin can turn it on in Settings, then Workflows. The maintenance agent then fixes flaky and outdated tests without asking. It may run tests live against your app, edit tests, file issues and update your product map. It asks you a yes or no question when it cannot tell whether a change was intended. Every change shows in the test's Activity tab. Run cofactor workflow feedback list --workflow <id> to see its questions.
Replay-only runs. cofactor workflow run <id> --cache-only replays recorded steps and fails at the first one that cannot replay. It is a real run, so it makes the same changes in your app that the test does. Login steps and steps set to always use the agent still run their agent.
Reset. cofactor workflow cache status <id> shows each step's cache. cofactor workflow cache clear <id> --mode all marks every cache invalid. --mode hard --yes deletes them instead, and the next run records everything again.