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
- No notice before anything runs
- A normal run shows no notice
- A looping run shows
Stopped at the step limit after 3 steps. - 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.