Back to Learn Jev
Starter project 08 · Agent loops

Browser next-step lab

Let Jev choose among indexed page actions while a deterministic harness owns the browser.

Time
90 min
Level
Controlled agent loop
Shape
Visible page state → next-action choice → validated browser step
You’ll practice
Action spaces · Observe/decide/act · Loop limits

The agent prompt

Copy this brief into your coding agent from the root of the project you want to build in. It names the behaviour, the constraints, and the checks to run — the decisions Jev makes stay explicit so you can see what the model actually decided.

Build a safe "Browser next-step lab" in this repository with Jev from TypeSafe AI and the browser automation library already present in the project, or Playwright if there is none.

Inspect the repo and follow its conventions. Use the official TypeSafe skill, installing it with npx skills add typesafe-ai/skills --skill typesafe-ai if necessary.

Create a local demo page with a three-step form. The harness observes only visible, indexed interactive elements plus the current goal. Ask Jev one Choice question to select the next allowed action ID, with stop and ask_for_help options. Deterministic code validates and executes the selected action. Show an event timeline with observation, probabilities, chosen action, and outcome.

Requirements:
- Run only against the included local fixture site; block arbitrary URLs.
- Never let model output become code or a selector. Choices must be predeclared action IDs.
- Add a maximum step count, duplicate-action loop detection, confidence gate, and emergency stop.
- Keep TYPESAFE_API_KEY server-side and redact typed secrets.
- Test the policy and loop with mocked decisions; live API tests must be opt-in.
- Document the trust boundary and how to add new fixture scenarios.

Run the full relevant suite and explain the observe/decide/act boundary.

Built something like this

Community projects in the directory that solve a similar problem: