Command Palette

Search for a command to run...

Hectal
Phase 14: Agents in the UI
AI Frontend · Exercise 5 of 5 Previous
Advanced

Ask Before the Refund

The refund tool waits for the user's approval. Click #start to send Refund ORD-1042. When the tool part is in the state approval-requested, show a card #card with the server's reason (part.approval.requestReason) and two buttons, #approve and #deny.

Answer with addToolApprovalResponse({ id, approved }), and use sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses so the run continues. When the refund step ends, show #result: Refund done for output-available and Refund skipped for output-denied. The card must disappear after the answer.

What Check tests

  1. No card before the click
  2. The card shows the server's reason
  3. Denying removes the card and shows Refund skipped
  4. The code answers with addToolApprovalResponse

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.