Task contract for a browser agent (goal, limits, proof, stop)
"Book a service for me on the site" sounds like a request. For a browser agent, everything is missing: which page, what it can touch, how to prove it is done, and when to stop. In this lesson you write a task contract in four parts and check with a script that the contract is complete before handing it to any agent.
Goal: write the contract for a browser task with goal, limits, proof and stop, and check that it is complete.
01 · The four parts
Tap each block. Read from bottom to top when you review.
Click each block in the diagram to see what it does.
Without proof, the result is a promise. Without limits, the whole site is at stake. Without a stop, the agent keeps pushing until it makes things up.
02 · Writing each part
What conferir-contrato.mjs checks for, and why.
1. Goal
20 letters or more and a place: an address or a page name. "On the shop's site" won't do; "on the agendar.html page" will.
One task, one result. Two things become two contracts.
2. Limits
The script requires at least one "no": the agent needs to know what not to do. In a site test, almost always: don't confirm, don't pay, don't leave the address.
Data limits count too: "don't type a password", "don't use someone else's data".
3. Proof
A literal text, in quotes, that you can search for on the page. It's the same text the dry-run robot in lesson 6 will wait for.
Also ask for the evidence copied from the page: "return the times copied from the list, not from memory".
4. Stop
The signals (login, verification, confirmation) and a number: 10 actions, 3 attempts. The script requires a number.
Ask for a well-reported blocker: where it stopped, what's missing, and the action the person needs to take.
Well-reported blocker"I stopped at the account login screen of conta.html: it asks for email and password. Missing: the account owner's login. Nothing was sent." Better than "I couldn't."
03 · A complete contract and a vague one
The same script checks both. The part titles also work in English and Spanish (Goal, Limits, Proof, Stop; Objetivo, Límites, Prueba, Parada).
File · kit/contratos/exemplo.md
# Contrato: horários de troca de pneu
## Objetivo
Na página http://127.0.0.1:8433/agendar.html, descobrir os horários livres de "Troca de pneu" em 2026-11-03.
## Limites
Pode preencher o formulário e clicar em "Ver horários". Não clique em "Agendar às…" nem em "Confirmar". Não saia de http://127.0.0.1:8433/.
## Prova
A página mostra "4 horários livres para Troca de pneu em 2026-11-03." Devolva os horários copiados da lista, não de memória.
## Parada
Pare e descreva a tela se aparecer login, verificação humana ou pedido de confirmação. Pare depois de 10 ações sem chegar à prova.
Terminal · check the complete contract
cd ~/projetos/formacao-webmcp-navegador-v72/kit
node conferir-contrato.mjs contratos/exemplo.md; echo "saída: $?"
Terminal · check the vague contract
cd ~/projetos/formacao-webmcp-navegador-v72/kit
node conferir-contrato.mjs contratos/vago.md; echo "saída: $?"
All four parts are there, each with what the script checks for.
contrato incompleto: 0/4 partes · contratos/vago.md
falta: objetivo sem o lugar (endereço ou página)
falta: limites (o que pode e o que não pode)
falta: prova (o que se vê na página quando acabou)
falta: parada (quando parar e chamar a pessoa)
saída: 1
"Schedule a service for me on the shop's website" doesn't name the page, has no limits, no proof, and no stop. An agent with that request might click Confirmar.
04 · Practice
From vague to complete, and a contract for your site. Each exercise has a "done when".
E1 · Fix the vague one
10 min
Copy kit/contratos/vago.md to meu-contrato.md and rewrite it until the script accepts it. Use the conta.html page: the proof is the list of appointments, and the stop is the login screen.
Done when:node conferir-contrato.mjs meu-contrato.md → contrato ok: 4/4 partes and saída: 0.
E2 · A task from your own site
15 min
Write the contract for a real task on your site (local or staging), read-only. The proof must be text you can find on the page right now.
Done when:node conferir-contrato.mjs contrato-site.md → contrato ok: 4/4 partes, and the proof text shows up with Ctrl+F on the page.
05 · Lesson quiz
Question 1 of 4
Which of these sentences works as proof in a task contract?skill
Correct
Proof is text you can check on the page. The agent's sentence is a promise; the screenshot alone doesn't say what to check; time is not a result.
Not that one
Proof is text you can check on the page. The agent's sentence is a promise; the screenshot alone doesn't say what to check; time is not a result.Review: The four parts
Question 2 of 4
The agent reached the login screen in the middle of the task. What does the contract say to do?skill
Correct
Login is a stop signal. A well-reported blocker names the screen, what is missing, and the person's action. Creating an account or trying a password breaks the limits.
Not that one
Login is a stop signal. A well-reported blocker names the screen, what is missing, and the person's action. Creating an account or trying a password breaks the limits.Review: Writing each part
Question 3 of 4
Why does conferir-contrato.mjs require a "no" in the limits?
Correct
Limits say what is allowed and what is not. When testing a site, the "no" protects whatever has consequences: confirming, paying, leaving the address.
Not that one
Limits say what is allowed and what is not. When testing a site, the "no" protects whatever has consequences: confirming, paying, leaving the address.Review: Writing each part
Question 4 of 4
The stop says "stop if it gets stuck." What is missing?
Correct
"Gets stuck" is something the agent decides on its own. A budget (10 actions) and clear signals (login, verification, confirmation) make the stop checkable.
Not that one
"Gets stuck" is something the agent decides on its own. A budget (10 actions) and clear signals (login, verification, confirmation) make the stop checkable.Review: The four parts
Quiz complete
You got {a} of {n} right. Get them all right and the lesson is marked as complete.
Pick an option. The explanation appears after you answer.
06 · In three sentences
Four partsGoal with a place, limits with a "no", proof in quotes, stop with a number.
Proof is not a sentenceIt's text you look for on the page and find.
Stopping is a resultStopping with the exact reason is worth more than pushing on and making things up.