Skip to content
mentoor

Topic 5 of 5 · 4 min read

Stopping and steering a running generation

Goal: Specify what happens to partial output, state and billing when a user stops a running generation or sends a correction mid-stream.

Let users stop or redirect a generation at any time, and decide in advance what happens to the partial output, to any actions already taken and to the bill. A stop button is the user's control over a system that otherwise runs until it decides it is finished.

Check yourself · 1 of 3

A user stops a reply halfway through. What should happen to the partial text?

Choose one answer

Why it matters

Models sometimes go the wrong way: a long answer to the wrong question, a plan that missed a key fact, an agent about to edit the wrong folder. Waiting for it to finish wastes time, and with agents it can cause real changes. Users also notice a mistake mid-sentence and want to say "no, I meant the 2025 report" without waiting.

What to decide

  1. Stop button. Show it while the model is generating, in the place where Send was. It must work at once: the interface stops showing text immediately, and the request to the server is cancelled.
  2. Partial output. Keep what was already shown, mark it "Stopped", and let the user copy it, retry or continue. Do not delete it, and do not present it as a finished answer.
  3. Cost. Tokens already generated are usually still billed by the provider. Tell the user honestly, and, if your product has quotas, say whether a stopped run counts.
  4. Actions already taken. For agents, list what has already changed (files edited, emails sent) and offer undo where you can. Stopping a stream is not the same as undoing its effects.
  5. Steering mid-run. If the user sends a new message while a reply is running, pick one rule and show it: replace (stop now, answer the new message), queue (finish, then answer) or inject (the model sees it at the next step). Agents often inject. Chat usually replaces.
  6. Voice. In voice assistants, "barge-in" lets the user speak over the assistant. The audio must cut off at once, and the system must keep only what was actually heard.

Before and after

Before: The user clicks Stop. The text freezes, but the page still says "Generating" and the next message is blocked for 20 seconds.

After: The text stops, the reply is labelled "Stopped", and the box is free. "Retry" and "Continue" appear under it.

What goes wrong

  • A stop button that only hides the text while the model keeps going and billing.
  • Deleting the partial answer, so the user loses useful text.
  • Treating a stopped agent as clean, while it already changed three files.
  • A new message that silently disappears because nothing says it was queued.

Optional code branch (engineers). In the browser, pass an AbortSignal to fetch and call abort() when Stop is clicked. On the server, cancel the upstream model call when the client disconnects.

Examples

A correction mid-stream

User: Summarise the 2024 sales report.

Assistant: (streaming) The 2024 report shows that...

User (while streaming): Sorry, the 2025 report.

System: Stopped the first answer (kept above). Answering your new message now.

The rule here is replace: the old answer is kept but marked stopped.

Stopping an agent

An agent that renames files is stopped after 40 of 120. The interface says: "Stopped. 40 files were already renamed. Undo these 40, or keep them and continue?" Stopping did not undo the work, and the user is told so.

Key points

  • A Stop button should appear while generating, work immediately and free the input box.
  • Keep partial output, label it as stopped and offer Retry and Continue instead of deleting it.
  • Tokens already generated are usually still billed, so tell users honestly and define what counts against a quota.
  • Stopping an agent does not undo its actions; list what changed and offer undo where possible.
  • Choose and show one rule for mid-run messages: replace, queue or inject.

Common mistakes

  • Hiding the text on Stop while the model keeps running and billing.
  • Deleting partial output the user may want to keep.
  • Assuming a stopped agent has changed nothing.
  • Handling a mid-run message with no visible rule, so it looks lost.

Check yourself · 2 of 3

A coding agent has edited 3 files when the user clicks Stop. What should the interface do?

Choose one answer

Check yourself · 3 of 3

A user types a new message while the assistant is still replying. Which design is clear?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic