Command Palette

Search for a command to run...

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

Say Why the Run Stopped

Two buttons start two runs: #normal (the agent finishes with a sentence) and #loop (the agent keeps calling a tool until its limit of 3 steps). The starter already sends which in the request body.

The server puts the finish reason in the message metadata. When the last assistant message has metadata.finishReason === "tool-calls", show a paragraph #notice with the text Stopped at the step limit after N steps. where N is the number of tool parts. In every other case, do not render #notice at all.

What Check tests

  1. No notice before anything runs
  2. A normal run shows no notice
  3. A looping run shows Stopped at the step limit after 3 steps.
  4. The code reads the finish reason

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.