E7 · Fix the cancellation
15 minPut consequentialHint and the confirmation in cancelar_agendamento and run the check afterward block.
Done when: RESULTADO: 0 falhas and saída: 0.
Lesson 3 · 18 min
Booking, canceling, paying, deleting. The agent may pick the wrong tool, misread the description, or obey planted text. The WebMCP spec answers with consequentialHint, so the client can require confirmation. In this lesson you add the annotation and your site's own confirmation, and you prove that declining changes nothing.
Start the lesson
Goal: add consequentialHint and a confirmation with target and effect to every tool that changes something, and prove that declining changes nothing.
Tap each step.
The annotation is for the client; the confirmation is yours. One doesn't replace the other.
The question says what, whose, and what happens next. "Are you sure?" won't do: the person doesn't know what they're approving.
One question per call, with that call's arguments. If the target changes, it's a new question. Never a "yes" that covers the next ones.
The spec shows finalizeCart: the agent thought it was only closing the cart to look, and the tool made the purchase (§6.3.2.3). Name and description state the effect: comprar_carrinho, "charges the saved card".
The dialog lives on the page, and an agent that operates the screen can click Confirm too. checar.mjs itself clicks, the way an agent would. For a high-value action, ask for something the agent doesn't have: the password again, or a code sent to the person.
Edit cancelar_agendamento in kit/pagina/ferramentas.mjs as in the snippet and run the checker. The finished version is in kit/solucao/aula3/.
annotations: { consequentialHint: true }, // lesson 3: warns that the action has consequences
execute: util(async ({ codigo }, { signal }) => {
const ag = agenda.agendamentos().find(a => a.codigo === codigo);
if (!ag) throw new Error(`agendamento não encontrado: ${codigo}`);
// the question states the target and the effect in full; aborting the run (signal) counts as "no"
const ok = await ui.pedirConfirmacao(`Cancelar o agendamento ${ag.codigo} (${ag.id}, ${ag.nome})? A vaga volta para a agenda.`, signal);
if (!ok) return { cancelado: false, motivo: 'a pessoa recusou na tela' };
agenda.cancelar(codigo);
ui.atualizar();
return { cancelado: true, agendamento: ag };
})cd ~/projetos/formacao-webmcp-seguranca-v72/kit node scripts/checar.mjs; echo "saída: $?"
== Chromium 156.0.8078.4 (Playwright) · modo: nativo ok buscar_mentorias: só leitura, sem texto de terceiro ok ler_avaliacoes: devolve texto de terceiro e está marcada com untrustedContentHint ok meus_agendamentos: só leitura, sem texto de terceiro ok agendar_mentoria: consequentialHint + confirmação; recusar não mudou nada ok cancelar_agendamento: consequentialHint + confirmação; recusar não mudou nada RESULTADO: 0 falhas saída: 0
Before the fix, the same line said FALHA cancelar_agendamento: agiu sem pedir confirmação (output from lesson 2).
The lock, in the kit and on your page.
Put consequentialHint and the confirmation in cancelar_agendamento and run the check afterward block.
Done when: RESULTADO: 0 falhas and saída: 0.
In agendar_mentoria, replace const ok = await ui.pedirConfirmacao(…) with const ok = true and run the checker. Then undo it.
Done when: FALHA agendar_mentoria: agiu sem pedir confirmação and saída: 1; once undone, RESULTADO: 0 falhas.
List the tools on your site that change something. Each one gets consequentialHint: true and a question that names the target and the effect.
Done when: grep -c "consequentialHint: true" [your tools file] → the number of tools on your list.
Question 1 of 4
What does the spec say the client can do when it sees consequentialHint?skill
Question 2 of 4
Which confirmation question actually protects?
Question 3 of 4
Why does the course say confirmation on the page has a limit?
Question 4 of 4
In the spec's finalizeCart case, what went wrong?
Choose an answer. The explanation appears after you try.